summaryrefslogtreecommitdiffstats
path: root/multivimbroker
diff options
context:
space:
mode:
Diffstat (limited to 'multivimbroker')
-rw-r--r--multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py6
-rw-r--r--multivimbroker/multivimbroker/forwarder/views.py15
-rw-r--r--multivimbroker/multivimbroker/pub/msapi/extsys.py7
-rw-r--r--multivimbroker/multivimbroker/pub/utils/syscomm.py16
-rw-r--r--multivimbroker/multivimbroker/settings.py4
-rw-r--r--multivimbroker/multivimbroker/tests/test_extsys.py42
-rw-r--r--multivimbroker/requirements.txt13
-rwxr-xr-xmultivimbroker/run.sh15
-rwxr-xr-xmultivimbroker/stop.sh3
9 files changed, 95 insertions, 26 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/msapi/extsys.py b/multivimbroker/multivimbroker/pub/msapi/extsys.py
index f5e26aa..e04c5f5 100644
--- a/multivimbroker/multivimbroker/pub/msapi/extsys.py
+++ b/multivimbroker/multivimbroker/pub/msapi/extsys.py
@@ -14,7 +14,7 @@ import json
import logging
from multivimbroker.pub.exceptions import VimBrokerException
-from multivimbroker.pub.utils.restcall import get_res_from_aai
+from multivimbroker.pub.utils import restcall
logger = logging.getLogger(__name__)
@@ -28,8 +28,9 @@ def split_vim_to_owner_region(vim_id):
def get_vim_by_id(vim_id):
cloud_owner, cloud_region = split_vim_to_owner_region(vim_id)
- ret = get_res_from_aai("/cloud-infrastructure/cloud-regions/cloud-region"
- "/%s/%s" % (cloud_owner, cloud_region))
+ ret = restcall.get_res_from_aai("/cloud-infrastructure/cloud-regions/"
+ "cloud-region/%s/%s" % (
+ cloud_owner, cloud_region))
if ret[0] != 0:
logger.error("Status code is %s, detail is %s." % (ret[2], ret[1]))
raise VimBrokerException(
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
diff --git a/multivimbroker/multivimbroker/settings.py b/multivimbroker/multivimbroker/settings.py
index 8d1fba5..c1d31d0 100644
--- a/multivimbroker/multivimbroker/settings.py
+++ b/multivimbroker/multivimbroker/settings.py
@@ -26,9 +26,9 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o'
# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
+# DEBUG = True
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ['*']
# Application definition
diff --git a/multivimbroker/multivimbroker/tests/test_extsys.py b/multivimbroker/multivimbroker/tests/test_extsys.py
new file mode 100644
index 0000000..c13779c
--- /dev/null
+++ b/multivimbroker/multivimbroker/tests/test_extsys.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2017-2018 VMware, 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 mock
+import unittest
+
+from multivimbroker.pub.msapi import extsys
+from multivimbroker.pub.utils import restcall
+
+
+class TestExtsys(unittest.TestCase):
+
+ def test_split_vim_to_owner_region(self):
+ vim_id = "openstack_regionone"
+ cloud_owner, cloud_region = extsys.split_vim_to_owner_region(vim_id)
+ self.assertEqual("openstack", cloud_owner)
+ self.assertEqual("regionone", cloud_region)
+
+ @mock.patch.object(restcall, "get_res_from_aai")
+ def test_get_vim_by_id_success(self, mock_get_res):
+ resp_body = """{
+ "cloud-type": "openstack",
+ "cloud-region-version": "regionone"
+ }"""
+ mock_get_res.return_value = (0, resp_body, 200, mock.Mock())
+ vim_id = "openstack_regionone"
+ ret = extsys.get_vim_by_id(vim_id)
+ expect_ret = {
+ "cloud-type": "openstack",
+ "cloud-region-version": "regionone",
+ "type": "openstack",
+ "version": "regionone",
+ "vimId": vim_id
+ }
+ self.assertDictEqual(expect_ret, ret)
diff --git a/multivimbroker/requirements.txt b/multivimbroker/requirements.txt
index ef24d49..5aadc57 100644
--- a/multivimbroker/requirements.txt
+++ b/multivimbroker/requirements.txt
@@ -24,4 +24,15 @@ mock==2.0.0
unittest_xml_reporting==1.12.0
# for onap logging
-onappylog>=1.0.6 \ No newline at end of file
+onappylog>=1.0.6
+
+# for pecan framework
+pecan>=1.2.1
+oslo.concurrency>=3.21.0
+oslo.config>=4.11.0
+oslo.service>=1.25.0
+eventlet>=0.20.0
+
+# uwsgi for parallel processing
+uwsgi
+
diff --git a/multivimbroker/run.sh b/multivimbroker/run.sh
index 35f2b9e..8270deb 100755
--- a/multivimbroker/run.sh
+++ b/multivimbroker/run.sh
@@ -26,10 +26,15 @@ if [ ! -x $logDir ]; then
mkdir -p $logDir
fi
-nohup python manage.py runserver 0.0.0.0:9001 2>&1 &
+if [ "$WEB_FRAMEWORK" == "pecan" ]
+then
+ python multivimbroker/scripts/api.py
+else
+ # nohup python manage.py runserver 0.0.0.0:9001 2>&1 &
+ nohup uwsgi --http :9001 --module multivimbroker.wsgi --master --processes 4 &
-while [ ! -f $logDir/multivimbroker.log ]; do
- sleep 1
-done
+ while [ ! -f $logDir/multivimbroker.log ]; do
+ sleep 1
+ done
-tail -F $logDir/multivimbroker.log
+ tail -F $logDir/multivimbroker.log
diff --git a/multivimbroker/stop.sh b/multivimbroker/stop.sh
index 4a2e5c3..ba0a2c8 100755
--- a/multivimbroker/stop.sh
+++ b/multivimbroker/stop.sh
@@ -11,4 +11,5 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-ps auxww | grep 'manage.py runserver 0.0.0.0:9001' | awk '{print $2}' | xargs kill -9
+# ps auxww | grep 'manage.py runserver 0.0.0.0:9001' | awk '{print $2}' | xargs kill -9
+ps auxww |grep 'uwsgi --http :9001 --module multivimbroker.wsgi --master' |awk '{print $2}' |xargs kill -9