summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--multivimbroker/multivimbroker/forwarder/views.py35
-rw-r--r--multivimbroker/multivimbroker/pub/config/provider-plugin.json29
-rw-r--r--multivimbroker/multivimbroker/pub/utils/syscomm.py24
-rw-r--r--multivimbroker/multivimbroker/samples/__init__.py10
-rw-r--r--multivimbroker/multivimbroker/samples/tests.py30
-rw-r--r--multivimbroker/multivimbroker/samples/urls.py16
-rw-r--r--multivimbroker/multivimbroker/samples/views.py26
-rw-r--r--multivimbroker/multivimbroker/urls.py1
8 files changed, 48 insertions, 123 deletions
diff --git a/multivimbroker/multivimbroker/forwarder/views.py b/multivimbroker/multivimbroker/forwarder/views.py
index 59c566b..e098065 100644
--- a/multivimbroker/multivimbroker/forwarder/views.py
+++ b/multivimbroker/multivimbroker/forwarder/views.py
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
+import json
+
from rest_framework.views import APIView
from rest_framework.views import Response
from rest_framework.views import status
@@ -79,33 +82,11 @@ class VIMTypes(BaseServer):
def get(self, request):
# Fix here unless we have plugin registry
- data = {
- "vim_types": [
- {
- "vim_type": "openstack",
- "versions": [
- {
- "version": "titanium_cloud",
- "extra_info_hint": ""
- },
- {
- "version": "ocata",
- "extra_info_hint": ""
- }
- ]
- },
- {
- "vim_type": "vmware",
- "versions": [
- {
- "version": "4.0",
- "extra_info_hint": ""
- }
- ]
- }
- ]
- }
-
+ 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)
+ data = {"vim_types": plugins}
return Response(data=data, status=status.HTTP_200_OK)
diff --git a/multivimbroker/multivimbroker/pub/config/provider-plugin.json b/multivimbroker/multivimbroker/pub/config/provider-plugin.json
new file mode 100644
index 0000000..0ac4701
--- /dev/null
+++ b/multivimbroker/multivimbroker/pub/config/provider-plugin.json
@@ -0,0 +1,29 @@
+{
+ "openstack": {
+ "vim_type": "openstack",
+ "versions": {
+ "titanium_cloud": {
+ "version": "titanium_cloud",
+ "extra_info_hint": "",
+ "provider_plugin": "multicloud-titanium_cloud"
+ },
+ "ocata": {
+ "version": "ocata",
+ "extra_info_hint": "",
+ "provider_plugin": "multicloud-ocata"
+ }
+ },
+ "provider_plugin": "multicloud-ocata"
+ },
+ "vmware": {
+ "vim_type": "vmware",
+ "versions": {
+ "4.0": {
+ "version": "4.0",
+ "extra_info_hint": "",
+ "provider_plugin": "multicloud-vio"
+ }
+ },
+ "provider_plugin": "multicloud-vio"
+ }
+} \ No newline at end of file
diff --git a/multivimbroker/multivimbroker/pub/utils/syscomm.py b/multivimbroker/multivimbroker/pub/utils/syscomm.py
index 7c5d94e..65039ae 100644
--- a/multivimbroker/multivimbroker/pub/utils/syscomm.py
+++ b/multivimbroker/multivimbroker/pub/utils/syscomm.py
@@ -10,6 +10,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import inspect
+import json
+import os
import re
import multivimbroker.pub.exceptions as exceptions
@@ -34,20 +36,16 @@ def getHeadersKeys(response):
def findMultivimDriver(vim=None):
-
- if vim and vim["type"] == "openstack":
- if vim["version"] == "ocata":
- multivimdriver = "multicloud-ocata"
- elif vim["version"] == "titanium_cloud":
- multivimdriver = "multicloud-titanium_cloud"
- else:
- # if vim type is openstack, use "ocata" version as default
- multivimdriver = "multicloud-ocata"
- elif vim and vim["type"] == "vmware":
- multivimdriver = "multicloud-vio"
- else:
+ json_file = os.path.join(os.path.dirname(__file__),
+ '../config/provider-plugin.json')
+ with open(json_file, "r") as f:
+ plugins = json.load(f)
+ if not vim or vim.get("type") not in plugins.keys():
raise exceptions.NotFound("Not support VIM type")
- return multivimdriver
+ plugin = plugins[vim["type"]]
+ if vim.get("version") in plugin["versions"].keys():
+ return plugin["versions"][vim["version"]]["provider_plugin"]
+ return plugin["provider_plugin"]
def getMultivimDriver(vimid, full_path=""):
diff --git a/multivimbroker/multivimbroker/samples/__init__.py b/multivimbroker/multivimbroker/samples/__init__.py
deleted file mode 100644
index 802f3fb..0000000
--- a/multivimbroker/multivimbroker/samples/__init__.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright (c) 2017 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/multivimbroker/multivimbroker/samples/tests.py b/multivimbroker/multivimbroker/samples/tests.py
deleted file mode 100644
index 25850c9..0000000
--- a/multivimbroker/multivimbroker/samples/tests.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (c) 2017 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-import unittest
-import json
-from django.test import Client
-from rest_framework import status
-
-
-class SampleViewTest(unittest.TestCase):
- def setUp(self):
- self.client = Client()
-
- def tearDown(self):
- pass
-
- def test_sample(self):
- response = self.client.get("/samples/")
- self.assertEqual(status.HTTP_200_OK,
- response.status_code, response.content)
- resp_data = json.loads(response.content)
- self.assertEqual({"status": "active"}, resp_data)
diff --git a/multivimbroker/multivimbroker/samples/urls.py b/multivimbroker/multivimbroker/samples/urls.py
deleted file mode 100644
index 71ffa88..0000000
--- a/multivimbroker/multivimbroker/samples/urls.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (c) 2017 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-from django.conf.urls import url
-from multivimbroker.samples import views
-
-urlpatterns = [
- url(r'^samples/$', views.SampleList.as_view()), ]
diff --git a/multivimbroker/multivimbroker/samples/views.py b/multivimbroker/multivimbroker/samples/views.py
deleted file mode 100644
index e51044a..0000000
--- a/multivimbroker/multivimbroker/samples/views.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (c) 2017 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-import logging
-
-from rest_framework.views import APIView
-from rest_framework.response import Response
-
-logger = logging.getLogger(__name__)
-
-
-class SampleList(APIView):
- """
- List all samples.
- """
- def get(self, request, format=None):
- logger.debug("get")
- return Response({"status": "active"})
diff --git a/multivimbroker/multivimbroker/urls.py b/multivimbroker/multivimbroker/urls.py
index 7619e5a..de2ef49 100644
--- a/multivimbroker/multivimbroker/urls.py
+++ b/multivimbroker/multivimbroker/urls.py
@@ -17,7 +17,6 @@ from multivimbroker.pub.config import config
urlpatterns = [
url(r'^', include('multivimbroker.swagger.urls')),
- url(r'^', include('multivimbroker.samples.urls')),
url(r'^', include('multivimbroker.forwarder.urls')),
]