diff options
author | zhang ab <zhanganbing@chinamobile.com> | 2018-03-23 07:22:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-23 07:22:35 +0000 |
commit | 8bc264d30294b15639c37ab446aa081ff09e41f0 (patch) | |
tree | acf75b5fad1e025b762d0bf7b4a8274430a6e223 | |
parent | 0e9683577c34acfdea8f067813048bf47665ec4a (diff) | |
parent | a137643d7f753d1b26f0d7863912264e7c49a2fe (diff) |
Merge "Migrate get vim_types to new framework"
-rw-r--r-- | multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py | 6 | ||||
-rw-r--r-- | multivimbroker/multivimbroker/forwarder/views.py | 15 | ||||
-rw-r--r-- | multivimbroker/multivimbroker/pub/utils/syscomm.py | 16 |
3 files changed, 23 insertions, 14 deletions
diff --git a/multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py b/multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py index 83b4260..99c1b08 100644 --- a/multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py +++ b/multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py @@ -13,10 +13,10 @@ import logging import pecan -from multivimbroker.swagger import utils from multivimbroker.pub import exceptions from multivimbroker.pub.utils import restcall from multivimbroker.pub.utils import syscomm +from multivimbroker.swagger import utils logger = logging.getLogger(__name__) @@ -30,6 +30,10 @@ IDENTITY_AUTH_URI = "identity/v3/auth/tokens" class V0_Controller(object): + @pecan.expose('json') + def vim_types(self): + return syscomm.getVIMTypes() + @pecan.expose('json', route="swagger.json") def swagger_json(self): return utils.get_swagger_json_data() diff --git a/multivimbroker/multivimbroker/forwarder/views.py b/multivimbroker/multivimbroker/forwarder/views.py index 83d3172..d1763c2 100644 --- a/multivimbroker/multivimbroker/forwarder/views.py +++ b/multivimbroker/multivimbroker/forwarder/views.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import json from rest_framework.views import APIView @@ -21,6 +20,7 @@ from rest_framework.views import Response from rest_framework.views import status from multivimbroker.forwarder.base import BaseHandler from multivimbroker.pub.utils.syscomm import originHeaders +from multivimbroker.pub.utils import syscomm class BaseServer(BaseHandler, APIView): @@ -85,18 +85,7 @@ class Extension(BaseServer): class VIMTypes(BaseServer): def get(self, request): - # Fix here unless we have plugin registry - json_file = os.path.join(os.path.dirname(__file__), - '../pub/config/provider-plugin.json') - with open(json_file, "r") as f: - plugins = json.load(f) - ret = [] - for k, v in plugins.items(): - item = {} - item["vim_type"] = v.get("vim_type") - item["versions"] = [k for k in v.get('versions', {})] - ret.append(item) - return Response(data=ret, status=status.HTTP_200_OK) + return Response(data=syscomm.getVIMTypes(), status=status.HTTP_200_OK) class CheckCapacity(BaseServer): diff --git a/multivimbroker/multivimbroker/pub/utils/syscomm.py b/multivimbroker/multivimbroker/pub/utils/syscomm.py index bd4bbb5..337a1bd 100644 --- a/multivimbroker/multivimbroker/pub/utils/syscomm.py +++ b/multivimbroker/multivimbroker/pub/utils/syscomm.py @@ -62,3 +62,19 @@ def getMultivimDriver(vimid, full_path=""): vim = get_vim_by_id(vimid) multclouddriver = findMultivimDriver(vim=vim) return re.sub(multcloud, multclouddriver, full_path) + + +def getVIMTypes(): + # Fix here unless we have plugin registry + json_file = os.path.join(os.path.dirname(__file__), + '../config/provider-plugin.json') + with open(json_file, "r") as f: + plugins = json.load(f) + ret = [] + for k, v in plugins.items(): + item = {} + item["vim_type"] = v.get("vim_type") + item["versions"] = [k for k in v.get('versions', {})] + ret.append(item) + + return ret |