# 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
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)
--- /dev/null
+{
+ "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
# 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
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=""):
+++ /dev/null
-# 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.
+++ /dev/null
-# 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)
+++ /dev/null
-# 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()), ]
+++ /dev/null
-# 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"})
urlpatterns = [
url(r'^', include('multivimbroker.swagger.urls')),
- url(r'^', include('multivimbroker.samples.urls')),
url(r'^', include('multivimbroker.forwarder.urls')),
]