diff options
-rw-r--r-- | docs/specs/parallelism_improvement.rst | 2 | ||||
-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 | ||||
-rw-r--r-- | multivimbroker/requirements.txt | 9 | ||||
-rwxr-xr-x | multivimbroker/run.sh | 14 |
6 files changed, 41 insertions, 21 deletions
diff --git a/docs/specs/parallelism_improvement.rst b/docs/specs/parallelism_improvement.rst index 00d66df..86f39d8 100644 --- a/docs/specs/parallelism_improvement.rst +++ b/docs/specs/parallelism_improvement.rst @@ -116,7 +116,7 @@ Result: 100000 requests, concurrency level 1000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Command: `ab -n 10000 -c 100 http://<IP:port>/api/multicloud/v0/vim_types` +Command: `ab -n 100000 -c 1000 http://<IP:port>/api/multicloud/v0/vim_types` Result: Django runserver: Apache Benchmark quit because it reports timeout after running a random portion of all requests. 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 diff --git a/multivimbroker/requirements.txt b/multivimbroker/requirements.txt index ef24d49..1d8330c 100644 --- a/multivimbroker/requirements.txt +++ b/multivimbroker/requirements.txt @@ -24,4 +24,11 @@ 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 diff --git a/multivimbroker/run.sh b/multivimbroker/run.sh index 35f2b9e..e73496f 100755 --- a/multivimbroker/run.sh +++ b/multivimbroker/run.sh @@ -26,10 +26,14 @@ 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 & -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 |