summaryrefslogtreecommitdiffstats
path: root/newton
diff options
context:
space:
mode:
authorzhang ab <zhanganbing@chinamobile.com>2018-03-12 03:23:34 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-12 03:23:34 +0000
commitcc66925f30debaeb720d3a189b3e06cbb681f6fa (patch)
tree529f277a03b381d9d971ff00bab670936b4acee5 /newton
parent8bddebb95d3f42eaf3da5523a2a07d3b2da5447a (diff)
parent51fde27c2a12f525e94ecd3a83238a46215d9392 (diff)
Merge "newton use share library"
Diffstat (limited to 'newton')
-rw-r--r--newton/assembly.xml12
-rw-r--r--newton/newton/extensions/tests/test_epacaps.py6
-rw-r--r--newton/newton/extensions/tests/test_extensions.py2
-rw-r--r--newton/newton/extensions/views/epacaps.py44
-rw-r--r--newton/newton/extensions/views/extensions.py58
-rw-r--r--newton/newton/proxy/tests/test_identity_proxy.py6
-rw-r--r--newton/newton/proxy/tests/test_service_proxy.py6
-rw-r--r--newton/newton/proxy/urls.py2
-rw-r--r--newton/newton/proxy/views/dnsaasdelegate.py196
-rw-r--r--newton/newton/proxy/views/identityV3.py215
-rw-r--r--newton/newton/proxy/views/proxy_utils.py196
-rw-r--r--newton/newton/proxy/views/services.py242
-rw-r--r--newton/newton/pub/__init__.py14
-rw-r--r--newton/newton/pub/config/__init__.py13
-rw-r--r--newton/newton/pub/config/config.py38
-rw-r--r--newton/newton/pub/database/__init__.py14
-rw-r--r--newton/newton/pub/database/models.py23
-rw-r--r--newton/newton/pub/exceptions.py19
-rw-r--r--newton/newton/pub/msapi/__init__.py14
-rw-r--r--newton/newton/pub/msapi/extsys.py101
-rw-r--r--newton/newton/pub/tests/__init__.py14
-rw-r--r--newton/newton/pub/tests/test_extsys.py131
-rw-r--r--newton/newton/pub/tests/test_restcall.py111
-rw-r--r--newton/newton/pub/utils/__init__.py14
-rw-r--r--newton/newton/pub/utils/enumutil.py16
-rw-r--r--newton/newton/pub/utils/fileutil.py52
-rw-r--r--newton/newton/pub/utils/idutil.py21
-rw-r--r--newton/newton/pub/utils/restcall.py149
-rw-r--r--newton/newton/pub/utils/share_lock.py80
-rw-r--r--newton/newton/pub/utils/syscomm.py19
-rw-r--r--newton/newton/pub/utils/timeutil.py19
-rw-r--r--newton/newton/pub/utils/toscautil.py2606
-rw-r--r--newton/newton/pub/utils/values.py24
-rw-r--r--newton/newton/registration/tests/test_registration.py8
-rw-r--r--newton/newton/registration/views/registration.py680
-rw-r--r--newton/newton/requests/tests/mock_info.py568
-rw-r--r--newton/newton/requests/tests/test_base.py252
-rw-r--r--newton/newton/requests/tests/test_flavor.py12
-rw-r--r--newton/newton/requests/tests/test_hosts.py2
-rw-r--r--newton/newton/requests/tests/test_image.py10
-rw-r--r--newton/newton/requests/tests/test_limits.py8
-rw-r--r--newton/newton/requests/tests/test_network.py2
-rw-r--r--newton/newton/requests/tests/test_server.py6
-rw-r--r--newton/newton/requests/tests/test_subnet.py8
-rw-r--r--newton/newton/requests/tests/test_tenant.py6
-rw-r--r--newton/newton/requests/tests/test_util.py6
-rw-r--r--newton/newton/requests/tests/test_volume.py8
-rw-r--r--newton/newton/requests/tests/test_vport.py6
-rw-r--r--newton/newton/requests/urls.py18
-rw-r--r--newton/newton/settings.py24
-rw-r--r--newton/newton/swagger/multicloud.identity.swagger.json59
-rw-r--r--newton/newton/swagger/multivim.flavor.swagger.json392
-rw-r--r--newton/newton/swagger/multivim.host.swagger.json233
-rw-r--r--newton/newton/swagger/multivim.image.swagger.json359
-rw-r--r--newton/newton/swagger/multivim.limit.swagger.json158
-rw-r--r--newton/newton/swagger/multivim.network.swagger.json349
-rw-r--r--newton/newton/swagger/multivim.server.swagger.json488
-rw-r--r--newton/newton/swagger/multivim.subnet.swagger.json417
-rw-r--r--newton/newton/swagger/multivim.tenant.swagger.json102
-rw-r--r--newton/newton/swagger/multivim.volume.swagger.json378
-rw-r--r--newton/newton/swagger/multivim.vport.swagger.json363
-rw-r--r--newton/newton/swagger/tests.py2
-rw-r--r--newton/newton/swagger/urls.py1
-rw-r--r--newton/newton/swagger/views.py87
-rw-r--r--newton/newton/urls.py2
-rw-r--r--newton/pom.xml47
-rw-r--r--newton/requirements.txt19
-rwxr-xr-xnewton/run.sh10
-rw-r--r--newton/setup.cfg24
-rw-r--r--newton/setup.py21
-rw-r--r--newton/test-requirements.txt3
-rw-r--r--newton/tox.ini19
72 files changed, 166 insertions, 9468 deletions
diff --git a/newton/assembly.xml b/newton/assembly.xml
index f77a1145..55d172a1 100644
--- a/newton/assembly.xml
+++ b/newton/assembly.xml
@@ -34,6 +34,18 @@
</includes>
</fileSet>
<fileSet>
+ <directory>../share</directory>
+ <outputDirectory>/lib/share</outputDirectory>
+ <includes>
+ <include>**/*.py</include>
+ <include>**/*.json</include>
+ <include>**/*.xml</include>
+ <include>**/*.wsdl</include>
+ <include>**/*.xsd</include>
+ <include>**/*.bpel</include>
+ </includes>
+ </fileSet>
+ <fileSet>
<directory>logs</directory>
<outputDirectory>/logs</outputDirectory>
<includes>
diff --git a/newton/newton/extensions/tests/test_epacaps.py b/newton/newton/extensions/tests/test_epacaps.py
index 35604165..0588f773 100644
--- a/newton/newton/extensions/tests/test_epacaps.py
+++ b/newton/newton/extensions/tests/test_epacaps.py
@@ -19,9 +19,9 @@ from django.test import Client
from rest_framework import status
import unittest
-from newton.requests.tests import test_base
-from newton.requests.tests import mock_info
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import test_base
+from newton_base.tests import mock_info
+from newton_base.util import VimDriverUtils
class TestEpaCaps(unittest.TestCase):
diff --git a/newton/newton/extensions/tests/test_extensions.py b/newton/newton/extensions/tests/test_extensions.py
index 7b92b61e..ebdb2168 100644
--- a/newton/newton/extensions/tests/test_extensions.py
+++ b/newton/newton/extensions/tests/test_extensions.py
@@ -16,7 +16,7 @@ from django.test import Client
from rest_framework import status
import unittest
-from newton.requests.tests import test_base
+from newton_base.tests import test_base
class TestExtensions(unittest.TestCase):
diff --git a/newton/newton/extensions/views/epacaps.py b/newton/newton/extensions/views/epacaps.py
index de5a24bf..77542b31 100644
--- a/newton/newton/extensions/views/epacaps.py
+++ b/newton/newton/extensions/views/epacaps.py
@@ -16,48 +16,18 @@ import logging
import json
import traceback
-from keystoneauth1.exceptions import HttpError
-from rest_framework import status
-from rest_framework.response import Response
-from rest_framework.views import APIView
+from django.conf import settings
-from newton.pub.config import config
-from newton.pub.exceptions import VimDriverNewtonException
-from newton.requests.views.util import VimDriverUtils
-from newton.pub.msapi import extsys
+
+from newton_base.extensions import epacaps as newton_epacaps
logger = logging.getLogger(__name__)
+DEBUG=True
+
-class EpaCaps(APIView):
+class EpaCaps(newton_epacaps.EpaCaps):
def __init__(self):
- self.proxy_prefix = config.MULTICLOUD_PREFIX
+ self.proxy_prefix = settings.MULTICLOUD_PREFIX
self._logger = logger
-
- def get(self, request, vimid=""):
- logger.debug("EpaCaps--get::data> %s" % request.data)
- logger.debug("EpaCaps--get::vimid> %s"
- % vimid)
- try:
-
- vim = VimDriverUtils.get_vim_info(vimid)
- caps_json = json.loads(vim['cloud_epa_caps'])
-
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- content = {
- "cloud-owner":cloud_owner,
- "cloud-region-id":cloud_region_id,
- "vimid":vimid,
- "cloud-epa-caps": caps_json,
- }
- return Response(data=content, status=status.HTTP_200_OK)
- except VimDriverNewtonException as e:
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- logger.error(traceback.format_exc())
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/newton/newton/extensions/views/extensions.py b/newton/newton/extensions/views/extensions.py
index 321b86fc..851bc7ea 100644
--- a/newton/newton/extensions/views/extensions.py
+++ b/newton/newton/extensions/views/extensions.py
@@ -13,66 +13,16 @@
# limitations under the License.
import logging
-import json
-import traceback
-from django.core.cache import cache
-
-from keystoneauth1 import access
-from keystoneauth1.access import service_catalog
-from keystoneauth1.exceptions import HttpError
-from rest_framework import status
-from rest_framework.response import Response
-from rest_framework.views import APIView
-
-from newton.pub.config import config
-from newton.pub.exceptions import VimDriverNewtonException
-from newton.requests.views.util import VimDriverUtils
-from newton.pub.msapi import extsys
+from django.conf import settings
+from newton_base.extensions import extensions as newton_extensions
logger = logging.getLogger(__name__)
DEBUG=True
-
-class Extensions(APIView):
+class Extensions(newton_extensions.Extensions):
def __init__(self):
- self.proxy_prefix = config.MULTICLOUD_PREFIX
self._logger = logger
-
- def get(self, request, vimid=""):
- logger.debug("Extensions--get::data> %s" % request.data)
- logger.debug("Extensions--get::vimid> %s"
- % vimid)
- try:
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- registered_extensions = \
- [
- {
- "alias": "epa-caps",
- "description": "Multiple network support",
- "name": "EPACapsQuery",
- "url": self.proxy_prefix + "/%s/extensions/epa-caps" \
- % (vimid),
- "spec": ""
- }
- ]
-
- content = {
- "cloud-owner":cloud_owner,
- "cloud-region-id":cloud_region_id,
- "vimid":vimid,
- "extensions": registered_extensions
- }
- return Response(data=content, status=status.HTTP_200_OK)
-
- except VimDriverNewtonException as e:
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- logger.error(traceback.format_exc())
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ self.proxy_prefix = settings.MULTICLOUD_PREFIX
diff --git a/newton/newton/proxy/tests/test_identity_proxy.py b/newton/newton/proxy/tests/test_identity_proxy.py
index 5d7616c5..f61ba699 100644
--- a/newton/newton/proxy/tests/test_identity_proxy.py
+++ b/newton/newton/proxy/tests/test_identity_proxy.py
@@ -19,9 +19,9 @@ import mock
from rest_framework import status
import unittest
-from newton.requests.tests import test_base
-from newton.requests.views.util import VimDriverUtils
-from newton.requests.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.util import VimDriverUtils
+from newton_base.tests import mock_info
mock_catalog_response = {
diff --git a/newton/newton/proxy/tests/test_service_proxy.py b/newton/newton/proxy/tests/test_service_proxy.py
index 39cc3dd9..d11ccb06 100644
--- a/newton/newton/proxy/tests/test_service_proxy.py
+++ b/newton/newton/proxy/tests/test_service_proxy.py
@@ -20,9 +20,9 @@ import mock
from rest_framework import status
import unittest
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.util import VimDriverUtils
MOCK_GET_SERVERS_RESPONSE = {
"servers": [
diff --git a/newton/newton/proxy/urls.py b/newton/newton/proxy/urls.py
index d5d67800..0322e79c 100644
--- a/newton/newton/proxy/urls.py
+++ b/newton/newton/proxy/urls.py
@@ -17,7 +17,7 @@ from rest_framework.urlpatterns import format_suffix_patterns
from newton.proxy.views import identityV3
from newton.proxy.views import services
-from newton.proxy.views import dnsaasdelegate
+from newton_base.proxy import dnsaasdelegate
urlpatterns = [
# url(r'^identity/v2)$',
diff --git a/newton/newton/proxy/views/dnsaasdelegate.py b/newton/newton/proxy/views/dnsaasdelegate.py
deleted file mode 100644
index e2c657d9..00000000
--- a/newton/newton/proxy/views/dnsaasdelegate.py
+++ /dev/null
@@ -1,196 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-import json
-import traceback
-
-from keystoneauth1.exceptions import HttpError
-import re
-from rest_framework.permissions import BasePermission
-from rest_framework.response import Response
-from rest_framework import status
-from rest_framework.views import APIView
-
-from newton.proxy.views.services import Services
-
-from newton.proxy.views.proxy_utils import ProxyUtils
-from newton.pub.exceptions import VimDriverNewtonException
-from newton.pub.msapi import extsys
-from newton.requests.views.util import VimDriverUtils
-
-
-logger = logging.getLogger(__name__)
-
-DEBUG=True
-
-class DnsaasDelegate(Services):
- '''
- DNSaaS delegate service
- '''
-
- def __init__(self):
- self._logger = logger
-
-
- def _do_action(self, action, request, vim_id, servicetype, requri):
- tmp_auth_token = self._get_token(request)
- try:
- # fetch the auth_state out of cache
- auth_state_str, metadata_catalog_str = VimDriverUtils.get_token_cache(tmp_auth_token)
-
- if not auth_state_str:
- #invalid token
- return Response(data={'error': "request token %s is not valid" % (tmp_auth_token)},
- status=status.HTTP_404_NOT_FOUND)
-
- # get project name from auth_state
- auth_state = json.loads(auth_state_str)
- if not auth_state:
- # invalid token
- return Response(data={'error': "request token %s is broken" % (tmp_auth_token)},
- status=status.HTTP_404_NOT_FOUND)
-
- tenant_name = auth_state['body']['token']['project']['name']
- #tenant_id = auth_state['body']['token']['project']['id']
-
- #find out the delegated DNSaaS provider
- viminfo = VimDriverUtils.get_vim_info(vim_id)
- if not viminfo:
- return Response(data={'error': "vimid %s is not found" % (vim_id)},
- status=status.HTTP_404_NOT_FOUND)
-
- cloud_dns_delegate_info = None
- cloud_extra_info_str = viminfo.get('cloud_extra_info')
- if cloud_extra_info_str:
- cloud_extra_info = json.loads(cloud_extra_info_str)
- cloud_dns_delegate_info = cloud_extra_info.get("dns-delegate")
-
- if not cloud_dns_delegate_info \
- or not cloud_dns_delegate_info.get("cloud-owner") \
- or not cloud_dns_delegate_info.get("cloud-region-id"):
- return Response(data={'error': "dns-delegate for vimid %s is not configured"
- % (vim_id)},
- status=status.HTTP_404_NOT_FOUND)
-
- vimid_delegate = cloud_dns_delegate_info.get("cloud-owner") \
- + "_" \
- + cloud_dns_delegate_info.get("cloud-region-id")
-
-
- #now forward request to delegated DNS service endpoint
- vim = VimDriverUtils.get_vim_info(vimid_delegate)
- if not vim:
- return Response(data={'error': "vimid %s is not found" % (vimid_delegate)},
- status=status.HTTP_404_NOT_FOUND)
-
- sess = VimDriverUtils.get_session(vim, tenant_name=tenant_name)
-
- cloud_owner, regionid = extsys.decode_vim_id(vimid_delegate)
- interface = 'public'
- service = {
- 'service_type': servicetype,
- 'interface': interface,
- 'region_id': regionid
- }
-
- req_resource = requri
- querystr = VimDriverUtils.get_query_part(request)
- if querystr:
- req_resource += "?" + querystr
-
- self._logger.debug("service " + action + " request uri %s" % (req_resource))
- if(action == "get"):
- resp = sess.get(req_resource, endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- elif(action == "post"):
- resp = sess.post(req_resource, data=json.JSONEncoder().encode(request.data),
- endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- elif(action == "put"):
- resp = sess.put(req_resource, data=json.JSONEncoder().encode(request.data),
- endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- elif(action == "patch"):
- resp = sess.patch(req_resource, data=json.JSONEncoder().encode(request.data),
- endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- elif (action == "delete"):
- resp = sess.delete(req_resource, endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- content = resp.json() if resp.content else None
- self._logger.debug("service " + action + " response: %s, %s" % (resp.status_code, content))
-
- if (action == "delete"):
- return Response(headers={'X-Subject-Token': tmp_auth_token}, status=resp.status_code)
- else:
- #content = ProxyUtils.update_dnsaas_project_id(content, tenant_id)
- return Response(headers={'X-Subject-Token': tmp_auth_token}, data=content, status=resp.status_code)
-
- except VimDriverNewtonException as e:
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
- def get(self, request, vimid="", servicetype="dns-delegate", requri=""):
- self._logger.debug("DnsaasDelegate--get::META> %s" % request.META)
- self._logger.debug("DnsaasDelegate--get::data> %s" % request.data)
- self._logger.debug("DnsaasDelegate--get::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("get", request, vimid, "dns", requri)
-
- def head(self, request, vimid="", servicetype="dns-delegate", requri=""):
- self._logger.debug("DnsaasDelegate--get::META> %s" % request.META)
- self._logger.debug("DnsaasDelegate--get::data> %s" % request.data)
- self._logger.debug("DnsaasDelegate--get::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("head", request, vimid, "dns", requri)
-
- def post(self, request, vimid="", servicetype="dns-delegate", requri=""):
- self._logger.debug("DnsaasDelegate--get::META> %s" % request.META)
- self._logger.debug("DnsaasDelegate--get::data> %s" % request.data)
- self._logger.debug("DnsaasDelegate--get::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("post", request, vimid, "dns", requri)
-
- def put(self, request, vimid="", servicetype="dns-delegate", requri=""):
- self._logger.debug("DnsaasDelegate--get::META> %s" % request.META)
- self._logger.debug("DnsaasDelegate--get::data> %s" % request.data)
- self._logger.debug("DnsaasDelegate--get::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("put", request, vimid, "dns", requri)
-
- def patch(self, request, vimid="", servicetype="dns-delegate", requri=""):
- self._logger.debug("DnsaasDelegate--get::META> %s" % request.META)
- self._logger.debug("DnsaasDelegate--get::data> %s" % request.data)
- self._logger.debug("DnsaasDelegate--get::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("patch", request, vimid, "dns", requri)
-
- def delete(self, request, vimid="", servicetype="dns-delegate", requri=""):
- self._logger.debug("DnsaasDelegate--get::META> %s" % request.META)
- self._logger.debug("DnsaasDelegate--get::data> %s" % request.data)
- self._logger.debug("DnsaasDelegate--get::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("delete", request, vimid, "dns", requri)
diff --git a/newton/newton/proxy/views/identityV3.py b/newton/newton/proxy/views/identityV3.py
index 9707726c..dd280314 100644
--- a/newton/newton/proxy/views/identityV3.py
+++ b/newton/newton/proxy/views/identityV3.py
@@ -13,225 +13,22 @@
# limitations under the License.
import logging
-import json
-import traceback
-from django.core.cache import cache
-
-from keystoneauth1 import access
-from keystoneauth1.access import service_catalog
-from keystoneauth1.exceptions import HttpError
-from rest_framework import status
-from rest_framework.response import Response
-from rest_framework.views import APIView
-
-from newton.pub.config import config
-from newton.pub.exceptions import VimDriverNewtonException
-from newton.requests.views.util import VimDriverUtils
-from newton.proxy.views.proxy_utils import ProxyUtils
+from django.conf import settings
+from newton_base.proxy import identityV3 as newton_identityV3
logger = logging.getLogger(__name__)
DEBUG=True
-v3_version_detail = {
- "version": {
- "status": "stable",
- "updated": "2014-04-17T00:00:00Z",
- "media-types": [
- {
- "base": "application/json",
- "type": "application/vnd.openstack.identity-v3+json"
- }
- ],
- "id": "v3",
- "links": [
- ]
- }
-}
-
-class Tokens(APIView):
- service = {'service_type': 'identity',
- 'interface': 'public'}
+class Tokens(newton_identityV3.Tokens):
def __init__(self):
- self.proxy_prefix = config.MULTICLOUD_PREFIX
+ self.proxy_prefix = settings.MULTICLOUD_PREFIX
self._logger = logger
- def get(self, request, vimid=""):
- self._logger.debug("identityV3--get::META> %s" % request.META)
-
- return Response(data=v3_version_detail, status=status.HTTP_200_OK)
-
- def post(self, request, vimid=""):
- self._logger.debug("identityV3--post::META> %s" % request.META)
- self._logger.debug("identityV3--post::data> %s" % request.data)
- self._logger.debug("identityV3--post::vimid> %s" % (vimid))
- sess = None
- resp = None
- resp_body = None
- try:
- tenant_name = request.data.get("tenant_name")
- tenant_id = request.data.get("tenant_id")
-
- #backward support for keystone v2.0 API
- if not tenant_name and request.data.get("auth"):
- tenant_name = request.data["auth"].get("tenantName")
- tenant_id = request.data["auth"].get("tenantId")
-
- #keystone v3 API
- if not tenant_name and request.data.get("auth") \
- and request.data["auth"].get("scope")\
- and request.data["auth"]["scope"].get("project"):
- if request.data["auth"]["scope"]["project"].get("name"):
- tenant_name = request.data["auth"]["scope"]["project"].get("name")
- else:
- tenant_id = request.data["auth"]["scope"]["project"].get("id")
-
-
-
- # prepare request resource to vim instance
- vim = VimDriverUtils.get_vim_info(vimid)
- sess = VimDriverUtils.get_session(
- vim, tenant_name=tenant_name, tenant_id=tenant_id)
-
- tmp_auth_state = VimDriverUtils.get_auth_state(sess)
- tmp_auth_info = json.loads(tmp_auth_state)
- tmp_auth_token = tmp_auth_info['auth_token']
- tmp_auth_data = tmp_auth_info['body']
-
- #store the auth_state, redis/memcached
- #set expiring in 1 hour
-
- #update the catalog
- tmp_auth_data['token']['catalog'], tmp_metadata_catalog = ProxyUtils.update_catalog(
- vimid, tmp_auth_data['token']['catalog'], self.proxy_prefix)
-
- VimDriverUtils.update_token_cache(
- tmp_auth_token, tmp_auth_state,
- json.dumps(tmp_metadata_catalog))
-
- tmp_auth_data['token']['catalog'] = ProxyUtils.update_catalog_dnsaas(
- vimid,tmp_auth_data['token']['catalog'], self.proxy_prefix, vim)
-
- resp = Response(headers={'X-Subject-Token': tmp_auth_token},
- data=tmp_auth_data, status=status.HTTP_201_CREATED)
- return resp
- except VimDriverNewtonException as e:
-
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- self._logger.error(traceback.format_exc())
-
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
-v2_version_detail = {
- "version": {
- "status": "stable",
- "updated": "2014-04-17T00:00:00Z",
- "media-types": [
- {
- "base": "application/json",
- "type": "application/vnd.openstack.identity-v2.0+json"
- }
- ],
- "id": "v2.0",
- "links": [
- ]
- }
-}
-
-class TokensV2(Tokens):
- '''
- Backward compatible API for /v2.0/tokens
- '''
+class TokensV2(newton_identityV3.TokensV2):
def __init__(self):
- self.proxy_prefix = config.MULTICLOUD_PREFIX
+ self.proxy_prefix = settings.MULTICLOUD_PREFIX
self._logger = logger
-
- def get(self, request, vimid=""):
- self._logger.debug("TokensV2--get::META> %s" % request.META)
-
- return Response(data=v2_version_detail, status=status.HTTP_200_OK)
-
- def post(self, request, vimid=""):
- self._logger.debug("TokensV2--post::META> %s" % request.META)
- self._logger.debug("TokensV2--post::data> %s" % request.data)
- self._logger.debug("TokensV2--post::vimid > %s" % (vimid))
-
- try:
- resp = super(TokensV2,self).post(request, vimid)
- self._logger.debug("TokensV2--resp:: headers:%s, data:%s" % (resp._headers, resp.data))
- if resp.status_code == status.HTTP_201_CREATED:
- v3_content = resp.data
- v3_token = v3_content['token']
-
- #convert catalog
- v2_catalog = []
- for v3_catalog in v3_token['catalog']:
- v2_catalog1 = {
- "type": v3_catalog["type"],
- "name": v3_catalog["name"],
- "endpoints": []
- }
-
- #convert endpoints
- v2_catalog1_endpoints = None
- for v3_endpoint in v3_catalog['endpoints']:
- v2_catalog1_endpoints = {
- "id": v3_endpoint['id'],
- "region":v3_endpoint['region'],
- "region_id": v3_endpoint['region_id'],
- 'interface':v3_endpoint['interface']
- }
- if v3_endpoint['interface'] == 'public':
- v2_catalog1_endpoints['publicURL'] = v3_endpoint['url']
- elif v3_endpoint['interface'] == 'admin':
- v2_catalog1_endpoints['adminURL'] = v3_endpoint['url']
- elif v3_endpoint['interface'] == 'internal':
- v2_catalog1_endpoints['internalURL'] = v3_endpoint['url']
-
- if v2_catalog1_endpoints:
- v2_catalog1['endpoints'].append(v2_catalog1_endpoints)
-
- v2_catalog.append(v2_catalog1)
-
-
- #conversion between v3 tokens response and v2.0 tokens response
- v3_token["project"]['enabled'] = 'true'
- v2_content = {
- "access": {
- "token": {
- "id" : resp.get('X-Subject-Token', None),
- "issued_at": v3_token["issued_at"],
- "expires" : v3_token["expires_at"],
- "tenant" : v3_token["project"],
- },
- "serviceCatalog": v2_catalog,
- "user": v3_token["user"],
- }
- }
-
- return Response(data=v2_content,
- status=status.HTTP_200_OK \
- if resp.status_code==status.HTTP_201_CREATED \
- else resp.status_code)
-
- else:
- return resp
- except VimDriverNewtonException as e:
-
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- self._logger.error(traceback.format_exc())
-
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/newton/newton/proxy/views/proxy_utils.py b/newton/newton/proxy/views/proxy_utils.py
deleted file mode 100644
index 9928c773..00000000
--- a/newton/newton/proxy/views/proxy_utils.py
+++ /dev/null
@@ -1,196 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-import json
-import traceback
-import re
-import uuid
-
-from rest_framework import status
-
-from newton.pub.exceptions import VimDriverNewtonException
-
-logger = logging.getLogger(__name__)
-
-DEBUG=True
-#MULTICLOUD_PREFIX = "http://%s:%s/api/multicloud-newton/v0" %(config.MSB_SERVICE_IP, config.MSB_SERVICE_PORT)
-
-class ProxyUtils(object):
-
- @staticmethod
- def update_prefix(metadata_catalog, content):
- '''match the longgest prefix and replace it'''
-
- if not content:
- return content
-
- for (servicetype, service_metadata) in metadata_catalog.items():
- real_prefix = service_metadata['prefix']
- proxy_prefix = service_metadata['proxy_prefix']
-
- if content:
- # filter the resp content and replace all endpoint prefix
- tmp_content = json.dumps(content)
- tmp_pattern = re.compile(real_prefix+r'([^:])')
- tmp_content = tmp_pattern.sub(proxy_prefix+r'\1', tmp_content)
- content = json.loads(tmp_content)
-
- return content
-
- @staticmethod
- def update_catalog(vimid, catalog, multicould_namespace):
- '''
- replace the orignal endpoints with multicloud's
- return the catalog with updated endpoints, and also another catalog with prefix and suffix of each endpoint
- :param vimid:
- :param catalog: service catalog to be updated
- :param multicould_namespace: multicloud namespace prefix to replace the real one in catalog endpoints url
- :return:updated catalog, and metadata_catalog looks like:
- {
- 'compute': {
- 'prefix': 'http://ip:port',
- 'proxy_prefix': 'http://another_ip: another_port',
- 'suffix': 'v2.1/53a4ab9015c84ee892e46d294f3b8b2d',
- },
- 'network': {
- 'prefix': 'http://ip:port',
- 'proxy_prefix': 'http://another_ip: another_port',
- 'suffix': '',
- },
- }
- '''
-
- metadata_catalog = {}
- if catalog:
- # filter and replace endpoints of catalogs
- for item in catalog:
- one_catalog = {}
- metadata_catalog[item['type']] = one_catalog
-
- endpoints = item['endpoints']
- item['endpoints']=[]
- for endpoint in endpoints:
- interface = endpoint.get('interface', None)
- if interface != 'public':
- continue
- # elif item["type"] == "identity":
- # endpoint["url"] = multicould_namespace + "/%s/identity/v3" % vimid
- else:
- # replace the endpoint with MultiCloud's proxy
- import re
- endpoint_url = endpoint["url"]
- real_prefix = None
- real_suffix = None
- m = re.search(r'^(http[s]?://[0-9.]+:[0-9]+)(/([0-9a-zA-Z/._-]+)$)?', endpoint_url)
- if not m:
- m = re.search(r'^(http[s]?://[0-9.]+)(/([0-9a-zA-Z/._-]+)$)?', endpoint_url)
- if m:
- real_prefix = m.group(1)
- real_suffix = m.group(3)
-
- if real_prefix:
- # populate metadata_catalog
- one_catalog['prefix'] = real_prefix
- one_catalog['suffix'] = real_suffix if real_suffix else ''
- one_catalog['proxy_prefix'] = multicould_namespace + "/%s" % vimid
-
- endpoint_url = multicould_namespace + "/%s" % vimid
-
- tmp_pattern = re.compile(item["type"])
- if not real_suffix or not re.match(tmp_pattern, real_suffix):
- one_catalog['proxy_prefix'] += "/" + item["type"]
- endpoint_url += '/' + item["type"]
-
- if real_suffix:
- endpoint_url += "/" + real_suffix
-
- if item["type"] == "identity":
- endpoint_url = multicould_namespace + "/%s/identity/v3" % vimid
-
- else:
- #something wrong
- pass
-
- endpoint["url"] = endpoint_url
- item['endpoints'].append( endpoint )
-
- return catalog, metadata_catalog
- else:
- return None
-
-
- @staticmethod
- def update_catalog_dnsaas(vimid, catalog, multicould_namespace, viminfo):
- '''
- append DNSaaS delegate endpoints to catalog
- :param vimid:
- :param catalog: service catalog to be updated
- :param multicould_namespace: multicloud namespace prefix to replace the real one in catalog endpoints url
- :param viminfo: vim information
- :return:updated catalog
- '''
-
- try:
- cloud_dns_delegate_info = None
- cloud_extra_info_str = viminfo.get('cloud_extra_info')
- if cloud_extra_info_str:
- cloud_extra_info = json.loads(cloud_extra_info_str)
- cloud_dns_delegate_info = cloud_extra_info.get("dns-delegate")
-
- if not cloud_dns_delegate_info\
- or not cloud_dns_delegate_info.get("cloud-owner") \
- or not cloud_dns_delegate_info.get("cloud-region-id"):
- #DNSaaS deleget was not configured yet
- return catalog
-
- dns_catalog = {
- "name":"dns-delegate",
- "type":"dns",
- "id": str(uuid.uuid1()),
- "endpoints": [{
- "interface": "public",
- "region": cloud_dns_delegate_info.get("cloud-region-id"),
- "region_id": cloud_dns_delegate_info.get("cloud-region-id"),
- "id": str(uuid.uuid1()),
- "url": multicould_namespace + "/%s/dns-delegate" % vimid,
- }]
- }
- catalog.append(dns_catalog)
-
- return catalog
-
- except Exception as e:
- logger.error(traceback.format_exc())
- return catalog
-
-
-# @staticmethod
-# def update_dnsaas_project_id(content, new_project_id):
-# '''
-# update project id in DNSaaS delegate content
-# '''
-# try:
-# if content:
-# # filter the resp content and replace all endpoint prefix
-# tmp_content = json.dumps(content)
-# tmp_pattern = re.compile(r'(^.*)"project_id"\s*:\s*"' + r'[\w-]+'+r'"(.*$)')
-# part1 = tmp_pattern.sub(r'\1', tmp_content)
-# part2 = tmp_pattern.sub(r'"project_id":"'+new_project_id +r'"\2', tmp_content)
-# #logger.debug("jsonstr:%s,part1:%s,part2:%s"%(tmp_content,part1,part2))
-# content = json.loads(part1+part2)
-# return content
-# except Exception as e:
-# logger.error(traceback.format_exc())
-# return content
diff --git a/newton/newton/proxy/views/services.py b/newton/newton/proxy/views/services.py
index 38354bbb..4bfecdbc 100644
--- a/newton/newton/proxy/views/services.py
+++ b/newton/newton/proxy/views/services.py
@@ -13,228 +13,23 @@
# limitations under the License.
import logging
-import json
-import traceback
-from keystoneauth1.exceptions import HttpError
-import re
-from rest_framework.permissions import BasePermission
-from rest_framework.response import Response
from rest_framework import status
-from rest_framework.views import APIView
-from newton.proxy.views.proxy_utils import ProxyUtils
-from newton.pub.exceptions import VimDriverNewtonException
-from newton.pub.msapi import extsys
-from newton.requests.views.util import VimDriverUtils
+from django.conf import settings
+from newton_base.proxy import services as newton_services
logger = logging.getLogger(__name__)
DEBUG=True
-
-class HasValidToken(BasePermission):
-
- def has_permission(self, request, view):
- logger.debug("HasValidToken--has_permission::META> %s" % request.META)
- token = request.META.get('HTTP_X_AUTH_TOKEN', None)
- if token:
- state, metadata = VimDriverUtils.get_token_cache(token)
- if state:
- return True
- return False
-
-
-class Services(APIView):
- permission_classes = (HasValidToken,)
+class Services(newton_services.Services):
def __init__(self):
self._logger = logger
- def _get_token(self, request):
- return request.META.get('HTTP_X_AUTH_TOKEN', None)
-
- def _get_resource_and_metadata(self, servicetype, metadata_catalog, requri):
- real_prefix = None
- proxy_prefix = None
- suffix = None
- if servicetype and metadata_catalog:
- metadata_catalog = json.loads(metadata_catalog)
- service_metadata = metadata_catalog.get(servicetype, None)
- if service_metadata:
- real_prefix = service_metadata['prefix']
- proxy_prefix = service_metadata['proxy_prefix']
- suffix = service_metadata['suffix']
-
- if not real_prefix or not proxy_prefix:
- raise VimDriverNewtonException(message="internal state error",
- content="invalid cached metadata",
- status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
- if requri == suffix:
- requri = None
-
- if suffix and requri:
- # remove the suffix from the requri to avoid duplicated suffix in real request uri later
- tmp_pattern = re.compile(suffix)
- requri = tmp_pattern.sub('', requri)
-
- req_resource = ''
- if requri and requri != '':
- req_resource = "/" if re.match(r'//', requri) else '' + requri
- return req_resource, metadata_catalog
-
- def _do_action(self, action, request, vim_id, servicetype, requri):
- tmp_auth_token = self._get_token(request)
- try:
- #special handling of compute/v2 request from APPC, temp solution for A release
- if servicetype == 'compute':
- tmp_pattern = re.compile(r'^v2/(.+)')
- requri = tmp_pattern.sub(r'v2.1/' + r'\1', requri)
-
-
- vim = VimDriverUtils.get_vim_info(vim_id)
- # fetch the auth_state out of cache
- auth_state, metadata_catalog = VimDriverUtils.get_token_cache(tmp_auth_token)
- req_resource, metadata_catalog = self._get_resource_and_metadata(servicetype, metadata_catalog, requri)
- sess = VimDriverUtils.get_session(vim, auth_state=auth_state)
-
- cloud_owner, regionid = extsys.decode_vim_id(vim_id)
- interface = 'public'
- service = {
- 'service_type': servicetype,
- 'interface': interface,
- 'region_id': regionid
- }
-
- querystr = VimDriverUtils.get_query_part(request)
- if querystr:
- req_resource += "?" + querystr
-
- self._logger.debug("service " + action + " request uri %s" % (req_resource))
- if(action == "get"):
- resp = sess.get(req_resource, endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- elif(action == "post"):
- resp = sess.post(req_resource, data=json.JSONEncoder().encode(request.data),
- endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- elif(action == "put"):
- resp = sess.put(req_resource, data=json.JSONEncoder().encode(request.data),
- endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- elif(action == "patch"):
- resp = sess.patch(req_resource, data=json.JSONEncoder().encode(request.data),
- endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- elif (action == "delete"):
- resp = sess.delete(req_resource, endpoint_filter=service,
- headers={"Content-Type": "application/json",
- "Accept": "application/json"})
- content = resp.json() if resp.content else None
- self._logger.debug("service " + action + " response: %s, %s" % (resp.status_code, content))
-
- if (action == "delete"):
- return Response(headers={'X-Subject-Token': tmp_auth_token}, status=resp.status_code)
- else:
- content = ProxyUtils.update_prefix(metadata_catalog, content)
- if (action == "get"):
- if requri == '/v3/auth/catalog' and content and content.get("catalog"):
- content['catalog'] = ProxyUtils.update_catalog_dnsaas(
- vim_id, content['catalog'], self.proxy_prefix, vim)
- return Response(headers={'X-Subject-Token': tmp_auth_token}, data=content, status=resp.status_code)
-
- except VimDriverNewtonException as e:
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
- def head(self, request, vimid="", servicetype="", requri=""):
- #self._logger.debug("Services--head::META> %s" % request.META)
- self._logger.debug("Services--head::data> %s" % request.data)
- self._logger.debug("Services--head::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
-
- token = self._get_token(request)
- try:
- vim = VimDriverUtils.get_vim_info(vimid)
- auth_state, metadata_catalog = VimDriverUtils.get_token_cache(token)
- sess = VimDriverUtils.get_session(vim, auth_state=auth_state)
-
- req_resource = ''
- if requri and requri != '':
- req_resource = "/" if re.match(r'//', requri) else ''+ requri
-
- cloud_owner, regionid = extsys.decode_vim_id(vimid)
- interface = 'public'
- service = {'service_type': servicetype,
- 'interface': interface,
- 'region_id': regionid}
- self._logger.debug("service head request uri %s" % (req_resource))
-
- resp = sess.head(req_resource, endpoint_filter=service)
- content = resp.json() if resp.content else None
- self._logger.debug("service head response: %s, %s" % (resp.status_code, content))
-
- return Response(headers={'X-Subject-Token': token}, data=content, status=resp.status_code)
- except VimDriverNewtonException as e:
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
- def get(self, request, vimid="", servicetype="", requri=""):
- #self._logger.debug("Services--get::META> %s" % request.META)
- self._logger.debug("Services--get::data> %s" % request.data)
- self._logger.debug("Services--get::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("get", request, vimid, servicetype, requri)
-
- def post(self, request, vimid="", servicetype="", requri=""):
- #self._logger.debug("Services--post::META> %s" % request.META)
- self._logger.debug("Services--post::data> %s" % request.data)
- self._logger.debug("Services--post::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
-
- return self._do_action("post", request, vimid, servicetype, requri)
-
- def put(self, request, vimid="", servicetype="", requri=""):
- #self._logger.debug("Services--put::META> %s" % request.META)
- self._logger.debug("Services--put::data> %s" % request.data)
- self._logger.debug("Services--put::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("put", request, vimid, servicetype, requri)
-
- def patch(self, request, vimid="", servicetype="", requri=""):
- #self._logger.debug("Services--patch::META> %s" % request.META)
- self._logger.debug("Services--patch::data> %s" % request.data)
- self._logger.debug("Services--patch::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("patch", request, vimid, servicetype, requri)
-
- def delete(self, request, vimid="", servicetype="", requri=""):
- #self._logger.debug("Services--delete::META> %s" % request.META)
- self._logger.debug("Services--delete::data> %s" % request.data)
- self._logger.debug("Services--delete::vimid, servicetype, requri> %s,%s,%s"
- % (vimid, servicetype, requri))
- return self._do_action("delete", request, vimid, servicetype, requri)
-
-
-class GetTenants(Services):
+class GetTenants(newton_services.GetTenants):
'''
Backward compatible API for /v2.0/tenants
'''
@@ -242,33 +37,10 @@ class GetTenants(Services):
def __init__(self):
self._logger = logger
- def get(self, request, vimid="", servicetype="identity", requri='projects'):
- #self._logger.debug("GetTenants--get::META> %s" % request.META)
+ def get(self, request, vimid="", servicetype="identity", requri='v3/projects'):
+ self._logger.debug("GetTenants--get::META> %s" % request.META)
self._logger.debug("GetTenants--get::data> %s" % request.data)
self._logger.debug("GetTenants--get::vimid, servicetype, requri> %s,%s,%s"
% (vimid, servicetype, requri))
- tmp_auth_token = request.META.get('HTTP_X_AUTH_TOKEN', None)
-
- resp = super(GetTenants,self).get(request, vimid, servicetype, requri)
- if resp.status_code == status.HTTP_200_OK:
- content = resp.data
- return Response(headers={'X-Subject-Token': tmp_auth_token}, data={'tenants': content['projects'],'tenants_links':[]},
- status=resp.status_code)
- else:
- return resp
-
- def head(self, request, vimid="", servicetype="", requri=""):
- return Response(data={'error': 'unsupported operation'}, status=status.HTTP_400_BAD_REQUEST)
-
- def post(self, request, vimid="", servicetype="", requri=""):
- return Response(data={'error': 'unsupported operation'}, status=status.HTTP_400_BAD_REQUEST)
-
- def put(self, request, vimid="", servicetype="", requri=""):
- return Response(data={'error': 'unsupported operation'}, status=status.HTTP_400_BAD_REQUEST)
-
- def patch(self, request, vimid="", servicetype="", requri=""):
- return Response(data={'error': 'unsupported operation'}, status=status.HTTP_400_BAD_REQUEST)
-
- def delete(self, request, vimid="", servicetype="", requri=""):
- return Response(data={'error': 'unsupported operation'}, status=status.HTTP_400_BAD_REQUEST)
+ return super(GetTenants,self).get(request, vimid, servicetype, requri)
diff --git a/newton/newton/pub/__init__.py b/newton/newton/pub/__init__.py
deleted file mode 100644
index afa702d3..00000000
--- a/newton/newton/pub/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
diff --git a/newton/newton/pub/config/__init__.py b/newton/newton/pub/config/__init__.py
deleted file mode 100644
index ae1ce9db..00000000
--- a/newton/newton/pub/config/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
diff --git a/newton/newton/pub/config/config.py b/newton/newton/pub/config/config.py
deleted file mode 100644
index ec9b92c8..00000000
--- a/newton/newton/pub/config/config.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-
-# [MSB]
-MSB_SERVICE_ADDR = '127.0.0.1'
-MSB_SERVICE_PORT = '80'
-
-
-#[Multicloud]
-MULTICLOUD_PREFIX = "http://%s:%s/api/multicloud-newton/v0" %(MSB_SERVICE_ADDR, MSB_SERVICE_PORT)
-
-# [A&AI]
-AAI_ADDR = "aai.api.simpledemo.openecomp.org"
-AAI_PORT = "8443"
-AAI_SERVICE_URL = 'https://%s:%s/aai' % (AAI_ADDR, AAI_PORT)
-AAI_SCHEMA_VERSION = "v11"
-AAI_USERNAME = 'AAI'
-AAI_PASSWORD = 'AAI'
-
-AAI_BASE_URL = "%s/%s" % (AAI_SERVICE_URL, AAI_SCHEMA_VERSION)
-
-MULTICLOUD_APP_ID = 'MultiCloud-Newton'
-
-# [IMAGE LOCAL PATH]
-ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
diff --git a/newton/newton/pub/database/__init__.py b/newton/newton/pub/database/__init__.py
deleted file mode 100644
index afa702d3..00000000
--- a/newton/newton/pub/database/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
diff --git a/newton/newton/pub/database/models.py b/newton/newton/pub/database/models.py
deleted file mode 100644
index 22785b65..00000000
--- a/newton/newton/pub/database/models.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from django.db import models
-
-class VimInstModel(models.Model):
- class Meta:
- db_table = 'vim_inst_type_mapping'
-
- vimid = models.CharField(db_column='VIMID', primary_key=True, max_length=200)
- vimtype = models.CharField(db_column="VIMTYPE", max_length=200)
- viminst_url = models.CharField(db_column="VIMINSTURL", max_length=200)
diff --git a/newton/newton/pub/exceptions.py b/newton/newton/pub/exceptions.py
deleted file mode 100644
index 80cf7ed1..00000000
--- a/newton/newton/pub/exceptions.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-class VimDriverNewtonException(Exception):
- def __init__(self, message, status_code="", content=""):
- super(VimDriverNewtonException, self).__init__(message)
- self.status_code = status_code
- self.content = content
diff --git a/newton/newton/pub/msapi/__init__.py b/newton/newton/pub/msapi/__init__.py
deleted file mode 100644
index afa702d3..00000000
--- a/newton/newton/pub/msapi/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
diff --git a/newton/newton/pub/msapi/extsys.py b/newton/newton/pub/msapi/extsys.py
deleted file mode 100644
index 2553958c..00000000
--- a/newton/newton/pub/msapi/extsys.py
+++ /dev/null
@@ -1,101 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-import logging
-import re
-
-from newton.pub.exceptions import VimDriverNewtonException
-from newton.pub.utils import restcall
-
-
-logger = logging.getLogger(__name__)
-
-def get_vim_by_id(vim_id):
-
- cloud_owner,cloud_region_id = decode_vim_id(vim_id)
-
- if cloud_owner and cloud_region_id:
- retcode, content, status_code = \
- restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s?depth=1"
- % (cloud_owner,cloud_region_id),"GET")
- if retcode != 0:
- logger.error("Status code is %s, detail is %s.", status_code, content)
- raise VimDriverNewtonException(
- "Failed to query VIM with id (%s:%s,%s)." % (vim_id,cloud_owner,cloud_region_id),
- status_code, content)
- tmp_viminfo = json.JSONDecoder().decode(content)
-
- #assume esr-system-info-id is composed by {cloud-owner} _ {cloud-region-id}
-# retcode2,content2,status_code2 = \
-# restcall.req_to_aai(("/cloud-infrastructure/cloud-regions/cloud-region/%(owner)s/%(region)s"
-# "/esr-system-info-list/esr-system-info/%(owner)s_%(region)s" % {
-# "owner": cloud_owner, "region": cloud_region_id}), "GET")
-# if retcode2 != 0:
-# logger.error("Status code is %s, detail is %s.", status_code, content)
-# raise VimDriverNewtonException(
-# "Failed to query ESR system with id (%s:%s,%s)." % (vim_id,cloud_owner,cloud_region_id),
-# status_code2, content2)
-# tmp_authinfo = json.JSONDecoder().decode(content2)
- tmp_authinfo = tmp_viminfo['esr-system-info-list']['esr-system-info'][0] if tmp_viminfo else None
-
- #convert vim information
- if tmp_viminfo and tmp_authinfo:
- viminfo = {}
- viminfo['vimId'] = vim_id
- viminfo['resource-version'] = tmp_viminfo.get('resource-version')
- viminfo['cloud_owner'] = cloud_owner
- viminfo['cloud_region_id'] = cloud_region_id
- viminfo['type'] = tmp_viminfo.get('cloud-type')
- viminfo['name'] = tmp_viminfo.get('complex-name')
- viminfo['version'] = tmp_viminfo.get('cloud-region-version')
- viminfo['cloud_extra_info'] = tmp_viminfo.get('cloud-extra-info')
- viminfo['cloud_epa_caps'] = tmp_viminfo.get('cloud-epa-caps')
-
- viminfo['userName'] = tmp_authinfo['user-name']
- viminfo['password'] = tmp_authinfo['password']
- viminfo['domain'] = tmp_authinfo.get('cloud-domain')
- viminfo['url'] = tmp_authinfo.get('service-url')
- viminfo['tenant'] = tmp_authinfo.get('default-tenant')
- viminfo['cacert'] = tmp_authinfo.get('ssl-cacert')
- viminfo['insecure'] = tmp_authinfo.get('ssl-insecure')
-
- return viminfo
- return None
-
-def delete_vim_by_id(vim_id):
- cloud_owner, cloud_region_id = decode_vim_id(vim_id)
- if cloud_owner and cloud_region_id:
- #get the vim info
- viminfo = get_vim_by_id(vim_id)
- if not viminfo or not viminfo['resource-version']:
- return 0
-
- retcode, content, status_code = \
- restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s?resource-version=%s"
- % ( cloud_owner, cloud_region_id, viminfo['resource-version']), "DELETE")
- if retcode != 0:
- logger.error("Status code is %s, detail is %s.", status_code, content)
- raise VimDriverNewtonException(
- "Failed to delete VIM in AAI with id (%s:%s,%s)." % (vim_id,cloud_owner,cloud_region_id),
- status_code, content)
- return 0
- # return non zero if failed to decode cloud owner and region id
- return 1
-
-def decode_vim_id(vim_id):
- m = re.search(r'^([0-9a-zA-Z-]+)_([0-9a-zA-Z_-]+)$', vim_id)
- cloud_owner, cloud_region_id = m.group(1), m.group(2)
- return cloud_owner, cloud_region_id
-
diff --git a/newton/newton/pub/tests/__init__.py b/newton/newton/pub/tests/__init__.py
deleted file mode 100644
index afa702d3..00000000
--- a/newton/newton/pub/tests/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
diff --git a/newton/newton/pub/tests/test_extsys.py b/newton/newton/pub/tests/test_extsys.py
deleted file mode 100644
index 9e67dcc0..00000000
--- a/newton/newton/pub/tests/test_extsys.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# Copyright (c) 2017 Intel Corporation.
-#
-# 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-
-import mock
-from rest_framework import status
-import six
-import unittest
-
-from newton.pub.exceptions import VimDriverNewtonException
-from newton.pub.msapi import extsys
-from newton.pub.utils import restcall
-
-
-MOCK_ESR_SYSTEM_INFO = {
- "user-name": "test",
- "password": "secret",
- "cloud-domain": "Default",
- "service-url": "http://localhost",
- "default-tenant": "demo",
- "ssl-cacert": None,
- "ssl-insecure": None,
- "resource-version":"1978882"
-}
-
-MOCK_VIM_INFO = {
- "resource-version":"1978883",
- "cloud-type": "openstack",
- "complex-name": "complex",
- "cloud-region-version": "Regionv1",
- "cloud-extra-info": "type",
- "cloud-epa-caps": "epa",
- "esr-system-info-list" :
- {
- "esr-system-info": [
- MOCK_ESR_SYSTEM_INFO
- ]
- }
-}
-
-
-
-def returnList(items):
- def func():
- for item in items:
- yield item
- yield mock.DEFAULT
-
- generator = func()
-
- def effect(*args, **kwargs):
- return six.next(generator)
-
- return effect
-
-
-class TestEpaCaps(unittest.TestCase):
- cloud_onwer = "windriver-hudson-cd"
- cloud_region_id = "RegionOne"
- vim_id = cloud_onwer + "_" + cloud_region_id
-
- def setUp(self):
- self.req_to_aai_backup = restcall.req_to_aai
-
- def tearDown(self):
- restcall.req_to_aai = self.req_to_aai_backup
-
- def test_get_vim_by_id(self):
- values = [
- (1, "test_content",
- status.HTTP_500_INTERNAL_SERVER_ERROR), # Failure first call
- (0, json.dumps(MOCK_VIM_INFO), None),
- (1, "test_content",
- status.HTTP_500_INTERNAL_SERVER_ERROR), # Failure second call
- (0, json.dumps(MOCK_VIM_INFO), None),
- (0, json.dumps(MOCK_ESR_SYSTEM_INFO), None) # Success calls
- ]
-
- restcall.req_to_aai = mock.Mock(side_effect=returnList(values))
- self.assertRaises(VimDriverNewtonException, extsys.get_vim_by_id, self.vim_id)
- restcall.req_to_aai.assert_called_once()
-
- #self.assertRaises(VimDriverNewtonException, extsys.get_vim_by_id, self.vim_id)
-
- viminfo = extsys.get_vim_by_id(self.vim_id)
- self.assertIsNotNone(viminfo)
- self.assertEquals(self.vim_id, viminfo['vimId'])
- self.assertEquals(self.cloud_onwer, viminfo['cloud_owner'])
- self.assertEquals(self.cloud_region_id, viminfo['cloud_region_id'])
- self.assertEquals(MOCK_VIM_INFO['cloud-type'], viminfo['type'])
- self.assertEquals(MOCK_VIM_INFO['complex-name'], viminfo['name'])
- self.assertEquals(MOCK_VIM_INFO['cloud-region-version'], viminfo['version'])
- self.assertEquals(MOCK_VIM_INFO['cloud-extra-info'], viminfo['cloud_extra_info'])
- self.assertEquals(MOCK_VIM_INFO['cloud-epa-caps'], viminfo['cloud_epa_caps'])
-
- self.assertEquals(MOCK_ESR_SYSTEM_INFO['user-name'], viminfo['userName'])
- self.assertEquals(MOCK_ESR_SYSTEM_INFO['password'], viminfo['password'])
- self.assertEquals(MOCK_ESR_SYSTEM_INFO['cloud-domain'], viminfo['domain'])
- self.assertEquals(MOCK_ESR_SYSTEM_INFO['service-url'], viminfo['url'])
- self.assertEquals(MOCK_ESR_SYSTEM_INFO['default-tenant'], viminfo['tenant'])
- self.assertEquals(MOCK_ESR_SYSTEM_INFO['ssl-cacert'], viminfo['cacert'])
- self.assertEquals(MOCK_ESR_SYSTEM_INFO['ssl-insecure'], viminfo['insecure'])
-
- def test_delete_vim_by_id(self):
- values = [
- (0, json.dumps(MOCK_VIM_INFO), None),
- (1, "test_content", 500),
- (0, json.dumps(MOCK_VIM_INFO), None),
- (0, None, None)
- ]
-
- restcall.req_to_aai = mock.Mock(side_effect=returnList(values))
- self.assertRaises(VimDriverNewtonException, extsys.delete_vim_by_id, self.vim_id)
- self.assertEquals(0, extsys.delete_vim_by_id(self.vim_id))
-
- def test_decode_vim_id_successfuly(self):
- owner, region_id = extsys.decode_vim_id(self.vim_id)
- self.assertEquals(self.cloud_onwer, owner)
- self.assertEquals(self.cloud_region_id, region_id)
diff --git a/newton/newton/pub/tests/test_restcall.py b/newton/newton/pub/tests/test_restcall.py
deleted file mode 100644
index 063beb35..00000000
--- a/newton/newton/pub/tests/test_restcall.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright (c) 2017 Intel Corporation.
-#
-# 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from httplib2 import Http
-import mock
-from rest_framework import status
-import unittest
-
-from newton.pub.utils import restcall
-
-rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2
-
-class TestRestCall(unittest.TestCase):
- base_url = "http://localhost"
- resource = "compute"
-
- @mock.patch.object(Http, 'request')
- def test_unknown_failure_call_req(self, mock_http):
- mock_http.raiseError.side_effect = mock.Mock(
- side_effect=Exception('Test'))
- args = [
- self.base_url, None, None, rest_no_auth,
- self.resource, "get", {"extra": "test"}
- ]
-
- ret = restcall._call_req(*args)
- self.assertEquals(3, ret[0])
- self.assertEquals(status.HTTP_500_INTERNAL_SERVER_ERROR, ret[2])
-
-
- @mock.patch.object(Http, 'request')
- def test_invalid_output_call_req(self, mock_http):
- args = [
- self.base_url, None, None, rest_no_auth,
- self.resource, "get", {"extra": "test"}
- ]
-
- mock_http.return_value = ({'status': None},
- str.encode("test", 'utf-8'))
-
- ret = restcall._call_req(*args)
- self.assertEquals(1, ret[0])
- self.assertEquals("test", ret[1])
- self.assertIsNone(ret[2])
-
- @mock.patch.object(Http, 'request')
- def test_req_by_msb(self, mock_http):
- resp_body = "test_body"
- resp_status='200' #status.HTTP_200_OK
- mock_http.return_value = (
- {'status': resp_status},
- str.encode(resp_body, 'utf-8'))
-
-
- ret = restcall.req_by_msb(self.resource, "delete")
- self.assertEquals(0, ret[0])
- self.assertEquals(resp_body, ret[1])
- self.assertEquals(resp_status, ret[2])
-
- @mock.patch.object(Http, 'request')
- def test_req_to_vim(self, mock_http):
- resp_body = "test_body"
- resp_status='200' #status.HTTP_200_OK
- mock_http.return_value = (
- {'status': resp_status},
- str.encode(resp_body, 'utf-8'))
-
- ret = restcall.req_to_vim(self.base_url, self.resource, "get")
- self.assertEquals(0, ret[0])
- self.assertEquals(resp_body, ret[1])
- self.assertEquals(resp_status, ret[2])
-
- @mock.patch.object(Http, 'request')
- def test_req_to_aai(self, mock_http):
- resp_body = "test_body"
- resp_status='200' #status.HTTP_200_OK
- mock_http.return_value = (
- {'status': resp_status},
- str.encode(resp_body, 'utf-8'))
-
- ret = restcall.req_to_aai(self.resource, "post")
- self.assertEquals(0, ret[0])
- self.assertEquals(resp_body, ret[1])
- self.assertEquals(resp_status, ret[2])
-
- def test_combine_url(self):
- self.assertEquals(self.base_url,
- restcall._combine_url(self.base_url, ""))
- self.assertEquals(self.base_url + "/" + self.resource,
- restcall._combine_url(self.base_url + "/",
- "/" + self.resource))
- self.assertEquals(self.base_url + "/" + self.resource,
- restcall._combine_url(self.base_url + "/",
- self.resource))
- self.assertEquals(self.base_url + "/" + self.resource,
- restcall._combine_url(self.base_url,
- "/" + self.resource))
- self.assertEquals(self.base_url + "/" + self.resource,
- restcall._combine_url(self.base_url,
- self.resource))
diff --git a/newton/newton/pub/utils/__init__.py b/newton/newton/pub/utils/__init__.py
deleted file mode 100644
index afa702d3..00000000
--- a/newton/newton/pub/utils/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
diff --git a/newton/newton/pub/utils/enumutil.py b/newton/newton/pub/utils/enumutil.py
deleted file mode 100644
index df2bc308..00000000
--- a/newton/newton/pub/utils/enumutil.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-def enum(**enums):
- return type('Enum', (), enums)
diff --git a/newton/newton/pub/utils/fileutil.py b/newton/newton/pub/utils/fileutil.py
deleted file mode 100644
index 2ceffdd5..00000000
--- a/newton/newton/pub/utils/fileutil.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import shutil
-import logging
-import traceback
-from six.moves import urllib
-
-logger = logging.getLogger(__name__)
-
-
-def make_dirs(path):
- if not os.path.exists(path):
- os.makedirs(path, 0777)
-
-
-def delete_dirs(path):
- try:
- if os.path.exists(path):
- shutil.rmtree(path)
- except Exception as e:
- logger.error(traceback.format_exc())
- logger.error("Failed to delete %s:%s", path, e.message)
-
-
-def download_file_from_http(url, local_dir, file_name):
- local_file_name = os.path.join(local_dir, file_name)
- is_download_ok = False
- try:
- make_dirs(local_dir)
- req = urllib.request.urlopen(url)
- save_file = open(local_file_name, 'wb')
- save_file.write(req.read())
- save_file.close()
- req.close()
- is_download_ok = True
- except:
- logger.error(traceback.format_exc())
- logger.error("Failed to download %s to %s.", url, local_file_name)
- return is_download_ok, local_file_name
diff --git a/newton/newton/pub/utils/idutil.py b/newton/newton/pub/utils/idutil.py
deleted file mode 100644
index ef53ce57..00000000
--- a/newton/newton/pub/utils/idutil.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from redisco import containers as cont
-
-
-def get_auto_id(id_type, id_group="auto_id_hash"):
- auto_id_hash = cont.Hash(id_group)
- auto_id_hash.hincrby(id_type, 1)
- return auto_id_hash.hget(id_type)
diff --git a/newton/newton/pub/utils/restcall.py b/newton/newton/pub/utils/restcall.py
deleted file mode 100644
index a34a44e4..00000000
--- a/newton/newton/pub/utils/restcall.py
+++ /dev/null
@@ -1,149 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import six
-import base64
-
-import codecs
-import json
-import traceback
-import sys
-
-import logging
-from six.moves import urllib
-import httplib2
-import uuid
-
-from rest_framework import status
-from newton.pub.config import config
-
-rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2
-HTTP_200_OK, HTTP_201_CREATED = '200', '201'
-HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED = '204', '202'
-status_ok_list = [HTTP_200_OK, HTTP_201_CREATED,
- HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED]
-HTTP_404_NOTFOUND, HTTP_403_FORBIDDEN = '404', '403'
-HTTP_401_UNAUTHORIZED, HTTP_400_BADREQUEST = '401', '400'
-
-MAX_RETRY_TIME = 3
-
-logger = logging.getLogger(__name__)
-
-
-def _call_req(base_url, user, passwd, auth_type,
- resource, method, extra_headers='', content=''):
- callid = str(uuid.uuid1())
- ret = None
- resp_status = None
- try:
- full_url = _combine_url(base_url, resource)
- headers = {
- 'content-type': 'application/json',
- 'accept': 'application/json'
- }
-
- if extra_headers:
- headers.update(extra_headers)
-# if user:
-# headers['Authorization'] = \
-# 'Basic ' + str(codecs.encode('%s:%s' % (user, passwd), "ascii"))
-
- if user:
- tmpauthsource = '%s:%s' % (user, passwd)
- if six.PY3:
- tmpauthsource = tmpauthsource.encode('utf-8')
- headers['Authorization'] = 'Basic ' + \
- base64.b64encode(tmpauthsource).decode('utf-8')
-
- ca_certs = None
- for retry_times in range(MAX_RETRY_TIME):
- http = httplib2.Http(
- ca_certs=ca_certs,
- disable_ssl_certificate_validation=(auth_type == rest_no_auth))
- http.follow_all_redirects = True
- try:
- resp, resp_content = http.request(full_url,
- method=method.upper(),
- body=content,
- headers=headers)
- resp_status, resp_body = \
- resp['status'], codecs.decode(
- resp_content, 'UTF-8')
- if resp_status in status_ok_list:
- ret = [0, resp_body, resp_status]
- else:
- ret = [1, resp_body, resp_status]
- break
- except Exception as ex:
- if 'httplib.ResponseNotReady' in str(sys.exc_info()):
- logger.debug("retry_times=%d", retry_times)
- logger.error(traceback.format_exc())
- ret = [1, "Unable to connect to %s" % full_url, resp_status]
- continue
- raise ex
- except urllib.error.URLError as err:
- ret = [2, str(err), resp_status]
- except Exception:
- logger.error(traceback.format_exc())
- logger.error("[%s]ret=%s" % (callid, str(sys.exc_info())))
- if not resp_status:
- resp_status = status.HTTP_500_INTERNAL_SERVER_ERROR
- ret = [3, str(sys.exc_info()), resp_status]
- except:
- logger.error(traceback.format_exc())
- ret = [4, str(sys.exc_info()), resp_status]
- return ret
-
-
-def req_by_msb(resource, method, content=''):
- base_url = "http://%s:%s/" % (config.MSB_SERVICE_ADDR, config.MSB_SERVICE_PORT)
- return _call_req(base_url, "", "", rest_no_auth,
- resource, method, "", content)
-
-
-def req_to_vim(base_url, resource, method, extra_headers='', content=''):
- return _call_req(base_url, "", "", rest_no_auth,
- resource, method, extra_headers, content)
-
-
-def req_to_aai(resource, method, content='', appid=config.MULTICLOUD_APP_ID):
- tmp_trasaction_id = '9003' #str(uuid.uuid1())
- headers = {
- 'X-FromAppId': appid,
- 'X-TransactionId': tmp_trasaction_id,
- 'content-type': 'application/json',
- 'accept': 'application/json'
- }
-
- logger.debug("req_to_aai--%s::> %s, %s" %
- (tmp_trasaction_id, method, _combine_url(config.AAI_BASE_URL,resource)))
- return _call_req(config.AAI_BASE_URL, config.AAI_USERNAME, config.AAI_PASSWORD, rest_no_auth,
- resource, method, content=json.dumps(content), extra_headers=headers)
-
-
-def _combine_url(base_url, resource):
- full_url = None
-
- if not resource:
- return base_url
-
- if base_url.endswith('/') and resource.startswith('/'):
- full_url = base_url[:-1] + resource
- elif base_url.endswith('/') and not resource.startswith('/'):
- full_url = base_url + resource
- elif not base_url.endswith('/') and resource.startswith('/'):
- full_url = base_url + resource
- else:
- full_url = base_url + '/' + resource
- return full_url
diff --git a/newton/newton/pub/utils/share_lock.py b/newton/newton/pub/utils/share_lock.py
deleted file mode 100644
index b63f691c..00000000
--- a/newton/newton/pub/utils/share_lock.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import time
-
-import redis
-
-from newton.pub.config.config import REDIS_HOST, REDIS_PORT, REDIS_PASSWD
-
-
-class SharedLock:
- def __init__(self, lock_key, host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWD, db=9, lock_timeout=5 * 60):
- self.lock_key = lock_key
- self.lock_timeout = lock_timeout
- self.redis = redis.Redis(host=host, port=port, db=db, password=password)
- self.acquire_time = -1
-
- def acquire(self):
- begin = now = int(time.time())
- while (now - begin) < self.lock_timeout:
-
- result = self.redis.setnx(self.lock_key, now + self.lock_timeout + 1)
- if result == 1 or result is True:
- self.acquire_time = now
- return True
-
- current_lock_timestamp = self.redis.get(self.lock_key)
- if not current_lock_timestamp:
- time.sleep(1)
- continue
-
- current_lock_timestamp = int(current_lock_timestamp)
-
- if now > current_lock_timestamp:
- next_lock_timestamp = self.redis.getset(self.lock_key, now + self.lock_timeout + 1)
- if not next_lock_timestamp:
- time.sleep(1)
- continue
- next_lock_timestamp = int(next_lock_timestamp)
-
- if next_lock_timestamp == current_lock_timestamp:
- self.acquire_time = now
- return True
- else:
- time.sleep(1)
- continue
- return False
-
- def release(self):
- now = int(time.time())
- if now > self.acquire_time + self.lock_timeout:
- # key expired, do nothing and let other clients handle it
- return
- self.acquire_time = None
- self.redis.delete(self.lock_key)
-
-
-def do_biz_with_share_lock(lock_name, callback):
- lock = SharedLock(lock_name)
- try:
- if not lock.acquire():
- raise Exception(lock_name + " timeout")
- callback()
- except Exception as e:
- raise e
- finally:
- lock.release()
diff --git a/newton/newton/pub/utils/syscomm.py b/newton/newton/pub/utils/syscomm.py
deleted file mode 100644
index 9b46f42a..00000000
--- a/newton/newton/pub/utils/syscomm.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import inspect
-
-
-def fun_name():
- return inspect.stack()[1][3]
diff --git a/newton/newton/pub/utils/timeutil.py b/newton/newton/pub/utils/timeutil.py
deleted file mode 100644
index 0c3dd658..00000000
--- a/newton/newton/pub/utils/timeutil.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import datetime
-
-
-def now_time(fmt="%Y-%m-%d %H:%M:%S"):
- return datetime.datetime.now().strftime(fmt)
diff --git a/newton/newton/pub/utils/toscautil.py b/newton/newton/pub/utils/toscautil.py
deleted file mode 100644
index 5c2135ea..00000000
--- a/newton/newton/pub/utils/toscautil.py
+++ /dev/null
@@ -1,2606 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-
-def safe_get(key_val, key):
- return key_val[key] if key in key_val else ""
-
-
-def find_node_name(node_id, node_list):
- for node in node_list:
- if node['id'] == node_id:
- return node['template_name']
- raise Exception('can not find node(%s).' % node_id)
-
-
-def find_node_type(node_id, node_list):
- for node in node_list:
- if node['id'] == node_id:
- return node['type_name']
- raise Exception('can not find node(%s).' % node_id)
-
-
-def find_related_node(node_id, src_json_model, requirement_name):
- related_nodes = []
- for model_tpl in safe_get(src_json_model, "node_templates"):
- for rt in safe_get(model_tpl, 'requirement_templates'):
- if safe_get(rt, 'name') == requirement_name and \
- safe_get(rt, 'target_node_template_name') == node_id:
- related_nodes.append(model_tpl['name'])
- return related_nodes
-
-
-def convert_props(src_node, dest_node):
- if 'properties' in src_node and src_node['properties']:
- for prop_name, prop_info in src_node['properties'].items():
- if 'value' in prop_info:
- dest_node['properties'][prop_name] = prop_info['value']
-
-
-def convert_metadata(src_json):
- return src_json['metadata'] if 'metadata' in src_json else {}
-
-
-def convert_inputs(src_json):
- inputs = {}
- if 'inputs' in src_json:
- src_inputs = src_json['inputs']
- for param_name, param_info in src_inputs.items():
- input_param = {}
- if 'type_name' in param_info:
- input_param['type'] = param_info['type_name']
- if 'description' in param_info:
- input_param['description'] = param_info['description']
- if 'value' in param_info:
- input_param['value'] = param_info['value']
- inputs[param_name] = input_param
- return inputs
-
-
-def convert_vnf_node(src_node, src_json_model):
- vnf_node = {'type': src_node['type_name'], 'vnf_id': src_node['template_name'],
- 'description': '', 'properties': {}, 'dependencies': [], 'networks': []}
- convert_props(src_node, vnf_node)
- for model_tpl in safe_get(src_json_model, "node_templates"):
- if model_tpl['name'] != vnf_node['vnf_id']:
- continue
- vnf_node['dependencies'] = [{
- 'key_name': requirement['name'],
- 'vl_id': requirement['target_node_template_name']} for \
- requirement in safe_get(model_tpl, 'requirement_templates') if \
- safe_get(requirement, 'target_capability_name') == 'virtual_linkable']
- vnf_node['networks'] = [requirement['target_node_template_name'] for \
- requirement in safe_get(model_tpl, 'requirement_templates') if \
- safe_get(requirement, 'name') == 'dependency']
- return vnf_node
-
-
-def convert_pnf_node(src_node, src_json_model):
- pnf_node = {'pnf_id': src_node['template_name'], 'description': '', 'properties': {}}
- convert_props(src_node, pnf_node)
- pnf_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
- return pnf_node
-
-
-def convert_vl_node(src_node, src_node_list):
- vl_node = {'vl_id': src_node['template_name'], 'description': '', 'properties': {}}
- convert_props(src_node, vl_node)
- vl_node['route_id'] = ''
- for relation in safe_get(src_node, 'relationships'):
- if safe_get(relation, 'type_name').endswith('.VirtualLinksTo'):
- vl_node['route_id'] = find_node_name(relation['target_node_id'], src_node_list)
- break
- vl_node['route_external'] = (src_node['type_name'].find('.RouteExternalVL') > 0)
- return vl_node
-
-
-def convert_cp_node(src_node, src_node_list, model_type='NSD'):
- cp_node = {'cp_id': src_node['template_name'], 'description': '', 'properties': {}}
- convert_props(src_node, cp_node)
- src_relationships = src_node['relationships']
- for relation in src_relationships:
- if safe_get(relation, 'name') == 'virtualLink':
- cp_node['vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
- elif safe_get(relation, 'name') == 'virtualbinding':
- node_key = 'pnf_id' if model_type == 'NSD' else 'vdu_id'
- cp_node[node_key] = find_node_name(relation['target_node_id'], src_node_list)
- return cp_node
-
-
-def convert_router_node(src_node, src_node_list):
- router_node = {'router_id': src_node['template_name'], 'description': '', 'properties': {}}
- convert_props(src_node, router_node)
- for relation in src_node['relationships']:
- if safe_get(relation, 'name') != 'external_virtual_link':
- continue
- router_node['external_vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
- router_node['external_ip_addresses'] = []
- if 'properties' not in relation:
- continue
- for prop_name, prop_info in relation['properties'].items():
- if prop_name == 'router_ip_address':
- router_node['external_ip_addresses'].append(prop_info['value'])
- break
- return router_node
-
-
-def convert_fp_node(src_node, src_node_list, src_json_model):
- fp_node = {'fp_id': src_node['template_name'], 'description': '',
- 'properties': {}, 'forwarder_list': []}
- convert_props(src_node, fp_node)
- for relation in safe_get(src_node, 'relationships'):
- if safe_get(relation, 'name') != 'forwarder':
- continue
- forwarder_point = {'type': 'vnf'}
- target_node_type = find_node_type(relation['target_node_id'], src_node_list).upper()
- if target_node_type.find('.CP.') >= 0 or target_node_type.endswith('.CP'):
- forwarder_point['type'] = 'cp'
- forwarder_point['node_name'] = find_node_name(relation['target_node_id'], src_node_list)
- forwarder_point['capability'] = ''
- if forwarder_point['type'] == 'vnf':
- for node_tpl in src_json_model["node_templates"]:
- if fp_node['fp_id'] != node_tpl["name"]:
- continue
- for r_tpl in safe_get(node_tpl, "requirement_templates"):
- if safe_get(r_tpl, "target_node_template_name") != forwarder_point['node_name']:
- continue
- forwarder_point['capability'] = safe_get(r_tpl, "target_capability_name")
- break
- break
- fp_node['forwarder_list'].append(forwarder_point)
- return fp_node
-
-
-def convert_vnffg_group(src_group, src_group_list, src_node_list):
- vnffg = {'vnffg_id': src_group['template_name'], 'description': '',
- 'properties': {}, 'members': []}
- convert_props(src_group, vnffg)
- for member_node_id in src_group['member_node_ids']:
- vnffg['members'].append(find_node_name(member_node_id, src_node_list))
- return vnffg
-
-
-def convert_imagefile_node(src_node, src_node_list):
- image_node = {'image_file_id': src_node['template_name'], 'description': '',
- 'properties': {}}
- convert_props(src_node, image_node)
- return image_node
-
-
-def convert_localstorage_node(src_node, src_node_list):
- localstorage_node = {'local_storage_id': src_node['template_name'], 'description': '',
- 'properties': {}}
- convert_props(src_node, localstorage_node)
- return localstorage_node
-
-
-def convert_vdu_node(src_node, src_node_list, src_json_model):
- vdu_node = {'vdu_id': src_node['template_name'], 'description': '', 'properties': {},
- 'image_file': '', 'local_storages': [], 'dependencies': [], 'nfv_compute': {},
- 'vls': [], 'artifacts': []}
- convert_props(src_node, vdu_node)
-
- for relation in src_node['relationships']:
- r_id, r_name = safe_get(relation, 'target_node_id'), safe_get(relation, 'name')
- if r_name == 'guest_os':
- vdu_node['image_file'] = find_node_name(r_id, src_node_list)
- elif r_name == 'local_storage':
- vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
- elif r_name.endswith('.AttachesTo'):
- nt = find_node_type(r_id, src_node_list)
- if nt.endswith('.BlockStorage.Local') or nt.endswith('.LocalStorage'):
- vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
-
- for capability in src_node['capabilities']:
- if capability['name'] != 'nfv_compute':
- continue
- for prop_name, prop_info in capability['properties'].items():
- if 'value' in prop_info:
- vdu_node['nfv_compute'][prop_name] = prop_info['value']
-
- vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
-
- for cp_node in vdu_node['cps']:
- for src_cp_node in src_node_list:
- if src_cp_node['template_name'] != cp_node:
- continue
- for relation in safe_get(src_cp_node, 'relationships'):
- if relation['name'] != 'virtualLink':
- continue
- vl_node_name = find_node_name(relation['target_node_id'], src_node_list)
- if vl_node_name not in vdu_node['vls']:
- vdu_node['vls'].append(vl_node_name)
-
- for item in safe_get(src_node, 'artifacts'):
- artifact = {'artifact_name': item['name'], 'type': item['type_name'],
- 'file': item['source_path']}
- vdu_node['artifacts'].append(artifact)
-
- return vdu_node
-
-
-def convert_exposed_node(src_json, src_nodes, exposed):
- for item in safe_get(safe_get(src_json, 'substitution'), 'requirements'):
- exposed['external_cps'].append({'key_name': item['mapped_name'],
- "cp_id": find_node_name(item['node_id'], src_nodes)})
- for item in safe_get(safe_get(src_json, 'substitution'), 'capabilities'):
- exposed['forward_cps'].append({'key_name': item['mapped_name'],
- "cp_id": find_node_name(item['node_id'], src_nodes)})
-
-
-def convert_vnffgs(src_json_inst, src_nodes):
- vnffgs = []
- src_groups = safe_get(src_json_inst, 'groups')
- for group in src_groups:
- type_name = group['type_name'].upper()
- if type_name.find('.VNFFG.') >= 0 or type_name.endswith('.VNFFG'):
- vnffgs.append(convert_vnffg_group(group, src_groups, src_nodes))
- return vnffgs
-
-
-def convert_common(src_json, target_json):
- if isinstance(src_json, (unicode, str)):
- src_json_dict = json.loads(src_json)
- else:
- src_json_dict = src_json
- src_json_inst = src_json_dict["instance"]
- src_json_model = src_json_dict["model"] if "model" in src_json_dict else {}
-
- target_json['metadata'] = convert_metadata(src_json_inst)
- target_json['inputs'] = convert_inputs(src_json_inst)
- target_json['vls'] = []
- target_json['cps'] = []
- target_json['routers'] = []
-
- return src_json_inst, src_json_model
-
-
-def convert_nsd_model(src_json):
- target_json = {'vnfs': [], 'pnfs': [], 'fps': []}
- src_json_inst, src_json_model = convert_common(src_json, target_json)
-
- src_nodes = src_json_inst['nodes']
- for node in src_nodes:
- type_name = node['type_name']
- if type_name.find('.VNF.') > 0 or type_name.endswith('.VNF'):
- target_json['vnfs'].append(convert_vnf_node(node, src_json_model))
- elif type_name.find('.PNF.') > 0 or type_name.endswith('.PNF'):
- target_json['pnfs'].append(convert_pnf_node(node, src_json_model))
- elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
- or node['type_name'].find('.RouteExternalVL') > 0:
- target_json['vls'].append(convert_vl_node(node, src_nodes))
- elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'):
- target_json['cps'].append(convert_cp_node(node, src_nodes))
- elif type_name.find('.FP.') > 0 or type_name.endswith('.FP'):
- target_json['fps'].append(convert_fp_node(node, src_nodes, src_json_model))
- elif type_name.endswith('.Router'):
- target_json['routers'].append(convert_router_node(node, src_nodes))
-
- target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes)
-
- target_json['ns_exposed'] = {'external_cps': [], 'forward_cps': []}
- convert_exposed_node(src_json_inst, src_nodes, target_json['ns_exposed'])
- return json.dumps(target_json)
-
-
-def convert_vnfd_model(src_json):
- target_json = {'image_files': [], 'local_storages': [], 'vdus': []}
- src_json_inst, src_json_model = convert_common(src_json, target_json)
-
- src_nodes = src_json_inst['nodes']
- for node in src_nodes:
- type_name = node['type_name']
- if type_name.endswith('.ImageFile'):
- target_json['image_files'].append(convert_imagefile_node(node, src_nodes))
- elif type_name.endswith('.BlockStorage.Local') or type_name.endswith('.LocalStorage'):
- target_json['local_storages'].append(convert_localstorage_node(node, src_nodes))
- elif type_name.find('.VDU.') > 0 or type_name.endswith('.VDU'):
- target_json['vdus'].append(convert_vdu_node(node, src_nodes, src_json_model))
- elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
- or node['type_name'].find('.RouteExternalVL') > 0:
- target_json['vls'].append(convert_vl_node(node, src_nodes))
- elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'):
- target_json['cps'].append(convert_cp_node(node, src_nodes, 'VNFD'))
- elif type_name.endswith('.Router'):
- target_json['routers'].append(convert_router_node(node, src_nodes))
-
- target_json['vnf_exposed'] = {'external_cps': [], 'forward_cps': []}
- convert_exposed_node(src_json_inst, src_nodes, target_json['vnf_exposed'])
- return json.dumps(target_json)
-
-if __name__ == '__main__':
- src_json = json.dumps(
- {
- "instance":{
- "metadata":{
- "vendor":"ZTE",
- "name":"VCPE_NS",
- "csarVersion":"v1.0",
- "csarType":"NSAR",
- "csarProvider":"ZTE",
- "version":1,
- "invariant_id":"vcpe_ns_sff_1",
- "id":"VCPE_NS",
- "description":"vcpe_ns"
- },
- "nodes":[
- {
- "id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "type_name":"tosca.nodes.nfv.ext.FP",
- "template_name":"path2",
- "properties":{
- "symmetric":{
- "type_name":"boolean",
- "value":False
- },
- "policy":{
- "type_name":"tosca.datatypes.nfv.ext.FPPolicy",
- "value":{
- "type":"ACL",
- "criteria":{
- "dest_port_range":"1-100",
- "ip_protocol":"tcp",
- "source_ip_range":[
- "119.1.1.1-119.1.1.10"
- ],
- "dest_ip_range":[
- {"get_input":"NatIpRange"}
- ],
- "dscp":0,
- "source_port_range":"1-100"
- }
- }
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- }
- ],
- "relationships":[
- {
- "name":"forwarder",
- "source_requirement_index":0,
- "target_node_id":"m6000_data_out_qeukdtf6g87cnparxi51fa8s6"
- },
- {
- "name":"forwarder",
- "source_requirement_index":1,
- "target_node_id":"m600_tunnel_cp_imwfk5l48ljz0g9knc6d68hv5"
- },
- {
- "name":"forwarder",
- "source_requirement_index":2,
- "target_node_id":"VNAT_cfdljtspvkp234irka59wgab0",
- "target_capability_name":"feature"
- }
- ]
- },
- {
- "id":"path1_bv53fblv26hawr8dj4fxe2rsd",
- "type_name":"tosca.nodes.nfv.ext.FP",
- "template_name":"path1",
- "properties":{
- "symmetric":{
- "type_name":"boolean",
- "value":True
- },
- "policy":{
- "type_name":"tosca.datatypes.nfv.ext.FPPolicy",
- "value":{
- "type":"ACL",
- "criteria":{
- "dest_port_range":"1-100",
- "ip_protocol":"tcp",
- "source_ip_range":[
- "1-100"
- ],
- "dest_ip_range":[
- "1-100"
- ],
- "dscp":4,
- "source_port_range":"1-100"
- }
- }
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- }
- ],
- "relationships":[
- {
- "name":"forwarder",
- "source_requirement_index":0,
- "target_node_id":"m6000_data_in_eldly5txw4frny3cc349uz3nc"
- },
- {
- "name":"forwarder",
- "source_requirement_index":1,
- "target_node_id":"m600_tunnel_cp_imwfk5l48ljz0g9knc6d68hv5"
- },
- {
- "name":"forwarder",
- "source_requirement_index":2,
- "target_node_id":"VFW_57z0ua89aiyl8ncvw7h7mjf34",
- "target_capability_name":"feature"
- },
- {
- "name":"forwarder",
- "source_requirement_index":3,
- "target_node_id":"VNAT_cfdljtspvkp234irka59wgab0",
- "target_capability_name":"feature"
- },
- {
- "name":"forwarder",
- "source_requirement_index":4,
- "target_node_id":"m600_tunnel_cp_imwfk5l48ljz0g9knc6d68hv5"
- },
- {
- "name":"forwarder",
- "source_requirement_index":5,
- "target_node_id":"m6000_data_out_qeukdtf6g87cnparxi51fa8s6"
- }
- ]
- },
- {
- "id":"m6000_data_out_qeukdtf6g87cnparxi51fa8s6",
- "type_name":"tosca.nodes.nfv.ext.zte.CP",
- "template_name":"m6000_data_out",
- "properties":{
- "direction":{
- "type_name":"string",
- "value":"bidirectional"
- },
- "vnic_type":{
- "type_name":"string",
- "value":"normal"
- },
- "bandwidth":{
- "type_name":"integer",
- "value":0
- },
- "mac_address":{
- "type_name":"string",
- "value":"11-22-33-22-11-44"
- },
- "interface_name":{
- "type_name":"string",
- "value":"xgei-0/4/1/5"
- },
- "ip_address":{
- "type_name":"string",
- "value":"176.1.1.2"
- },
- "order":{
- "type_name":"integer",
- "value":0
- },
- "sfc_encapsulation":{
- "type_name":"string",
- "value":"mac"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "relationships":[
- {
- "name":"virtualbinding",
- "source_requirement_index":0,
- "target_node_id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18",
- "target_capability_name":"feature"
- },
- {
- "name":"virtualLink",
- "source_requirement_index":1,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- },
- {
- "name":"forwarder",
- "source_requirement_index":2,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- }
- ]
- },
- {
- "id":"VFW_57z0ua89aiyl8ncvw7h7mjf34",
- "type_name":"tosca.nodes.nfv.ext.zte.VNF.VFW",
- "template_name":"VFW",
- "properties":{
- "is_shared":{
- "type_name":"boolean",
- "value":False
- },
- "plugin_info":{
- "type_name":"string",
- "value":"vbrasplugin_1.0"
- },
- "vendor":{
- "type_name":"string",
- "value":"zte"
- },
- "request_reclassification":{
- "type_name":"boolean",
- "value":False
- },
- "vnf_extend_type":{
- "type_name":"string",
- "value":"driver"
- },
- "name":{
- "type_name":"string",
- "value":"VFW"
- },
- "version":{
- "type_name":"string",
- "value":"1.0"
- },
- "cross_dc":{
- "type_name":"boolean",
- "value":False
- },
- "vnf_type":{
- "type_name":"string",
- "value":"VFW"
- },
- "vnfd_version":{
- "type_name":"string",
- "value":"1.0.0"
- },
- "id":{
- "type_name":"string",
- "value":"vcpe_vfw_zte_1_0"
- },
- "nsh_aware":{
- "type_name":"boolean",
- "value":True
- },
- "adjust_vnf_capacity":{
- "type_name":"boolean",
- "value":True
- },
- "vmnumber_overquota_alarm":{
- "type_name":"boolean",
- "value":True
- },
- "csarProvider":{
- "type_name":"string",
- "value":"ZTE"
- },
- "csarVersion":{
- "type_name":"string",
- "value":"v1.0"
- },
- "externalPluginManageNetworkName":{
- "type_name":"string",
- "value":"vlan_4007_plugin_net"
- },
- "csarType":{
- "type_name":"string",
- "value":"NFAR"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- },
- {
- "name":"vfw_fw_inout",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "relationships":[
- {
- "name":"vfw_ctrl_by_manager_cp",
- "source_requirement_index":0,
- "target_node_id":"ext_mnet_net_au2otee5mcy0dnpqykj487zr3",
- "target_capability_name":"feature"
- },
- {
- "name":"vfw_data_cp",
- "source_requirement_index":1,
- "target_node_id":"sfc_data_network_vx3pc1oahn0k0pa5q722yafee",
- "target_capability_name":"feature"
- },
- {
- "name":"virtualLink",
- "source_requirement_index":2,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- },
- {
- "name":"forwarder",
- "source_requirement_index":3,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- }
- ]
- },
- {
- "id":"m600_tunnel_cp_imwfk5l48ljz0g9knc6d68hv5",
- "type_name":"tosca.nodes.nfv.ext.zte.CP",
- "template_name":"m600_tunnel_cp",
- "properties":{
- "direction":{
- "type_name":"string",
- "value":"bidirectional"
- },
- "vnic_type":{
- "type_name":"string",
- "value":"normal"
- },
- "bandwidth":{
- "type_name":"integer",
- "value":0
- },
- "mac_address":{
- "type_name":"string",
- "value":"00-11-00-22-33-00"
- },
- "interface_name":{
- "type_name":"string",
- "value":"gei-0/4/0/13"
- },
- "ip_address":{
- "type_name":"string",
- "value":"191.167.100.5"
- },
- "order":{
- "type_name":"integer",
- "value":0
- },
- "sfc_encapsulation":{
- "type_name":"string",
- "value":"mac"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "relationships":[
- {
- "name":"virtualLink",
- "source_requirement_index":0,
- "target_node_id":"ext_datanet_net_qtqzlx5dsthzs883hxjn6hyhd",
- "target_capability_name":"feature"
- },
- {
- "name":"virtualbinding",
- "source_requirement_index":1,
- "target_node_id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18",
- "target_capability_name":"feature"
- },
- {
- "name":"forwarder",
- "source_requirement_index":2,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- }
- ]
- },
- {
- "id":"ext_mnet_net_au2otee5mcy0dnpqykj487zr3",
- "type_name":"tosca.nodes.nfv.ext.VL.Vmware",
- "template_name":"ext_mnet_net",
- "properties":{
- "name":{
- "type_name":"string",
- "value":"vlan_4008_mng_net"
- },
- "dhcp_enabled":{
- "type_name":"boolean",
- "value":True
- },
- "location_info":{
- "type_name":"tosca.datatypes.nfv.ext.LocationInfo",
- "value":{
- "tenant":"admin",
- "vimid":2,
- "availability_zone":"nova"
- }
- },
- "ip_version":{
- "type_name":"integer",
- "value":4
- },
- "mtu":{
- "type_name":"integer",
- "value":1500
- },
- "network_name":{
- "type_name":"string",
- "value":"vlan_4008_mng_net"
- },
- "network_type":{
- "type_name":"string",
- "value":"vlan"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"virtual_linkable",
- "type_name":"tosca.capabilities.nfv.VirtualLinkable"
- }
- ]
- },
- {
- "id":"m6000_data_in_eldly5txw4frny3cc349uz3nc",
- "type_name":"tosca.nodes.nfv.ext.zte.CP",
- "template_name":"m6000_data_in",
- "properties":{
- "direction":{
- "type_name":"string",
- "value":"bidirectional"
- },
- "vnic_type":{
- "type_name":"string",
- "value":"normal"
- },
- "bandwidth":{
- "type_name":"integer",
- "value":0
- },
- "mac_address":{
- "type_name":"string",
- "value":"11-22-33-22-11-41"
- },
- "interface_name":{
- "type_name":"string",
- "value":"gei-0/4/0/7"
- },
- "ip_address":{
- "type_name":"string",
- "value":"1.1.1.1"
- },
- "order":{
- "type_name":"integer",
- "value":0
- },
- "sfc_encapsulation":{
- "type_name":"string",
- "value":"mac"
- },
- "bond":{
- "type_name":"string",
- "value":"none"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "relationships":[
- {
- "name":"virtualbinding",
- "source_requirement_index":0,
- "target_node_id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18",
- "target_capability_name":"feature"
- },
- {
- "name":"virtualLink",
- "source_requirement_index":1,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- },
- {
- "name":"forwarder",
- "source_requirement_index":2,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- }
- ]
- },
- {
- "id":"ext_datanet_net_qtqzlx5dsthzs883hxjn6hyhd",
- "type_name":"tosca.nodes.nfv.ext.VL.Vmware",
- "template_name":"ext_datanet_net",
- "properties":{
- "name":{
- "type_name":"string",
- "value":"vlan_4004_tunnel_net"
- },
- "dhcp_enabled":{
- "type_name":"boolean",
- "value":True
- },
- "location_info":{
- "type_name":"tosca.datatypes.nfv.ext.LocationInfo",
- "value":{
- "tenant":"admin",
- "vimid":2,
- "availability_zone":"nova"
- }
- },
- "ip_version":{
- "type_name":"integer",
- "value":4
- },
- "mtu":{
- "type_name":"integer",
- "value":1500
- },
- "network_name":{
- "type_name":"string",
- "value":"vlan_4004_tunnel_net"
- },
- "network_type":{
- "type_name":"string",
- "value":"vlan"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"virtual_linkable",
- "type_name":"tosca.capabilities.nfv.VirtualLinkable"
- }
- ]
- },
- {
- "id":"m600_mnt_cp_l3488y2a8ilyfdn0l89ni4os7",
- "type_name":"tosca.nodes.nfv.ext.zte.CP",
- "template_name":"m600_mnt_cp",
- "properties":{
- "direction":{
- "type_name":"string",
- "value":"bidirectional"
- },
- "vnic_type":{
- "type_name":"string",
- "value":"normal"
- },
- "bandwidth":{
- "type_name":"integer",
- "value":0
- },
- "mac_address":{
- "type_name":"string",
- "value":"00-11-00-22-33-11"
- },
- "interface_name":{
- "type_name":"string",
- "value":"gei-0/4/0/1"
- },
- "ip_address":{
- "type_name":"string",
- "value":"10.46.244.51"
- },
- "order":{
- "type_name":"integer",
- "value":0
- },
- "sfc_encapsulation":{
- "type_name":"string",
- "value":"mac"
- },
- "bond":{
- "type_name":"string",
- "value":"none"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "relationships":[
- {
- "name":"virtualLink",
- "source_requirement_index":0,
- "target_node_id":"ext_mnet_net_au2otee5mcy0dnpqykj487zr3",
- "target_capability_name":"feature"
- },
- {
- "name":"virtualbinding",
- "source_requirement_index":1,
- "target_node_id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18",
- "target_capability_name":"feature"
- },
- {
- "name":"forwarder",
- "source_requirement_index":2,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- }
- ]
- },
- {
- "id":"sfc_data_network_vx3pc1oahn0k0pa5q722yafee",
- "type_name":"tosca.nodes.nfv.ext.zte.VL",
- "template_name":"sfc_data_network",
- "properties":{
- "name":{
- "type_name":"string",
- "value":"sfc_data_network"
- },
- "dhcp_enabled":{
- "type_name":"boolean",
- "value":True
- },
- "is_predefined":{
- "type_name":"boolean",
- "value":False
- },
- "location_info":{
- "type_name":"tosca.datatypes.nfv.ext.LocationInfo",
- "value":{
- "tenant":"admin",
- "vimid":2,
- "availability_zone":"nova"
- }
- },
- "ip_version":{
- "type_name":"integer",
- "value":4
- },
- "mtu":{
- "type_name":"integer",
- "value":1500
- },
- "network_name":{
- "type_name":"string",
- "value":"sfc_data_network"
- },
- "network_type":{
- "type_name":"string",
- "value":"vlan"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"virtual_linkable",
- "type_name":"tosca.capabilities.nfv.VirtualLinkable"
- }
- ]
- },
- {
- "id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18",
- "type_name":"tosca.nodes.nfv.ext.PNF",
- "template_name":"m6000_s",
- "properties":{
- "vendor":{
- "type_name":"string",
- "value":"zte"
- },
- "request_reclassification":{
- "type_name":"boolean",
- "value":False
- },
- "pnf_type":{
- "type_name":"string",
- "value":"m6000s"
- },
- "version":{
- "type_name":"string",
- "value":"1.0"
- },
- "management_address":{
- "type_name":"string",
- "value":"111111"
- },
- "id":{
- "type_name":"string",
- "value":"m6000_s"
- },
- "nsh_aware":{
- "type_name":"boolean",
- "value":False
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"virtualBinding",
- "type_name":"tosca.capabilities.nfv.VirtualBindable"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "relationships":[
- {
- "name":"forwarder",
- "source_requirement_index":0,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- }
- ]
- },
- {
- "id":"VNAT_cfdljtspvkp234irka59wgab0",
- "type_name":"tosca.nodes.nfv.ext.zte.VNF.VNAT",
- "template_name":"VNAT",
- "properties":{
- "is_shared":{
- "type_name":"boolean",
- "value":False
- },
- "plugin_info":{
- "type_name":"string",
- "value":"vbrasplugin_1.0"
- },
- "vendor":{
- "type_name":"string",
- "value":"zte"
- },
- "request_reclassification":{
- "type_name":"boolean",
- "value":False
- },
- "name":{
- "type_name":"string",
- "value":"VNAT"
- },
- "vnf_extend_type":{
- "type_name":"string",
- "value":"driver"
- },
- "externalPluginManageNetworkName":{
- "type_name":"string",
- "value":"vlan_4007_plugin_net"
- },
- "version":{
- "type_name":"string",
- "value":"1.0"
- },
- "cross_dc":{
- "type_name":"boolean",
- "value":False
- },
- "vnf_type":{
- "type_name":"string",
- "value":"VNAT"
- },
- "vnfd_version":{
- "type_name":"string",
- "value":"1.0.0"
- },
- "id":{
- "type_name":"string",
- "value":"vcpe_vnat_zte_1"
- },
- "nsh_aware":{
- "type_name":"boolean",
- "value":True
- },
- "adjust_vnf_capacity":{
- "type_name":"boolean",
- "value":True
- },
- "vmnumber_overquota_alarm":{
- "type_name":"boolean",
- "value":True
- },
- "csarProvider":{
- "type_name":"string",
- "value":"ZTE"
- },
- "NatIpRange":{
- "type_name":"string",
- "value":"192.167.0.10-192.168.0.20"
- },
- "csarVersion":{
- "type_name":"string",
- "value":"v1.0"
- },
- "csarType":{
- "type_name":"string",
- "value":"NFAR"
- }
- },
- "interfaces":[
- {
- "name":"Standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "capabilities":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- },
- {
- "name":"vnat_fw_inout",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "relationships":[
- {
- "name":"vnat_ctrl_by_manager_cp",
- "source_requirement_index":0,
- "target_node_id":"ext_mnet_net_au2otee5mcy0dnpqykj487zr3",
- "target_capability_name":"feature"
- },
- {
- "name":"vnat_data_cp",
- "source_requirement_index":1,
- "target_node_id":"sfc_data_network_vx3pc1oahn0k0pa5q722yafee",
- "target_capability_name":"feature"
- },
- {
- "name":"virtualLink",
- "source_requirement_index":2,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- },
- {
- "name":"forwarder",
- "source_requirement_index":3,
- "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc",
- "target_capability_name":"feature"
- }
- ]
- }
- ],
- "groups":[
- {
- "id":"vnffg1_wk1aqhk6exoh5fmds2unu0uyc",
- "type_name":"tosca.groups.nfv.VNFFG",
- "template_name":"vnffg1",
- "properties":{
- "vendor":{
- "type_name":"string",
- "value":"zte"
- },
- "connection_point":{
- "type_name":"list",
- "value":[
- "m6000_data_in",
- "m600_tunnel_cp",
- "m6000_data_out"
- ]
- },
- "version":{
- "type_name":"string",
- "value":"1.0"
- },
- "constituent_vnfs":{
- "type_name":"list",
- "value":[
- "VFW",
- "VNAT"
- ]
- },
- "number_of_endpoints":{
- "type_name":"integer",
- "value":3
- },
- "dependent_virtual_link":{
- "type_name":"list",
- "value":[
- "sfc_data_network",
- "ext_datanet_net",
- "ext_mnet_net"
- ]
- }
- },
- "interfaces":[
- {
- "name":"standard",
- "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
- "type_name":"tosca.interfaces.node.lifecycle.Standard",
- "operations":[
- {
- "name":"create",
- "description":"Standard lifecycle create operation."
- },
- {
- "name":"stop",
- "description":"Standard lifecycle stop operation."
- },
- {
- "name":"start",
- "description":"Standard lifecycle start operation."
- },
- {
- "name":"delete",
- "description":"Standard lifecycle delete operation."
- },
- {
- "name":"configure",
- "description":"Standard lifecycle configure operation."
- }
- ]
- }
- ],
- "member_node_ids":[
- "path1_bv53fblv26hawr8dj4fxe2rsd",
- "path2_kgmfqr5ldqs9lj3oscrgxqefc"
- ]
- }
- ],
- "substitution":{
- "node_type_name":"tosca.nodes.nfv.NS.VCPE_NS"
- },
- "inputs":{
- "externalDataNetworkName":{
- "type_name":"string",
- "value":"vlan_4004_tunnel_net"
- },
- "sfc_data_network":{
- "type_name":"string",
- "value":"sfc_data_network"
- },
- "NatIpRange":{
- "type_name":"string",
- "value":"192.167.0.10-192.168.0.20"
- },
- "externalManageNetworkName":{
- "type_name":"string",
- "value":"vlan_4008_mng_net"
- },
- "externalPluginManageNetworkName":{
- "type_name":"string",
- "value":"vlan_4007_plugin_net"
- }
- }
- },
- "model":{
- "metadata":{
- "vendor":"ZTE",
- "name":"VCPE_NS",
- "csarVersion":"v1.0",
- "csarType":"NSAR",
- "csarProvider":"ZTE",
- "version":1,
- "invariant_id":"vcpe_ns_sff_1",
- "id":"VCPE_NS",
- "description":"vcpe_ns"
- },
- "node_templates":[
- {
- "name":"path2",
- "type_name":"tosca.nodes.nfv.ext.FP",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "symmetric":{
- "type_name":"boolean",
- "value":False
- },
- "policy":{
- "type_name":"tosca.datatypes.nfv.ext.FPPolicy",
- "value":{
- "type":"ACL",
- "criteria":{
- "dest_port_range":"1-100",
- "ip_protocol":"tcp",
- "source_ip_range":[
- "119.1.1.1-119.1.1.10"
- ],
- "dest_ip_range":[
- {"get_input":"NatIpRange"}
- ],
- "dscp":0,
- "source_port_range":"1-100"
- }
- }
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ed0288a10>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- }
- ],
- "requirement_templates":[
- {
- "name":"forwarder",
- "target_node_template_name":"m6000_data_out"
- },
- {
- "name":"forwarder",
- "target_node_template_name":"m600_tunnel_cp"
- },
- {
- "name":"forwarder",
- "target_node_template_name":"VNAT",
- "target_capability_name":"vnat_fw_inout"
- }
- ]
- },
- {
- "name":"path1",
- "type_name":"tosca.nodes.nfv.ext.FP",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "symmetric":{
- "type_name":"boolean",
- "value":True
- },
- "policy":{
- "type_name":"tosca.datatypes.nfv.ext.FPPolicy",
- "value":{
- "type":"ACL",
- "criteria":{
- "dest_port_range":"1-100",
- "ip_protocol":"tcp",
- "source_ip_range":[
- "1-100"
- ],
- "dest_ip_range":[
- "1-100"
- ],
- "dscp":4,
- "source_port_range":"1-100"
- }
- }
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec81df090>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- }
- ],
- "requirement_templates":[
- {
- "name":"forwarder",
- "target_node_template_name":"m6000_data_in"
- },
- {
- "name":"forwarder",
- "target_node_template_name":"m600_tunnel_cp"
- },
- {
- "name":"forwarder",
- "target_node_template_name":"VFW",
- "target_capability_name":"vfw_fw_inout"
- },
- {
- "name":"forwarder",
- "target_node_template_name":"VNAT",
- "target_capability_name":"vnat_fw_inout"
- },
- {
- "name":"forwarder",
- "target_node_template_name":"m600_tunnel_cp"
- },
- {
- "name":"forwarder",
- "target_node_template_name":"m6000_data_out"
- }
- ]
- },
- {
- "name":"m6000_data_out",
- "type_name":"tosca.nodes.nfv.ext.zte.CP",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "direction":{
- "type_name":"string",
- "value":"bidirectional"
- },
- "vnic_type":{
- "type_name":"string",
- "value":"normal"
- },
- "bandwidth":{
- "type_name":"integer",
- "value":0
- },
- "mac_address":{
- "type_name":"string",
- "value":"11-22-33-22-11-44"
- },
- "interface_name":{
- "type_name":"string",
- "value":"xgei-0/4/1/5"
- },
- "ip_address":{
- "type_name":"string",
- "value":"176.1.1.2"
- },
- "order":{
- "type_name":"integer",
- "value":0
- },
- "sfc_encapsulation":{
- "type_name":"string",
- "value":"mac"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec82c6610>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "requirement_templates":[
- {
- "name":"virtualbinding",
- "target_node_template_name":"m6000_s",
- "target_capability_name":"virtualBinding"
- },
- {
- "name":"virtualLink",
- "target_node_type_name":"tosca.nodes.Root"
- },
- {
- "name":"forwarder",
- "target_node_type_name":"tosca.nodes.Root"
- }
- ]
- },
- {
- "name":"VFW",
- "type_name":"tosca.nodes.nfv.ext.zte.VNF.VFW",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "is_shared":{
- "type_name":"boolean",
- "value":False
- },
- "plugin_info":{
- "type_name":"string",
- "value":"vbrasplugin_1.0"
- },
- "vendor":{
- "type_name":"string",
- "value":"zte"
- },
- "request_reclassification":{
- "type_name":"boolean",
- "value":False
- },
- "vnf_extend_type":{
- "type_name":"string",
- "value":"driver"
- },
- "name":{
- "type_name":"string",
- "value":"VFW"
- },
- "version":{
- "type_name":"string",
- "value":"1.0"
- },
- "cross_dc":{
- "type_name":"boolean",
- "value":False
- },
- "vnf_type":{
- "type_name":"string",
- "value":"VFW"
- },
- "vnfd_version":{
- "type_name":"string",
- "value":"1.0.0"
- },
- "id":{
- "type_name":"string",
- "value":"vcpe_vfw_zte_1_0"
- },
- "nsh_aware":{
- "type_name":"boolean",
- "value":True
- },
- "adjust_vnf_capacity":{
- "type_name":"boolean",
- "value":True
- },
- "vmnumber_overquota_alarm":{
- "type_name":"boolean",
- "value":True
- },
- "csarProvider":{
- "type_name":"string",
- "value":"ZTE"
- },
- "csarVersion":{
- "type_name":"string",
- "value":"v1.0"
- },
- "externalPluginManageNetworkName":{
- "type_name":"string",
- "value":"vlan_4007_plugin_net"
- },
- "csarType":{
- "type_name":"string",
- "value":"NFAR"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec8281950>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- },
- {
- "name":"vfw_fw_inout",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "requirement_templates":[
- {
- "name":"vfw_ctrl_by_manager_cp",
- "target_node_template_name":"ext_mnet_net",
- "target_capability_name":"virtual_linkable"
- },
- {
- "name":"vfw_data_cp",
- "target_node_template_name":"sfc_data_network",
- "target_capability_name":"virtual_linkable"
- },
- {
- "name":"virtualLink",
- "target_node_type_name":"tosca.nodes.Root"
- },
- {
- "name":"forwarder",
- "target_node_type_name":"tosca.nodes.Root"
- }
- ]
- },
- {
- "name":"m600_tunnel_cp",
- "type_name":"tosca.nodes.nfv.ext.zte.CP",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "direction":{
- "type_name":"string",
- "value":"bidirectional"
- },
- "vnic_type":{
- "type_name":"string",
- "value":"normal"
- },
- "bandwidth":{
- "type_name":"integer",
- "value":0
- },
- "mac_address":{
- "type_name":"string",
- "value":"00-11-00-22-33-00"
- },
- "interface_name":{
- "type_name":"string",
- "value":"gei-0/4/0/13"
- },
- "ip_address":{
- "type_name":"string",
- "value":"191.167.100.5"
- },
- "order":{
- "type_name":"integer",
- "value":0
- },
- "sfc_encapsulation":{
- "type_name":"string",
- "value":"mac"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x1ae39d0>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "requirement_templates":[
- {
- "name":"virtualLink",
- "target_node_template_name":"ext_datanet_net",
- "target_capability_name":"virtual_linkable"
- },
- {
- "name":"virtualbinding",
- "target_node_template_name":"m6000_s",
- "target_capability_name":"virtualBinding"
- },
- {
- "name":"forwarder",
- "target_node_type_name":"tosca.nodes.Root"
- }
- ]
- },
- {
- "name":"ext_mnet_net",
- "type_name":"tosca.nodes.nfv.ext.VL.Vmware",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "name":{
- "type_name":"string",
- "value":"vlan_4008_mng_net"
- },
- "dhcp_enabled":{
- "type_name":"boolean",
- "value":True
- },
- "location_info":{
- "type_name":"tosca.datatypes.nfv.ext.LocationInfo",
- "value":{
- "tenant":"admin",
- "vimid":2,
- "availability_zone":"nova"
- }
- },
- "ip_version":{
- "type_name":"integer",
- "value":4
- },
- "mtu":{
- "type_name":"integer",
- "value":1500
- },
- "network_name":{
- "type_name":"string",
- "value":"vlan_4008_mng_net"
- },
- "network_type":{
- "type_name":"string",
- "value":"vlan"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ed00f89d0>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"virtual_linkable",
- "type_name":"tosca.capabilities.nfv.VirtualLinkable"
- }
- ]
- },
- {
- "name":"m6000_data_in",
- "type_name":"tosca.nodes.nfv.ext.zte.CP",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "direction":{
- "type_name":"string",
- "value":"bidirectional"
- },
- "vnic_type":{
- "type_name":"string",
- "value":"normal"
- },
- "bandwidth":{
- "type_name":"integer",
- "value":0
- },
- "mac_address":{
- "type_name":"string",
- "value":"11-22-33-22-11-41"
- },
- "interface_name":{
- "type_name":"string",
- "value":"gei-0/4/0/7"
- },
- "ip_address":{
- "type_name":"string",
- "value":"1.1.1.1"
- },
- "order":{
- "type_name":"integer",
- "value":0
- },
- "sfc_encapsulation":{
- "type_name":"string",
- "value":"mac"
- },
- "bond":{
- "type_name":"string",
- "value":"none"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x1745710>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "requirement_templates":[
- {
- "name":"virtualbinding",
- "target_node_template_name":"m6000_s",
- "target_capability_name":"virtualBinding"
- },
- {
- "name":"virtualLink",
- "target_node_type_name":"tosca.nodes.Root"
- },
- {
- "name":"forwarder",
- "target_node_type_name":"tosca.nodes.Root"
- }
- ]
- },
- {
- "name":"ext_datanet_net",
- "type_name":"tosca.nodes.nfv.ext.VL.Vmware",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "name":{
- "type_name":"string",
- "value":"vlan_4004_tunnel_net"
- },
- "dhcp_enabled":{
- "type_name":"boolean",
- "value":True
- },
- "location_info":{
- "type_name":"tosca.datatypes.nfv.ext.LocationInfo",
- "value":{
- "tenant":"admin",
- "vimid":2,
- "availability_zone":"nova"
- }
- },
- "ip_version":{
- "type_name":"integer",
- "value":4
- },
- "mtu":{
- "type_name":"integer",
- "value":1500
- },
- "network_name":{
- "type_name":"string",
- "value":"vlan_4004_tunnel_net"
- },
- "network_type":{
- "type_name":"string",
- "value":"vlan"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8eac063990>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"virtual_linkable",
- "type_name":"tosca.capabilities.nfv.VirtualLinkable"
- }
- ]
- },
- {
- "name":"m600_mnt_cp",
- "type_name":"tosca.nodes.nfv.ext.zte.CP",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "direction":{
- "type_name":"string",
- "value":"bidirectional"
- },
- "vnic_type":{
- "type_name":"string",
- "value":"normal"
- },
- "bandwidth":{
- "type_name":"integer",
- "value":0
- },
- "mac_address":{
- "type_name":"string",
- "value":"00-11-00-22-33-11"
- },
- "interface_name":{
- "type_name":"string",
- "value":"gei-0/4/0/1"
- },
- "ip_address":{
- "type_name":"string",
- "value":"10.46.244.51"
- },
- "order":{
- "type_name":"integer",
- "value":0
- },
- "sfc_encapsulation":{
- "type_name":"string",
- "value":"mac"
- },
- "bond":{
- "type_name":"string",
- "value":"none"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec81264d0>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "requirement_templates":[
- {
- "name":"virtualLink",
- "target_node_template_name":"ext_mnet_net",
- "target_capability_name":"virtual_linkable"
- },
- {
- "name":"virtualbinding",
- "target_node_template_name":"m6000_s",
- "target_capability_name":"virtualBinding"
- },
- {
- "name":"forwarder",
- "target_node_type_name":"tosca.nodes.Root"
- }
- ]
- },
- {
- "name":"sfc_data_network",
- "type_name":"tosca.nodes.nfv.ext.zte.VL",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "name":{
- "type_name":"string",
- "value":"sfc_data_network"
- },
- "dhcp_enabled":{
- "type_name":"boolean",
- "value":True
- },
- "is_predefined":{
- "type_name":"boolean",
- "value":False
- },
- "location_info":{
- "type_name":"tosca.datatypes.nfv.ext.LocationInfo",
- "value":{
- "tenant":"admin",
- "vimid":2,
- "availability_zone":"nova"
- }
- },
- "ip_version":{
- "type_name":"integer",
- "value":4
- },
- "mtu":{
- "type_name":"integer",
- "value":1500
- },
- "network_name":{
- "type_name":"string",
- "value":"sfc_data_network"
- },
- "network_type":{
- "type_name":"string",
- "value":"vlan"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec813c6d0>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"virtual_linkable",
- "type_name":"tosca.capabilities.nfv.VirtualLinkable"
- }
- ]
- },
- {
- "name":"m6000_s",
- "type_name":"tosca.nodes.nfv.ext.PNF",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "vendor":{
- "type_name":"string",
- "value":"zte"
- },
- "request_reclassification":{
- "type_name":"boolean",
- "value":False
- },
- "pnf_type":{
- "type_name":"string",
- "value":"m6000s"
- },
- "version":{
- "type_name":"string",
- "value":"1.0"
- },
- "management_address":{
- "type_name":"string",
- "value":"111111"
- },
- "id":{
- "type_name":"string",
- "value":"m6000_s"
- },
- "nsh_aware":{
- "type_name":"boolean",
- "value":False
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec8132490>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"virtualBinding",
- "type_name":"tosca.capabilities.nfv.VirtualBindable"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "requirement_templates":[
- {
- "name":"forwarder",
- "target_node_type_name":"tosca.nodes.Root"
- }
- ]
- },
- {
- "name":"VNAT",
- "type_name":"tosca.nodes.nfv.ext.zte.VNF.VNAT",
- "default_instances":1,
- "min_instances":0,
- "properties":{
- "is_shared":{
- "type_name":"boolean",
- "value":False
- },
- "plugin_info":{
- "type_name":"string",
- "value":"vbrasplugin_1.0"
- },
- "vendor":{
- "type_name":"string",
- "value":"zte"
- },
- "request_reclassification":{
- "type_name":"boolean",
- "value":False
- },
- "name":{
- "type_name":"string",
- "value":"VNAT"
- },
- "vnf_extend_type":{
- "type_name":"string",
- "value":"driver"
- },
- "externalPluginManageNetworkName":{
- "type_name":"string",
- "value":"vlan_4007_plugin_net"
- },
- "version":{
- "type_name":"string",
- "value":"1.0"
- },
- "cross_dc":{
- "type_name":"boolean",
- "value":False
- },
- "vnf_type":{
- "type_name":"string",
- "value":"VNAT"
- },
- "vnfd_version":{
- "type_name":"string",
- "value":"1.0.0"
- },
- "id":{
- "type_name":"string",
- "value":"vcpe_vnat_zte_1"
- },
- "nsh_aware":{
- "type_name":"boolean",
- "value":True
- },
- "adjust_vnf_capacity":{
- "type_name":"boolean",
- "value":True
- },
- "vmnumber_overquota_alarm":{
- "type_name":"boolean",
- "value":True
- },
- "csarProvider":{
- "type_name":"string",
- "value":"ZTE"
- },
- "NatIpRange":{
- "type_name":"string",
- "value":"192.167.0.10-192.168.0.20"
- },
- "csarVersion":{
- "type_name":"string",
- "value":"v1.0"
- },
- "csarType":{
- "type_name":"string",
- "value":"NFAR"
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x1bba810>"
- ],
- "capability_templates":[
- {
- "name":"feature",
- "type_name":"tosca.capabilities.Node"
- },
- {
- "name":"forwarder",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- },
- {
- "name":"vnat_fw_inout",
- "type_name":"tosca.capabilities.nfv.Forwarder"
- }
- ],
- "requirement_templates":[
- {
- "name":"vnat_ctrl_by_manager_cp",
- "target_node_template_name":"ext_mnet_net",
- "target_capability_name":"virtual_linkable"
- },
- {
- "name":"vnat_data_cp",
- "target_node_template_name":"sfc_data_network",
- "target_capability_name":"virtual_linkable"
- },
- {
- "name":"virtualLink",
- "target_node_type_name":"tosca.nodes.Root"
- },
- {
- "name":"forwarder",
- "target_node_type_name":"tosca.nodes.Root"
- }
- ]
- }
- ],
- "group_templates":[
- {
- "name":"vnffg1",
- "type_name":"tosca.groups.nfv.VNFFG",
- "properties":{
- "vendor":{
- "type_name":"string",
- "value":"zte"
- },
- "connection_point":{
- "type_name":"list",
- "value":[
- "m6000_data_in",
- "m600_tunnel_cp",
- "m6000_data_out"
- ]
- },
- "version":{
- "type_name":"string",
- "value":"1.0"
- },
- "constituent_vnfs":{
- "type_name":"list",
- "value":[
- "VFW",
- "VNAT"
- ]
- },
- "number_of_endpoints":{
- "type_name":"integer",
- "value":3
- },
- "dependent_virtual_link":{
- "type_name":"list",
- "value":[
- "sfc_data_network",
- "ext_datanet_net",
- "ext_mnet_net"
- ]
- }
- },
- "interface_templates":[
- "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec811cd10>"
- ],
- "member_node_template_names":[
- "path1",
- "path2"
- ]
- }
- ],
- "substitution_template":{
- "node_type_name":"tosca.nodes.nfv.NS.VCPE_NS"
- },
- "inputs":{
- "externalDataNetworkName":{
- "type_name":"string",
- "value":"vlan_4004_tunnel_net"
- },
- "sfc_data_network":{
- "type_name":"string",
- "value":"sfc_data_network"
- },
- "NatIpRange":{
- "type_name":"string",
- "value":"192.167.0.10-192.168.0.20"
- },
- "externalManageNetworkName":{
- "type_name":"string",
- "value":"vlan_4008_mng_net"
- },
- "externalPluginManageNetworkName":{
- "type_name":"string",
- "value":"vlan_4007_plugin_net"
- }
- }
- }
- }
- )
- print convert_nsd_model(src_json)
-
-
-
-
diff --git a/newton/newton/pub/utils/values.py b/newton/newton/pub/utils/values.py
deleted file mode 100644
index 808d977a..00000000
--- a/newton/newton/pub/utils/values.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (c) 2017-2018 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-def ignore_case_get(args, key, def_val=""):
- if not key:
- return def_val
- if key in args:
- return args[key]
- for old_key in args:
- if old_key.upper() == key.upper():
- return args[old_key]
- return def_val
-
diff --git a/newton/newton/registration/tests/test_registration.py b/newton/newton/registration/tests/test_registration.py
index 36b45f9f..78d75341 100644
--- a/newton/newton/registration/tests/test_registration.py
+++ b/newton/newton/registration/tests/test_registration.py
@@ -16,10 +16,10 @@ import mock
from rest_framework import status
-from newton.pub.utils import restcall
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.views.util import VimDriverUtils
+from common.utils import restcall
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.util import VimDriverUtils
MOCK_GET_TENANT_RESPONSE = {
"projects": [
diff --git a/newton/newton/registration/views/registration.py b/newton/newton/registration/views/registration.py
index 9b2f134d..69c85837 100644
--- a/newton/newton/registration/views/registration.py
+++ b/newton/newton/registration/views/registration.py
@@ -13,686 +13,18 @@
# limitations under the License.
import logging
-import json
-import traceback
-from keystoneauth1.exceptions import HttpError
-from rest_framework import status
-from rest_framework.response import Response
-from rest_framework.views import APIView
+from django.conf import settings
-from newton.pub.config import config
-from newton.pub.exceptions import VimDriverNewtonException
-from newton.pub.msapi import extsys
-from newton.pub.utils import restcall
-from newton.requests.views.util import VimDriverUtils
+from newton_base.registration import registration as newton_registration
logger = logging.getLogger(__name__)
+DEBUG=True
-class Registry(APIView):
+class Registry(newton_registration.Registry):
def __init__(self):
- self.proxy_prefix = config.MULTICLOUD_PREFIX
+ self.proxy_prefix = settings.MULTICLOUD_PREFIX
+ self.aai_base_url = settings.AAI_BASE_URL
self._logger = logger
-
- def _get_list_resources(
- self, resource_url, service_type, session, viminfo,
- vimid, content_key):
- service = {'service_type': service_type,
- 'interface': 'public',
- 'region_id': viminfo['cloud_region_id']}
- resp = session.get(resource_url, endpoint_filter=service)
- content = resp.json()
-
- self._logger.debug("vimid: %s, req: %s,resp code: %s, body: %s"
- % (vimid, resource_url, resp.status_code,content))
-
- if resp.status_code != status.HTTP_200_OK:
- return # failed to discover resources
- return content.get(content_key)
-
- def _update_resoure(self, cloud_owner, cloud_region_id,
- resoure_id, resource_info, resource_type):
- if cloud_owner and cloud_region_id:
- self._logger.debug(
- ("_update_resoure,vimid:%(cloud_owner)s"
- "_%(cloud_region_id)s req_to_aai: %(resoure_id)s, "
- "%(resource_type)s, %(resource_info)s")
- % {
- "cloud_owner": cloud_owner,
- "cloud_region_id": cloud_region_id,
- "resoure_id": resoure_id,
- "resource_type": resource_type,
- "resource_info": resource_info,
- })
-
- #get the resource first
- resource_url = ("/cloud-infrastructure/cloud-regions/"
- "cloud-region/%(cloud_owner)s/%(cloud_region_id)s/"
- "%(resource_type)ss/%(resource_type)s/%(resoure_id)s"
- % {
- "cloud_owner": cloud_owner,
- "cloud_region_id": cloud_region_id,
- "resoure_id": resoure_id,
- "resource_type": resource_type,
- })
-
- # get cloud-region
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "GET")
-
- # add resource-version
- if retcode == 0 and content:
- content = json.JSONDecoder().decode(content)
- #resource_info["resource-version"] = content["resource-version"]
- content.update(resource_info)
- resource_info = content
-
- #then update the resource
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "PUT", content=resource_info)
-
- self._logger.debug(
- ("_update_resoure,vimid:%(cloud_owner)s"
- "_%(cloud_region_id)s req_to_aai: %(resoure_id)s, "
- "return %(retcode)s, %(content)s, %(status_code)s")
- % {
- "cloud_owner": cloud_owner,
- "cloud_region_id": cloud_region_id,
- "resoure_id": resoure_id,
- "retcode": retcode,
- "content": content,
- "status_code": status_code,
- })
- return retcode
- return 1 # unknown cloud owner,region_id
-
- def _discover_tenants(self, vimid="", session=None, viminfo=None):
- try:
- # iterate all projects and populate them into AAI
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- for tenant in self._get_list_resources(
- "projects", "identity", session, viminfo, vimid,
- "projects"):
- tenant_info = {
- 'tenant-id': tenant['id'],
- 'tenant-name': tenant['name'],
- }
- self._update_resoure(
- cloud_owner, cloud_region_id, tenant['id'],
- tenant_info, "tenant")
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- def _discover_flavors(self, vimid="", session=None, viminfo=None):
- try:
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- for flavor in self._get_list_resources(
- "/flavors/detail", "compute", session, viminfo, vimid,
- "flavors"):
- flavor_info = {
- 'flavor-id': flavor['id'],
- 'flavor-name': flavor['name'],
- 'flavor-vcpus': flavor['vcpus'],
- 'flavor-ram': flavor['ram'],
- 'flavor-disk': flavor['disk'],
- 'flavor-ephemeral': flavor['OS-FLV-EXT-DATA:ephemeral'],
- 'flavor-swap': flavor['swap'],
- 'flavor-is-public': flavor['os-flavor-access:is_public'],
- 'flavor-disabled': flavor['OS-FLV-DISABLED:disabled'],
- }
-
- if flavor.get('link') and len(flavor['link']) > 0:
- flavor_info['flavor-selflink'] = flavor['link'][0]['href'] or 'http://0.0.0.0',
- else:
- flavor_info['flavor-selflink'] = 'http://0.0.0.0',
-
- self._update_resoure(
- cloud_owner, cloud_region_id, flavor['id'],
- flavor_info, "flavor")
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- # def update_image_metadata(self, cloud_owner, cloud_region_id, image_id, metadatainfo):
- # '''
- # populate image meta data
- # :param cloud_owner:
- # :param cloud_region_id:
- # :param image_id:
- # :param metadatainfo:
- # metaname: string
- # metaval: string
- # :return:
- # '''
- #
- # if cloud_owner and cloud_region_id:
- # retcode, content, status_code = \
- # restcall.req_to_aai(
- # "/cloud-infrastructure/cloud-regions/cloud-region"
- # + "/%s/%s/images/image/%s/metadata/metadatum/%s"
- # % (cloud_owner, cloud_region_id, image_id, metadatainfo['metaname']),
- # "PUT", content=metadatainfo)
- #
- # self._logger.debug("update_image,vimid:%s_%s req_to_aai: %s/%s, return %s, %s, %s"
- # % (cloud_owner,cloud_region_id,image_id,metadatainfo['metaname'],
- # retcode, content, status_code))
- # return retcode
- # return 1
-
- def _discover_images(self, vimid="", session=None, viminfo=None):
- try:
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- for image in self._get_list_resources(
- "/v2/images", "image", session, viminfo, vimid,
- "images"):
- image_info = {
- 'image-id': image['id'],
- 'image-name': image['name'],
- 'image-selflink': image['self'],
-
- 'image-os-distro': image.get('os_distro') or 'Unknown',
- 'image-os-version': image.get('os_version') or 'Unknown',
- 'application': image.get('application'),
- 'application-vendor': image.get('application_vendor'),
- 'application-version': image.get('application_version'),
- 'image-architecture': image.get('architecture'),
- }
-
- ret = self._update_resoure(
- cloud_owner, cloud_region_id, image['id'], image_info,
- "image")
- if ret != 0:
- # failed to update image
- self._logger.debug("failed to populate image info into AAI: %s, image id: %s, ret:%s"
- % (vimid, image_info['image-id'], ret))
- continue
-
- schema = image['schema']
- if schema:
- req_resource = schema
- service = {'service_type': "image",
- 'interface': 'public',
- 'region_id': viminfo['cloud_region_id']}
- resp = session.get(req_resource, endpoint_filter=service)
- content = resp.json()
-
- self._logger.debug("vimid: %s, req: %s,resp code: %s, body: %s"
- % (vimid, req_resource, resp.status_code, content))
- # if resp.status_code == status.HTTP_200_OK:
- # parse the schema? TBD
- # self.update_image(cloud_owner, cloud_region_id, image_info)
- #metadata_info = {}
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- def _discover_availability_zones(self, vimid="", session=None,
- viminfo=None):
- try:
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- for az in self._get_list_resources(
- "/os-availability-zone/detail", "compute", session,
- viminfo, vimid,
- "availabilityZoneInfo"):
- az_info = {
- 'availability-zone-name': az['zoneName'],
- 'operational-status': az['zoneState']['available']
- if az.get('zoneState') else '',
- 'hypervisor-type': '',
- }
- if az.get('hosts'):
- for (k, v) in az['hosts'].items():
- req_resource = "/os-hypervisors/detail?hypervisor_hostname_pattern=%s" % k
- service = {'service_type': "compute",
- 'interface': 'public',
- 'region_id': viminfo['cloud_region_id']}
- resp = session.get(req_resource, endpoint_filter=service)
- content = resp.json()
- self._logger.debug("vimid: %s, req: %s,resp code: %s, body: %s"
- % (vimid, req_resource, resp.status_code, content))
- if resp.status_code != status.HTTP_200_OK and not content[0]:
- continue
- az_info['hypervisor-type'] = content['hypervisors'][0]['hypervisor_type']\
- if len(content.get('hypervisors')) else ''
-
- break
- ret = self._update_resoure(
- cloud_owner, cloud_region_id, az['zoneName'], az_info,
- "availability-zone")
- if ret != 0:
- # failed to update image
- self._logger.debug("failed to populate az info into AAI: %s, az name: %s, ret:%s"
- % (vimid, az_info['availability-zone-name'], ret))
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- # def _discover_volumegroups(self, vimid="", session=None, viminfo=None):
- # cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- # for cg in self._get_list_resources(
- # "/consistencygroups/detail", "volumev3", session,
- # viminfo, vimid,
- # "consistencygroups"):
- # vg_info = {
- # 'volume-group-id': cg['id'],
- # 'volume-group-name': cg['name'],
- # 'vnf-type': '',
- # }
- #
- # ret = self._update_resoure(
- # cloud_owner, cloud_region_id, cg['id'], vg_info,
- # "volume-group")
- # if ret != 0:
- # # failed to update image
- # self._logger.debug("failed to populate volumegroup info into AAI: %s, volume-group-id: %s, ret:%s"
- # % (vimid, vg_info['volume-group-id'], ret))
-
- def _discover_snapshots(self, vimid="", session=None, viminfo=None):
- try:
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- for ss in self._get_list_resources(
- "/snapshots/detail", "volumev3", session,
- viminfo, vimid,
- "snapshots"):
- snapshot_info = {
- 'snapshot-id': ss['id'],
- 'snapshot-name': ss['name'],
- }
- if ss.get('metadata'):
- snapshot_info['snapshot-architecture'] = ss['metadata'].get('architecture')
- snapshot_info['application'] = ss['metadata'].get('architecture')
- snapshot_info['snapshot-os-distro'] = ss['metadata'].get('os-distro')
- snapshot_info['snapshot-os-version'] = ss['metadata'].get('os-version')
- snapshot_info['application-vendor'] = ss['metadata'].get('vendor')
- snapshot_info['application-version'] = ss['metadata'].get('version')
- snapshot_info['snapshot-selflink'] = ss['metadata'].get('selflink')
- snapshot_info['prev-snapshot-id'] = ss['metadata'].get('prev-snapshot-id')
-
- ret = self._update_resoure(
- cloud_owner, cloud_region_id, ss['id'], snapshot_info,
- "snapshot")
- if ret != 0:
- # failed to update image
- self._logger.debug("failed to populate snapshot info into AAI: %s, snapshot-id: %s, ret:%s"
- % (vimid, snapshot_info['snapshot-id'], ret))
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- # def _discover_servergroups(self, vimid="", session=None, viminfo=None):
- # for sg in self._get_list_resources(
- # "/os-server-groups", "compute", session,
- # viminfo, vimid,
- # "security groups"):
-
- def _update_pserver(self, cloud_owner, cloud_region_id, pserverinfo):
- '''
- populate pserver into AAI
- :param cloud_owner:
- :param cloud_region_id:
- :param pserverinfo:
- hostname: string
- in-maint: boolean
-
- pserver-name2: string
- pserver-id: string
- ptnii-equip-name: string
- number-of-cpus: integer
- disk-in-gigabytes: integer
- ram-in-megabytes: integer
- equip-type: string
- equip-vendor: string
- equip-model: string
- fqdn: string
- pserver-selflink: string
- ipv4-oam-address: string
- serial-number: string
- ipaddress-v4-loopback-0: string
- ipaddress-v6-loopback-0: string
- ipaddress-v4-aim: string
- ipaddress-v6-aim: string
- ipaddress-v6-oam: string
- inv-status: string
- internet-topology: string
- purpose: string
- prov-status: string
- management-option: string
- host-profile: string
-
- :return:
- '''
-
- if cloud_owner and cloud_region_id:
- resource_url = "/cloud-infrastructure/pservers/pserver/%s" \
- % (pserverinfo['hostname'])
-
- # get cloud-region
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "GET")
-
- # add resource-version to url
- if retcode == 0 and content:
- content = json.JSONDecoder().decode(content)
- #pserverinfo["resource-version"] = content["resource-version"]
- content.update(pserverinfo)
- pserverinfo = content
-
-
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "PUT", content=pserverinfo)
-
- self._logger.debug("update_snapshot,vimid:%s_%s req_to_aai: %s, return %s, %s, %s"
- % (cloud_owner,cloud_region_id, pserverinfo['hostname'], retcode, content, status_code))
-
- if retcode == 0:
- # relationship to cloud-region
-
- related_link = ("%s/cloud-infrastructure/cloud-regions/"
- "cloud-region/%s/%s" % (
- config.AAI_BASE_URL, cloud_owner,
- cloud_region_id))
-
- relationship_data = \
- {
- 'related-to': 'cloud-region',
- 'related-link': related_link,
- 'relationship-data': [
- {
- 'relationship-key': 'cloud-region.cloud-owner',
- 'relationship-value': cloud_owner
- },
- {
- 'relationship-key': 'cloud-region.cloud-region-id',
- 'relationship-value': cloud_region_id
- }
- ],
- "related-to-property": [
- {
- "property-key": "cloud-region.cloud-owner"
- },
- {
- "property-key": "cloud-region.cloud-region-id"
- }
- ]
- }
-
- retcode, content, status_code = \
- restcall.req_to_aai("/cloud-infrastructure/pservers/pserver/%s/relationship-list/relationship"
- % (pserverinfo['hostname']), "PUT", content=relationship_data)
-
- self._logger.debug("update_pserver,vimid:%s_%s req_to_aai: %s, return %s, %s, %s"
- % (cloud_owner, cloud_region_id, pserverinfo['hostname'], retcode, content,
- status_code))
-
- return retcode
- return 1 # unknown cloud owner,region_id
-
- def _discover_pservers(self, vimid="", session=None, viminfo=None):
- try:
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- for hypervisor in self._get_list_resources(
- "/os-hypervisors/detail", "compute", session,
- viminfo, vimid,
- "hypervisors"):
- hypervisor_info = {
- 'hostname': hypervisor['hypervisor_hostname'],
- 'in-maint': hypervisor['state'],
-
- 'pserver-id': hypervisor.get('id'),
- 'ptnii-equip-name': hypervisor.get('id'),
- 'disk-in-gigabytes': hypervisor.get('local_gb'),
- 'ram-in-megabytes': hypervisor.get('memory_mb'),
- 'pserver-selflink': hypervisor.get('hypervisor_links'),
- 'ipv4-oam-address': hypervisor.get('host_ip'),
- }
-
- # if hypervisor.get('cpu_info') and hypervisor['cpu_info'].get('topology'):
- # cputopo = hypervisor['cpu_info'].get('topology')
- # n_cpus = cputopo['cores'] * cputopo['threads'] * cputopo['sockets']
- # hypervisor_info['number-of-cpus'] = n_cpus
- if hypervisor.get('cpu_info'):
- cpu_info = json.loads(hypervisor['cpu_info'])
- if cpu_info.get('topology'):
- cputopo = cpu_info.get('topology')
- n_cpus = cputopo['cores'] * cputopo['threads'] * cputopo['sockets']
- hypervisor_info['number-of-cpus'] = n_cpus
-
- ret = self._update_pserver(cloud_owner, cloud_region_id,
- hypervisor_info)
- if ret != 0:
- # failed to update image
- self._logger.debug("failed to populate pserver info into AAI: %s, hostname: %s, ret:%s"
- % (vimid, hypervisor_info['hostname'], ret))
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- def _update_epa_caps(self, cloud_owner, cloud_region_id, epa_caps_info):
- '''
- populate cloud EPA Capabilities information into AAI
- :param cloud_owner:
- :param cloud_region_id:
- :param epa_caps_info: dict of meta data about cloud-region's epa caps
-
- :return:
- '''
-
- cloud_epa_caps = {
- 'cloud-epa-caps': json.dumps(epa_caps_info),
- }
-
- if cloud_owner and cloud_region_id:
- resource_url = "/cloud-infrastructure/cloud-regions/cloud-region/%s/%s" \
- % (cloud_owner, cloud_region_id)
-
- # get cloud-region
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "GET")
-
- #add resource-version to url
- if retcode == 0 and content:
- content = json.JSONDecoder().decode(content)
- #cloud_epa_caps["resource-version"] = content["resource-version"]
- content.update(cloud_epa_caps)
- cloud_epa_caps = content
-
- #update cloud-region
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "PUT", content=cloud_epa_caps)
-
- self._logger.debug(
- "update_epa_caps,vimid:%s_%s req_to_aai: update cloud-epa-caps, return %s, %s, %s"
- % (cloud_owner,cloud_region_id, retcode, content, status_code))
-
- return retcode
- return 1 # unknown cloud owner,region_id
-
- def _discover_epa_resources(self, vimid="", viminfo=None):
- try:
- cloud_epa_caps_info = {}
- cloud_extra_info_str = viminfo.get('cloud_extra_info')
- if cloud_extra_info_str:
- cloud_extra_info = json.loads(cloud_extra_info_str)
- cloud_epa_caps_info.update(cloud_extra_info.get("epa-caps"))
-
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- ret = self._update_epa_caps(cloud_owner, cloud_region_id,
- cloud_epa_caps_info)
- if ret != 0:
- # failed to update image
- self._logger.debug("failed to populate EPA CAPs info into AAI: %s, ret:%s"
- % (vimid, ret))
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- def _update_proxy_identity_endpoint(self, vimid):
- '''
- update cloud_region's identity url
- :param cloud_owner:
- :param cloud_region_id:
- :param url:
- :return:
- '''
- try:
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- if cloud_owner and cloud_region_id:
- resource_url = "/cloud-infrastructure/cloud-regions/cloud-region/%s/%s" \
- % (cloud_owner, cloud_region_id)
-
- # get cloud-region
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "GET")
-
- # add resource-version to url
- if retcode == 0 and content:
- viminfo = json.JSONDecoder().decode(content)
- # cloud_epa_caps["resource-version"] = content["resource-version"]
- viminfo['identity-url'] = self.proxy_prefix + "/%s/identity/v2.0" % vimid
-
- retcode, content, status_code = \
- restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s"
- % (cloud_owner, cloud_region_id), "PUT", content=viminfo)
-
- self._logger.debug("update_proxy_identity_endpoint,vimid:%s req_to_aai: %s, return %s, %s, %s"
- % (vimid, viminfo['identity-url'], retcode, content, status_code))
- else:
- self._logger.debug("failure: update_proxy_identity_endpoint,vimid:%s req_to_aai: return %s, %s, %s"
- % (vimid, retcode, content, status_code))
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
- def post(self, request, vimid=""):
- self._logger.debug("Registration--post::data> %s" % request.data)
- self._logger.debug("Registration--post::vimid > %s" % vimid)
-
- try:
- # populate proxy identity url
- self._update_proxy_identity_endpoint(vimid)
-
- # prepare request resource to vim instance
- # get token:
- viminfo = VimDriverUtils.get_vim_info(vimid)
- if not viminfo:
- raise VimDriverNewtonException(
- "There is no cloud-region with {cloud-owner}_{cloud-region-id}=%s in AAI" % vimid)
-
- # set the default tenant since there is no tenant info in the VIM yet
- sess = VimDriverUtils.get_session(
- viminfo, tenant_name=viminfo['tenant'])
-
- # step 1. discover all projects and populate into AAI
- self._discover_tenants(vimid, sess, viminfo)
-
- # discover all flavors
- self._discover_flavors(vimid, sess, viminfo)
-
- # discover all images
- self._discover_images(vimid, sess, viminfo)
-
- # discover all az
- self._discover_availability_zones(vimid, sess, viminfo)
-
- # discover all vg
- #self._discover_volumegroups(vimid, sess, viminfo)
-
- # discover all snapshots
- self._discover_snapshots(vimid, sess, viminfo)
-
- # discover all server groups
- #self.discover_servergroups(request, vimid, sess, viminfo)
-
- # discover all pservers
- self._discover_pservers(vimid, sess, viminfo)
-
- # discover all epa resources, e.g. sriov pf and vf, etc.
- self._discover_epa_resources(vimid, viminfo)
-
- return Response(status=status.HTTP_202_ACCEPTED)
-
- except VimDriverNewtonException as e:
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return Response(
- data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
- def delete(self, request, vimid=""):
- self._logger.debug("Registration--delete::data> %s" % request.data)
- self._logger.debug("Registration--delete::vimid > %s"% vimid)
- try:
- ret_code = VimDriverUtils.delete_vim_info(vimid)
- return Response(status=status.HTTP_202_ACCEPTED if ret_code==0 else status.HTTP_500_INTERNAL_SERVER_ERROR)
- except VimDriverNewtonException as e:
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/newton/newton/requests/tests/mock_info.py b/newton/newton/requests/tests/mock_info.py
deleted file mode 100644
index 0c7556ee..00000000
--- a/newton/newton/requests/tests/mock_info.py
+++ /dev/null
@@ -1,568 +0,0 @@
-# Copyright (c) 2017 Intel Corporation, 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from django.conf import settings
-
-MOCK_VIM_INFO = {
- "createTime": "2017-04-01 02:22:27",
- "domain": "Default",
- "name": "TiS_R4",
- "password": "admin",
- "tenant": "admin",
- "type": "openstack",
- "url": "http://128.224.180.14:5000/v3",
- "userName": "admin",
- "vendor": "WindRiver",
- "version": "newton",
- "vimId": "windriver-hudson-dc_RegionOne",
- 'cloud_owner': 'windriver-hudson-dc',
- 'cloud_region_id': 'RegionOne',
- 'cloud_extra_info': '',
- 'cloud_epa_caps':
- '{'
- '"huge_page":"true",'
- '"cpu_pinning":"true",'
- '"cpu_thread_policy":"true",'
- '"numa_aware":"true",'
- '"sriov":"true",'
- '"dpdk_vswitch":"true",'
- '"rdt":"false",'
- '"numa_locality_pci":"true"'
- '}',
- 'insecure': 'True',
-}
-
-MOCK_TOKEN_ID = "1a62b3971d774404a504c5d9a3e506e3"
-
-MOCK_CATALOG_RESPONSE = {
- "catalog": [
- {
- "id": "99aefcc82a9246f98f8c281e61ffc754",
- "endpoints": [
- {
- "region": "RegionOne",
- "url": "http://128.224.180.14:9696",
- "id": "39583c1508ad4b71b380570a745ee10a",
- "interface": "public",
- "region_id": "RegionOne"
- },
- {
- "url": "http://192.168.204.2:9696",
- "region": "RegionOne",
- "id": "37e8d07ba24e4b8f93490c9daaba06e2",
- "interface": "internal",
- "region_id": "RegionOne"
- },
- {
- "interface": "admin",
- "id": "7eee4ca98d444b1abb00a50d4b89373f",
- "region_id": "RegionOne",
- "region": "RegionOne",
- "url": "http://192.168.204.2:9696"
- }
- ],
- "name": "neutron",
- "type": "network"
- },
- {
- "endpoints": [
- {
- "interface": "public",
- "id": "10496738fa374295a4a88a63b81a1589",
- "region_id": "RegionOne",
- "url": "http://128.224.180.14:8777",
- "region": "RegionOne"
- },
- {
- "id": "02dcb8c0bd464c4489fa0a0c9f28571f",
- "region_id": "RegionOne",
- "interface": "internal",
- "url": "http://192.168.204.2:8777",
- "region": "RegionOne"
- },
- {
- "region_id": "RegionOne",
- "id": "8a73b0d3743b4e78b87614690f6e97fe",
- "interface": "admin",
- "url": "http://192.168.204.2:8777",
- "region": "RegionOne"
- }
- ],
- "id": "d131054da83f4c93833799747a0f4709",
- "name": "ceilometer",
- "type": "metering"
- },
- {
- "type": "volumev2",
- "name": "cinderv2",
- "endpoints": [
- {
- "id": "35a67ad36f0447d19c9662babf7cf609",
- "interface": "public",
- "region_id": "RegionOne",
- "url": "http://128.224.180.14:8776/v2/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8776/v2/fcca3cc49d5e42caae15459e27103efc",
- "id": "c6ea42052268420fa2c8d351ee68c922",
- "interface": "internal",
- "region_id": "RegionOne"
- },
- {
- "region_id": "RegionOne",
- "id": "91cb24853dc3450d847b0c286a2e44ea",
- "interface": "admin",
- "region": "RegionOne",
- "url": "http://192.168.204.2:8776/v2/fcca3cc49d5e42caae15459e27103efc"
- }
- ],
- "id": "40440057102440739c30be10a66bc5d1"
- },
- {
- "name": "heat",
- "type": "orchestration",
- "id": "35300cce88db4bd4bb5a72ffe3b88b00",
- "endpoints": [
- {
- "id": "58999d7b4a94439089ecfb2aca2d7f6c",
- "region_id": "RegionOne",
- "interface": "public",
- "region": "RegionOne",
- "url": "http://128.224.180.14:8004/v1/fcca3cc49d5e42caae15459e27103efc"
- },
- {
- "url": "http://192.168.204.2:8004/v1/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne",
- "interface": "internal",
- "id": "1e0ee1a2aef84802b921d422372a567e",
- "region_id": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8004/v1/fcca3cc49d5e42caae15459e27103efc",
- "id": "17661bf4859741b8a43a461dedad1871",
- "region_id": "RegionOne",
- "interface": "admin"
- }
- ]
- },
- {
- "id": "08dc6912aea64c01925012c8a6df250a",
- "endpoints": [
- {
- "id": "02792c4eed77486083f9b2e52d7b94b0",
- "region_id": "RegionOne",
- "interface": "public",
- "region": "RegionOne",
- "url": "http://128.224.180.14:5000/v3"
- },
- {
- "id": "b6d5cad394b94309ae40d8de88059c5f",
- "region_id": "RegionOne",
- "interface": "internal",
- "url": "http://192.168.204.2:5000/v3",
- "region": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:35357/v3",
- "region_id": "RegionOne",
- "id": "1f18e2b7c6a34493b86853b65917888e",
- "interface": "admin"
- }
- ],
- "type": "identity",
- "name": "keystone"
- },
- {
- "name": "vim",
- "type": "nfv",
- "endpoints": [
- {
- "url": "http://128.224.180.14:4545",
- "region": "RegionOne",
- "id": "b33e317345e4480ab0786e4960995ec9",
- "interface": "public",
- "region_id": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:4545",
- "interface": "internal",
- "id": "03c85828d5bf432ab04831aa65ac9c52",
- "region_id": "RegionOne"
- },
- {
- "id": "067983abb061476cb53a9e23a740d98f",
- "region_id": "RegionOne",
- "interface": "admin",
- "url": "http://192.168.204.2:4545",
- "region": "RegionOne"
- }
- ],
- "id": "01636c856fc84988b38b9117eb4a8021"
- },
- {
- "name": "aodh",
- "type": "alarming",
- "id": "eb269151d0e44744a5b5449657bdc61c",
- "endpoints": [
- {
- "id": "5bfc6c056e0244c493642eb82f6aaa11",
- "region_id": "RegionOne",
- "interface": "public",
- "url": "http://128.224.180.14:8042",
- "region": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8042",
- "region_id": "RegionOne",
- "id": "ad69c7f76dce4089a195b9221ddbfb44",
- "interface": "internal"
- },
- {
- "interface": "admin",
- "id": "3e8fcdfa7bcb40b0ae33c282adfcc9ff",
- "region_id": "RegionOne",
- "region": "RegionOne",
- "url": "http://192.168.204.2:8042"
- }
- ]
- },
- {
- "name": "sysinv",
- "type": "platform",
- "endpoints": [
- {
- "region": "RegionOne",
- "url": "http://128.224.180.14:6385/v1",
- "interface": "public",
- "id": "ba4ba8104590421b84672306c7e0e1f1",
- "region_id": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:6385/v1",
- "interface": "internal",
- "id": "a1cba34b163f496ab1acd6e9b51e39a2",
- "region_id": "RegionOne"
- },
- {
- "url": "http://192.168.204.2:6385/v1",
- "region": "RegionOne",
- "id": "7c171210a2c841a6a52a5713e316d6fc",
- "interface": "admin",
- "region_id": "RegionOne"
- }
- ],
- "id": "256bbad671f946fea543e6bd71f98875"
- },
- {
- "id": "e84665dcce814c05b4c5084964547534",
- "endpoints": [
- {
- "url": "http://128.224.180.14:8000/v1/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne",
- "region_id": "RegionOne",
- "id": "b2ed1a23dc6944bea129c20861e0286a",
- "interface": "public"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8000/v1/fcca3cc49d5e42caae15459e27103efc",
- "interface": "internal",
- "id": "c4df7c6bc15646848eff35caf6ffea8e",
- "region_id": "RegionOne"
- },
- {
- "region_id": "RegionOne",
- "id": "61b3dabb761443a89ab549f437c05ab0",
- "interface": "admin",
- "region": "RegionOne",
- "url": "http://192.168.204.2:8000/v1/fcca3cc49d5e42caae15459e27103efc"
- }
- ],
- "name": "heat-cfn",
- "type": "cloudformation"
- },
- {
- "id": "823024424a014981a3721229491c0b1a",
- "endpoints": [
- {
- "region": "RegionOne",
- "url": "http://128.224.180.14:8776/v1/fcca3cc49d5e42caae15459e27103efc",
- "region_id": "RegionOne",
- "id": "4a52e4e54ff440789f9a797919c4a0f2",
- "interface": "public"
- },
- {
- "url": "http://192.168.204.2:8776/v1/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne",
- "id": "d4f9a84476524a39844f0fce63f1022e",
- "region_id": "RegionOne",
- "interface": "internal"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8776/v1/fcca3cc49d5e42caae15459e27103efc",
- "interface": "admin",
- "id": "81bf3810a8cc4697b68c6e93b5b8fe1f",
- "region_id": "RegionOne"
- }
- ],
- "type": "volume",
- "name": "cinder"
- },
- {
- "name": "glance",
- "type": "image",
- "endpoints": [
- {
- "id": "bd930aba961946cfb1401bada56d55e3",
- "region_id": "RegionOne",
- "interface": "public",
- "region": "RegionOne",
- "url": "http://128.224.180.14:9292"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:9292",
- "id": "c11da585f0b141b99d1e18bb9a607beb",
- "region_id": "RegionOne",
- "interface": "internal"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:9292",
- "id": "31b26c625a6a4fc7910dc5935155996e",
- "interface": "admin",
- "region_id": "RegionOne"
- }
- ],
- "id": "3b78cf039bc54d1bbb99ab3a4be15ef1"
- },
- {
- "id": "b8701374bf254de1beee8a2c9ecc6b33",
- "endpoints": [
- {
- "region_id": "RegionOne",
- "id": "f7407f330c8b4577b1d377d3fab9c2f8",
- "interface": "public",
- "region": "RegionOne",
- "url": "http://128.224.180.14:15491"
- },
- {
- "url": "http://192.168.204.2:5491",
- "region": "RegionOne",
- "interface": "internal",
- "id": "0b37ce31a32f4b6fa5e1aa0d6c20680f",
- "region_id": "RegionOne"
- },
- {
- "region_id": "RegionOne",
- "id": "7b87ea72adf245e1991e9e0df29b7ea9",
- "interface": "admin",
- "region": "RegionOne",
- "url": "http://192.168.204.2:5491"
- }
- ],
- "type": "patching",
- "name": "patching"
- },
- {
- "id": "0ec0923a58f04ffeb6fced3bbc5c0947",
- "endpoints": [
- {
- "url": "http://128.224.180.14:8774/v2.1/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne",
- "id": "13168b12da17451fb39630de67db168f",
- "region_id": "RegionOne",
- "interface": "public"
- },
- {
- "id": "22dd6a44209f42d986b82e3aa6535f82",
- "interface": "internal",
- "region_id": "RegionOne",
- "region": "RegionOne",
- "url": "http://192.168.204.2:8774/v2.1/fcca3cc49d5e42caae15459e27103efc"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8774/v2.1/fcca3cc49d5e42caae15459e27103efc",
- "id": "552a991ae501492f841c1b6e2ff38fc5",
- "region_id": "RegionOne",
- "interface": "admin"
- }
- ],
- "type": "compute",
- "name": "nova"
- },
- {
- "id": "50b219650f1049b097b3f14e8c70cdf8",
- "endpoints": [
- {
- "interface": "public",
- "id": "5a4276cd6e4d43e883cf8640d4e13f7d",
- "region_id": "RegionOne",
- "region": "RegionOne",
- "url": "http://128.224.180.14:8776/v3/fcca3cc49d5e42caae15459e27103efc"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8776/v3/fcca3cc49d5e42caae15459e27103efc",
- "region_id": "RegionOne",
- "id": "c796df3ca5a84fc18db5b43a55283953",
- "interface": "internal"
- },
- {
- "region_id": "RegionOne",
- "id": "cf55c2b34d0049ba835a2e48b9ad0e2e",
- "interface": "admin",
- "url": "http://192.168.204.2:8776/v3/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne"
- }
- ],
- "type": "volumev3",
- "name": "cinderv3"
- }
- ]
-}
-
-MOCK_AUTH_STATE = {
- "body": {
- "token": {
- "is_domain": "false",
- "expires_at": "2017-08-27T14:19:15.000000Z",
- "issued_at": "2017-08-27T13:19:15.000000Z",
- "roles": [
- {
- "id": "9fe2ff9ee4384b1894a90878d3e92bab",
- "name": "_member_"
- },
- {
- "id": "b86a7e02935844b899d3d326f83c1b1f",
- "name": "admin"
- },
- {
- "name": "heat_stack_owner",
- "id": "7de502236e954c8282de32e773fc052e"
- }
- ],
- "methods": [
- "password"
- ],
- "catalog": MOCK_CATALOG_RESPONSE['catalog'],
- "project": {
- "name": "admin",
- "id": "fcca3cc49d5e42caae15459e27103efc",
- "domain": {
- "id": "default",
- "name": "Default"
- }
- },
- "user": {
- "name": "admin",
- "id": "9efb043c7629497a8028d7325ca1afb0",
- "domain": {
- "id": "default",
- "name": "Default"
- }
- },
- "audit_ids": [
- "_ZWT10DtSZKRXIvIcxun7w"
- ]
- }
- },
- "auth_token": MOCK_TOKEN_ID
-}
-
-BASE_URL = ("http://172.16.77.20:9003/api/%s/v0/"
- "windriver-hudson-dc_RegionOne/"
- % settings.MULTIVIM_VERSION)
-
-MOCK_INTERNAL_METADATA_CATALOG = {
- "identity": {
- "proxy_prefix": BASE_URL + "identity",
- "prefix": "http://128.224.180.14:5000",
- "suffix": "v3"
- },
- "patching": {
- "proxy_prefix": BASE_URL + "patching",
- "suffix": "",
- "prefix": "http://128.224.180.14:15491"
- },
- "orchestration": {
- "suffix": "v1/fcca3cc49d5e42caae15459e27103efc",
- "prefix": "http://128.224.180.14:8004",
- "proxy_prefix": BASE_URL + "orchestration"
- },
- "volume": {
- "prefix": "http://128.224.180.14:8776",
- "suffix": "v1/fcca3cc49d5e42caae15459e27103efc",
- "proxy_prefix": BASE_URL + "volume"
- },
- "metering": {
- "suffix": "",
- "prefix": "http://128.224.180.14:8777",
- "proxy_prefix": BASE_URL + "metering"
- },
- "volumev3": {
- "prefix": "http://128.224.180.14:8776",
- "suffix": "v3/fcca3cc49d5e42caae15459e27103efc",
- "proxy_prefix": BASE_URL + "volumev3"
- },
- "compute": {
- "suffix": "v2.1/fcca3cc49d5e42caae15459e27103efc",
- "prefix": "http://128.224.180.14:8774",
- "proxy_prefix": BASE_URL + "compute"
- },
- "platform": {
- "prefix": "http://128.224.180.14:6385",
- "suffix": "v1",
- "proxy_prefix": BASE_URL + "platform"
- },
- "nfv": {
- "proxy_prefix": BASE_URL + "nfv",
- "prefix": "http://128.224.180.14:4545",
- "suffix": ""
- },
- "volumev2": {
- "proxy_prefix": BASE_URL + "volumev2",
- "suffix": "v2/fcca3cc49d5e42caae15459e27103efc",
- "prefix": "http://128.224.180.14:8776"
- },
- "image": {
- "suffix": "",
- "prefix": "http://128.224.180.14:9292",
- "proxy_prefix": BASE_URL + "image"
- },
- "network": {
- "proxy_prefix": BASE_URL + "network",
- "prefix": "http://128.224.180.14:9696",
- "suffix": ""
- },
- "alarming": {
- "suffix": "",
- "prefix": "http://128.224.180.14:8042",
- "proxy_prefix": BASE_URL + "alarming"
- },
- "cloudformation": {
- "proxy_prefix": BASE_URL + "cloudformation",
- "prefix": "http://128.224.180.14:8000",
- "suffix": "v1/fcca3cc49d5e42caae15459e27103efc"
- }
-}
diff --git a/newton/newton/requests/tests/test_base.py b/newton/newton/requests/tests/test_base.py
deleted file mode 100644
index 4db0cf64..00000000
--- a/newton/newton/requests/tests/test_base.py
+++ /dev/null
@@ -1,252 +0,0 @@
-# Copyright (c) 2017 Intel Corporation, 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import mock
-from rest_framework import status
-import unittest
-
-from abc import ABCMeta
-from django.conf import settings
-from django.test import Client
-
-from newton.requests.tests import mock_info
-from newton.requests.views.util import VimDriverUtils
-
-MULTIVIM_VERSION = settings.MULTIVIM_VERSION
-
-
-class MockResponse(object):
- status_code = status.HTTP_200_OK
- content = ''
-
- def json(self):
- pass
-
-
-def get_mock_session(http_actions, response_dict={}):
- mock_session = mock.Mock(
- name='mock_session',spec=http_actions)
- for action in http_actions:
- side_effect = response_dict.get("side_effect")
- if side_effect and isinstance(side_effect, list):
- mock_session.__getattr__(action).__setattr__(
- "side_effect", side_effect)
- else:
- mock_response_obj = mock.Mock(spec=MockResponse)
- mock_response_obj.content = response_dict.get(
- action).get("content")
- mock_response_obj.json.return_value = response_dict.get(
- action).get("content")
- mock_response_obj.status_code = response_dict.get(
- action).get("status_code", status.HTTP_200_OK)
- mock_session.__getattr__(action).__setattr__(
- "return_value", mock_response_obj)
-
- return mock_session
-
-
-class TestRequest(unittest.TestCase):
-
- def setUp(self):
- self.client = Client()
-
-
-class AbstractTestResource(object):
- __metaclass__ = ABCMeta
-
- def __init__(self):
-
- self.client = Client()
-
- self.region = "windriver-hudson-dc_RegionOne"
- self.url = ("/api/%s/v0/%s/"
- "fcca3cc49d5e42caae15459e27103efc/" % (
- MULTIVIM_VERSION, self.region))
-
- self.MOCK_GET_RESOURCES_RESPONSE = {}
- self.MOCK_GET_RESOURCE_RESPONSE = {}
- self.MOCK_GET_RESOURCE_RESPONSE_NOT_FOUND = {}
-
- self.MOCK_POST_RESOURCE_REQUEST = {}
- self.MOCK_POST_RESOURCE_REQUEST_EXISTING = {}
-
- self.MOCK_POST_RESOURCE_RESPONSE = {}
-
- self.assert_keys = ""
- self.assert_key = ""
-
- self.HTTP_not_found = status.HTTP_404_NOT_FOUND
-
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_get_resources_list(
- self, mock_get_vim_info, mock_get_session):
- mock_get_session.side_effect = [
- get_mock_session(
- ["get"], {"get": {
- "content": self.MOCK_GET_RESOURCES_RESPONSE}}),
- ]
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
-
- response = self.client.get(
- self.url, {}, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
-
- context = response.json()
- self.assertEquals(status.HTTP_200_OK, response.status_code)
- self.assertIsNotNone(context[self.assert_keys])
- self.assertEqual(
- self.MOCK_GET_RESOURCES_RESPONSE[self.assert_keys],
- context[self.assert_keys])
-
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_get_resource_info(
- self, mock_get_vim_info, mock_get_session):
- mock_get_session.side_effect = [
- get_mock_session(
- ["get"], {"get": {
- "content": self.MOCK_GET_RESOURCE_RESPONSE}}),
- ]
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
-
- response = self.client.get(
- self.url + "/uuid_1", {},
- HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
-
- context = response.json()
- self.assertEquals(status.HTTP_200_OK, response.status_code)
- self.assertEquals(
- self.MOCK_GET_RESOURCE_RESPONSE[self.assert_key],
- context[self.assert_key])
-
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_get_resource_not_found(
- self, mock_get_vim_info, mock_get_session):
- mock_get_session.side_effect = [
- get_mock_session(
- ["get"], {
- "get": {
- "content": self.MOCK_GET_RESOURCE_RESPONSE_NOT_FOUND,
- "status_code": 404
- }
- }
- ),
- ]
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
-
- response = self.client.get(
- self.url + "/uuid_3", {},
- HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
-
- self.assertEquals(self.HTTP_not_found, response.status_code)
-
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_post_resource(self, mock_get_vim_info, mock_get_session):
- mock_get_session.side_effect = [
- get_mock_session(
- ["get"], {"get": {
- "content": self.MOCK_GET_RESOURCES_RESPONSE}}),
- get_mock_session(
- ["post"], {"post": {
- "content": self.MOCK_POST_RESOURCE_RESPONSE,
- "status_code": 202}}),
- ]
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
-
- response = self.client.post(
- self.url, self.MOCK_POST_RESOURCE_REQUEST,
- HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
-
- context = response.json()
- self.assertEquals(status.HTTP_202_ACCEPTED,
- response.status_code)
- self.assertIsNotNone(context['id'])
- self.assertEqual(1, context['returnCode'])
-
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_post_resource_existing(
- self, mock_get_vim_info, mock_get_session):
- mock_get_session.side_effect = [
- get_mock_session(
- ["get"], {"get": {
- "content": self.MOCK_GET_RESOURCES_RESPONSE}}),
- get_mock_session(
- ["post"], {"post": {
- "content": self.MOCK_POST_RESOURCE_RESPONSE,
- "status_code": 201}}),
- ]
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
-
- response = self.client.post(
- self.url, self.MOCK_POST_RESOURCE_REQUEST_EXISTING,
- HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
-
- context = response.json()
- self.assertEquals(status.HTTP_200_OK, response.status_code)
- self.assertIsNotNone(context['returnCode'])
- self.assertEqual(0, context['returnCode'])
-
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_post_resource_empty(
- self, mock_get_vim_info, mock_get_session):
- mock_get_session.side_effect = [
- get_mock_session(
- ["get"], {"get": {
- "content": self.MOCK_GET_RESOURCE_RESPONSE}}),
- get_mock_session(
- ["post"], {"post": {
- "content": self.MOCK_POST_RESOURCE_RESPONSE,
- "status_code": 202}}),
- ]
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
-
- response = self.client.post(
- self.url, {}, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
-
- context = response.json()
- self.assertIn('error', context)
- self.assertEquals(
- status.HTTP_500_INTERNAL_SERVER_ERROR,
- response.status_code)
-
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_delete_resource(
- self, mock_get_vim_info, mock_get_session):
-
- mock_get_session.side_effect = [
- get_mock_session(
- ["delete"], {"delete": {"content": {},
- "status_code": 204}})
- ]
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
-
- response = self.client.delete(
- self.url + "/uuid_1",
- HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
-
- self.assertEqual(status.HTTP_204_NO_CONTENT,
- response.status_code)
- self.assertIsNone(response.data)
diff --git a/newton/newton/requests/tests/test_flavor.py b/newton/newton/requests/tests/test_flavor.py
index 765121ff..e0fa041a 100644
--- a/newton/newton/requests/tests/test_flavor.py
+++ b/newton/newton/requests/tests/test_flavor.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2017 Intel Corporation, Inc.
+# Copyright (c) 2017-2018 Intel Corporation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,11 +17,11 @@ import unittest
from rest_framework import status
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.tests.test_base import AbstractTestResource
-from newton.requests.views.flavor import Flavors
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.tests.test_base import AbstractTestResource
+from newton_base.openoapi.flavor import Flavors
+from newton_base.util import VimDriverUtils
class TestFlavorsNewton(unittest.TestCase, AbstractTestResource):
diff --git a/newton/newton/requests/tests/test_hosts.py b/newton/newton/requests/tests/test_hosts.py
index 13e6b1fc..94df2071 100644
--- a/newton/newton/requests/tests/test_hosts.py
+++ b/newton/newton/requests/tests/test_hosts.py
@@ -16,7 +16,7 @@ import unittest
from rest_framework import status
-from newton.requests.tests.test_base import AbstractTestResource
+from newton_base.tests.test_base import AbstractTestResource
class TestHostNewton(unittest.TestCase, AbstractTestResource):
diff --git a/newton/newton/requests/tests/test_image.py b/newton/newton/requests/tests/test_image.py
index 40326c2d..fff04e89 100644
--- a/newton/newton/requests/tests/test_image.py
+++ b/newton/newton/requests/tests/test_image.py
@@ -18,11 +18,11 @@ import unittest
from six.moves import urllib
from rest_framework import status
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.tests.test_base import AbstractTestResource
-from newton.requests.views.image import imageThread
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.tests.test_base import AbstractTestResource
+from newton_base.openoapi.image import imageThread
+from newton_base.util import VimDriverUtils
class TestImageNewton(unittest.TestCase, AbstractTestResource):
diff --git a/newton/newton/requests/tests/test_limits.py b/newton/newton/requests/tests/test_limits.py
index 6438e975..fd12bc10 100644
--- a/newton/newton/requests/tests/test_limits.py
+++ b/newton/newton/requests/tests/test_limits.py
@@ -18,10 +18,10 @@ import unittest
from django.test import Client
from rest_framework import status
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.tests.test_base import AbstractTestResource
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.tests.test_base import AbstractTestResource
+from newton_base.util import VimDriverUtils
class TestLimitNewton(unittest.TestCase, AbstractTestResource):
diff --git a/newton/newton/requests/tests/test_network.py b/newton/newton/requests/tests/test_network.py
index 353c7fa3..31c00ce0 100644
--- a/newton/newton/requests/tests/test_network.py
+++ b/newton/newton/requests/tests/test_network.py
@@ -16,7 +16,7 @@ import unittest
from rest_framework import status
-from newton.requests.tests.test_base import AbstractTestResource
+from newton_base.tests.test_base import AbstractTestResource
class TestNetworkNewton(unittest.TestCase, AbstractTestResource):
diff --git a/newton/newton/requests/tests/test_server.py b/newton/newton/requests/tests/test_server.py
index 15a77948..91e51a32 100644
--- a/newton/newton/requests/tests/test_server.py
+++ b/newton/newton/requests/tests/test_server.py
@@ -17,9 +17,9 @@ import json
import mock
from rest_framework import status
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.util import VimDriverUtils
MOCK_GET_SERVERS_RESPONSE = {
"servers": [
diff --git a/newton/newton/requests/tests/test_subnet.py b/newton/newton/requests/tests/test_subnet.py
index 9cc1ea3c..7f1c737c 100644
--- a/newton/newton/requests/tests/test_subnet.py
+++ b/newton/newton/requests/tests/test_subnet.py
@@ -17,10 +17,10 @@ import unittest
from rest_framework import status
-from newton.requests.tests import test_base
-from newton.requests.tests import mock_info
-from newton.requests.tests.test_base import AbstractTestResource
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import test_base
+from newton_base.tests import mock_info
+from newton_base.tests.test_base import AbstractTestResource
+from newton_base.util import VimDriverUtils
class TestSubnetNewton(unittest.TestCase, AbstractTestResource):
diff --git a/newton/newton/requests/tests/test_tenant.py b/newton/newton/requests/tests/test_tenant.py
index 87db8abd..381c5577 100644
--- a/newton/newton/requests/tests/test_tenant.py
+++ b/newton/newton/requests/tests/test_tenant.py
@@ -15,9 +15,9 @@
import mock
from rest_framework import status
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.util import VimDriverUtils
MOCK_GET_PROJECTS_RESPONSE = {
"tenants": [
diff --git a/newton/newton/requests/tests/test_util.py b/newton/newton/requests/tests/test_util.py
index 4db754fe..71f66aa0 100644
--- a/newton/newton/requests/tests/test_util.py
+++ b/newton/newton/requests/tests/test_util.py
@@ -16,8 +16,8 @@ from django.core.cache import cache
import mock
import unittest
-from newton.requests.views import util
-from newton.requests.tests import mock_info
+from newton_base import util
+from newton_base.tests import mock_info
class TestUtil(unittest.TestCase):
@@ -156,4 +156,4 @@ class TestUtil(unittest.TestCase):
dict_obj, mapping, reverse=True)
self.assertEqual(len(new_keys), len(dict_obj.keys()))
- self.assertEqual(sorted(new_keys), sorted(dict_obj.keys())) \ No newline at end of file
+ self.assertEqual(sorted(new_keys), sorted(dict_obj.keys()))
diff --git a/newton/newton/requests/tests/test_volume.py b/newton/newton/requests/tests/test_volume.py
index ff3e2cf9..5f4405e3 100644
--- a/newton/newton/requests/tests/test_volume.py
+++ b/newton/newton/requests/tests/test_volume.py
@@ -17,10 +17,10 @@ import unittest
from rest_framework import status
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.tests.test_base import AbstractTestResource
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.tests.test_base import AbstractTestResource
+from newton_base.util import VimDriverUtils
class TestVolumesNewton(unittest.TestCase, AbstractTestResource):
diff --git a/newton/newton/requests/tests/test_vport.py b/newton/newton/requests/tests/test_vport.py
index 3fc4bfca..08f6af69 100644
--- a/newton/newton/requests/tests/test_vport.py
+++ b/newton/newton/requests/tests/test_vport.py
@@ -16,9 +16,9 @@ import mock
from rest_framework import status
-from newton.requests.tests import mock_info
-from newton.requests.tests import test_base
-from newton.requests.views.util import VimDriverUtils
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.util import VimDriverUtils
MOCK_GET_VPORTS_RESPONSE = {
"ports": [
diff --git a/newton/newton/requests/urls.py b/newton/newton/requests/urls.py
index 87749aab..435ff239 100644
--- a/newton/newton/requests/urls.py
+++ b/newton/newton/requests/urls.py
@@ -15,15 +15,15 @@
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
-from newton.requests.views import network
-from newton.requests.views import subnet
-from newton.requests.views import image
-from newton.requests.views import volume
-from newton.requests.views import server
-from newton.requests.views import vport
-from newton.requests.views import limits
-from newton.requests.views import hosts
-from newton.requests.views import flavor
+from newton_base.openoapi import network
+from newton_base.openoapi import subnet
+from newton_base.openoapi import image
+from newton_base.openoapi import volume
+from newton_base.openoapi import server
+from newton_base.openoapi import vport
+from newton_base.openoapi import limits
+from newton_base.openoapi import hosts
+from newton_base.openoapi import flavor
urlpatterns = [
url(r'^networks(/(?P<networkid>[0-9a-zA-Z_-]+))?',
diff --git a/newton/newton/settings.py b/newton/newton/settings.py
index ffdaa3e2..4b08d2a6 100644
--- a/newton/newton/settings.py
+++ b/newton/newton/settings.py
@@ -121,12 +121,34 @@ CACHES = {
}
}
+# [MSB]
+MSB_SERVICE_ADDR = os.environ.get('MSB_ADDR', "127.0.0.1")
+MSB_SERVICE_PORT = os.environ.get('MSB_PORT', "80")
+
+#[Multicloud]
+MULTICLOUD_PREFIX = "http://%s:%s/api/multicloud-newton/v0" % (
+ MSB_SERVICE_ADDR, MSB_SERVICE_PORT)
+
+# [A&AI]
+AAI_ADDR = os.environ.get('AAI_ADDR', "aai.api.simpledemo.openecomp.org")
+AAI_PORT = os.environ.get('AAI_PORT', "8443")
+AAI_SERVICE_URL = 'https://%s:%s/aai' % (AAI_ADDR, AAI_PORT)
+AAI_SCHEMA_VERSION = os.environ.get('AAI_SCHEMA_VERSION', "v11")
+AAI_USERNAME = os.environ.get('AAI_USERNAME', "AAI")
+AAI_PASSWORD = os.environ.get('AAI_PASSWORD', "AAI")
+
+AAI_BASE_URL = "%s/%s" % (AAI_SERVICE_URL, AAI_SCHEMA_VERSION)
+
+MULTICLOUD_APP_ID = 'MultiCloud-Newton'
+
+# [IMAGE LOCAL PATH]
+ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
OPENSTACK_VERSION = "newton"
MULTIVIM_VERSION = "multicloud-" + OPENSTACK_VERSION
if 'test' in sys.argv:
- from newton.pub.config import config
REST_FRAMEWORK = {}
import platform
diff --git a/newton/newton/swagger/multicloud.identity.swagger.json b/newton/newton/swagger/multicloud.identity.swagger.json
deleted file mode 100644
index b8020648..00000000
--- a/newton/newton/swagger/multicloud.identity.swagger.json
+++ /dev/null
@@ -1,59 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiCloud Identity Proxy rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiCloud services"
- }
- ],
- "paths": {
- "/{vimid}/identity/v3/auth/tokens": {
- "post": {
- "tags": [
- "MultiCloud Identity Proxy"
- ],
- "summary": "Authenticate and get Catalog of endpoints",
- "description": "Authenticate to get token and catalog of service endpoints",
- "operationId": "authenticate",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id, composed by {cloud-owner}_{cloud-region-id}",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenant_name",
- "in": "body",
- "description": "tenant name",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "type": "string"
- },
- "404": {
- "description": "the vim id or tenant name is wrong"
- },
- "500": {
- "description": "the vim instance is not accessable"
- }
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.flavor.swagger.json b/newton/newton/swagger/multivim.flavor.swagger.json
deleted file mode 100644
index e73be9ed..00000000
--- a/newton/newton/swagger/multivim.flavor.swagger.json
+++ /dev/null
@@ -1,392 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/flavors": {
- "post": {
- "tags": [
- "vim flavors"
- ],
- "summary": "create a flavor",
- "description": "create a flavor",
- "operationId": "create_vim_flavor",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "create vim flavor request param",
- "required": true,
- "schema": {
- "$ref": "#/definitions/CreateVimFlavor"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimFlavorInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim flavor is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim flavors"
- ],
- "summary": "query vim flavors list",
- "description": "query vim flavors list",
- "operationId": "query_vim_flavors",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "flavor name to filter list",
- "required": false,
- "type": "string"
- },
- {
- "name": "limit",
- "in": "query",
- "description": "Requests a page size of items",
- "required": false,
- "type": "string"
- },
- {
- "name": "marker",
- "in": "query",
- "description": "image ID of the last-seen item",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimFlavorsInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim flavor is not accessable"
- }
- }
- }
- },
- "/{vimid}/{tenantid}/flavors/{flavorid}": {
- "delete": {
- "tags": [
- "vim flavors"
- ],
- "summary": "delete specific vim flavor",
- "description": "delete specific vim flavor",
- "operationId": "delete_vim_flavor",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "flavorid",
- "in": "path",
- "description": "vim flavor id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "204": {
- "description": "successful operation"
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim flavor is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim flavors"
- ],
- "summary": "query specific vim flavor",
- "description": "query specific vim flavor",
- "operationId": "query_vim_flavor",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "flavorid",
- "in": "path",
- "description": "vim flavor id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimFlavorInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim flavor is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "CreateVimFlavor": {
- "type": "object",
- "required": [
- "vcpu",
- "name",
- "memory",
- "disk"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "flavor name"
- },
- "vcpu": {
- "type": "integer",
- "description": "virtual cpu number"
- },
- "memory": {
- "type": "integer",
- "description": "memory size"
- },
- "disk": {
- "type": "integer",
- "description": "The size of the root disk"
- },
- "ephemeral": {
- "type": "integer",
- "description": "The size of the ephemeral disk"
- },
- "swap": {
- "type": "integer",
- "description": "The size of the swap disk"
- },
- "isPublic": {
- "type": "boolean",
- "description": "whether the flavor is public"
- },
- "extraSpecs": {
- "type": "array",
- "description": "list of extra specs",
- "items": {
- "$ref": "#/definitions/VimFlavorExtraSpecInfo"
- }
- }
- }
- },
- "VimFlavorExtraSpecInfo": {
- "type": "object",
- "properties": {
- "keyName": {
- "type": "string",
- "description": "extra spec key"
- },
- "value": {
- "type": "string",
- "description": "extra spec value"
- }
- }
- },
- "VimFlavorsInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "flavors"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "flavors": {
- "type": "array",
- "description": "flavor list information",
- "items": {
- "$ref": "#/definitions/VimFlavorInfo"
- }
- }
- }
- },
- "VimFlavorInfo": {
- "type": "object",
- "required": [
- "name",
- "id",
- "vcpu",
- "memory",
- "disk",
- "ephemeral",
- "swap",
- "isPublic"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "flavor name"
- },
- "id": {
- "type": "string",
- "description": "flavor UUID"
- },
- "vcpu": {
- "type": "integer",
- "description": "virtual cpu number"
- },
- "memory": {
- "type": "integer",
- "description": "memory size"
- },
- "disk": {
- "type": "integer",
- "description": "The size of the root disk"
- },
- "ephemeral": {
- "type": "integer",
- "description": "The size of the ephemeral disk"
- },
- "swap": {
- "type": "integer",
- "description": "The size of the swap disk"
- },
- "isPublic": {
- "type": "boolean",
- "description": "whether the flavor is public"
- },
- "extraSpecs": {
- "type": "array",
- "description": "list of extra specs",
- "items": {
- "$ref": "#/definitions/VimFlavorExtraSpecInfo"
- }
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "returnCode": {
- "type": "integer",
- "description": "0: Already exist 1: Newly created"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.host.swagger.json b/newton/newton/swagger/multivim.host.swagger.json
deleted file mode 100644
index 1ea4603e..00000000
--- a/newton/newton/swagger/multivim.host.swagger.json
+++ /dev/null
@@ -1,233 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/hosts": {
- "get": {
- "tags": [
- "vim hosts"
- ],
- "summary": "query vim hosts list",
- "description": "query vim hosts list",
- "operationId": "query_vim_hosts",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimHostsInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim host is not accessable"
- }
- }
- }
- },
- "/{vimid}/{tenantid}/hosts/{hostname}": {
- "get": {
- "tags": [
- "vim hosts"
- ],
- "summary": "query specific vim host",
- "description": "query specific vim host",
- "operationId": "query_vim_host",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "hostname",
- "in": "path",
- "description": "vim host name",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimHostDetail"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim host is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "VimHostsInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "hosts"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "hosts": {
- "type": "array",
- "description": "list of host information",
- "items": {
- "$ref": "#/definitions/VimHostInfo"
- }
- }
- }
- },
- "VimHostInfo": {
- "type": "object",
- "required": [
- "name",
- "service"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "host name"
- },
- "service": {
- "type": "string",
- "description": "service name running on the host"
- },
- "zone": {
- "type": "string",
- "description": "available zone name of the host"
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- }
- }
- },
- "VimHostDetail": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "host"
- ],
- "properties": {
- "host": {
- "type": "array",
- "description": "list of host information",
- "items": {
- "$ref": "#/definitions/VimHostResource"
- }
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- }
- }
- },
- "VimHostResource": {
- "type": "object",
- "required": [
- "name",
- "cpu",
- "memory_mb",
- "disk_gb",
- "project"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "host name"
- },
- "cpu": {
- "type": "integer",
- "description": "The cpu info on the host"
- },
- "memory_mb": {
- "type": "integer",
- "description": "The memory info on the host (in MB)"
- },
- "disk_gb": {
- "type": "integer",
- "description": "The disk info on the host (in GB)"
- },
- "project": {
- "type": "string",
- "description": "The project id (or special name like total, used_now, used_max)."
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.image.swagger.json b/newton/newton/swagger/multivim.image.swagger.json
deleted file mode 100644
index 1ff3741a..00000000
--- a/newton/newton/swagger/multivim.image.swagger.json
+++ /dev/null
@@ -1,359 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/images": {
- "post": {
- "tags": [
- "vim images"
- ],
- "summary": "create a image",
- "description": "create a image",
- "operationId": "create_vim_image",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "create vim image request param",
- "required": true,
- "schema": {
- "$ref": "#/definitions/CreateVimImage"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimImageInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim image is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim images"
- ],
- "summary": "query vim images list",
- "description": "query vim images list",
- "operationId": "query_vim_images",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "images name to filter list",
- "required": false,
- "type": "string"
- },
- {
- "name": "limit",
- "in": "query",
- "description": "Requests a page size of items",
- "required": false,
- "type": "string"
- },
- {
- "name": "marker",
- "in": "query",
- "description": "image ID of the last-seen item",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimImagesInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim image is not accessable"
- }
- }
- }
- },
- "/{vimid}/{tenantid}/images/{imageid}": {
- "delete": {
- "tags": [
- "vim images"
- ],
- "summary": "delete specific vim image",
- "description": "delete specific vim image",
- "operationId": "delete_vim_image",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "imageid",
- "in": "path",
- "description": "vim image id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "204": {
- "description": "successful operation"
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim image is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim images"
- ],
- "summary": "query specific vim image",
- "description": "query specific vim image",
- "operationId": "query_vim_image",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "imageid",
- "in": "path",
- "description": "vim image id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimImageInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim image is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "CreateVimImage": {
- "type": "object",
- "required": [
- "imagePath",
- "name",
- "imageType",
- "containerFormat"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "image name"
- },
- "imageType": {
- "type": "string",
- "description": "image type: ami, ari, aki, vhd, vhdx, vmdk, raw, qcow2, vdi, iso"
- },
- "imagePath": {
- "type": "string",
- "description": "image url to catalog"
- },
- "containerFormat": {
- "type": "string",
- "description": "image container format: ami, ari, aki, bare, ovf, ova, docker"
- },
- "visibility": {
- "type": "string",
- "description": "public, private, shared, or community"
- }
- }
- },
- "VimImagesInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "images"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "images": {
- "type": "array",
- "description": "image list information",
- "items": {
- "$ref": "#/definitions/VimImageInfo"
- }
- }
- }
- },
- "VimImageInfo": {
- "type": "object",
- "required": [
- "name",
- "status",
- "id"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "image name"
- },
- "id": {
- "type": "string",
- "description": "image UUID"
- },
- "imageType": {
- "type": "string",
- "description": "image type: ami, ari, aki, vhd, vhdx, vmdk, raw, qcow2, vdi, iso"
- },
- "imagePath": {
- "type": "string",
- "description": "image url to catalog"
- },
- "containerFormat": {
- "type": "string",
- "description": "image container format: ami, ari, aki, bare, ovf, ova, docker"
- },
- "visibility": {
- "type": "string",
- "description": "public, private, shared, or community"
- },
- "properties": {
- "type": "array",
- "description": "list of properties",
- "items": {
- "$ref": "#/definitions/VimImagePropertyInfo"
- }
- },
- "status": {
- "type": "string",
- "description": "image status"
- },
- "size": {
- "type": "string",
- "description": "image size"
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "returnCode": {
- "type": "integer",
- "description": "0: Already exist 1: Newly created"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.limit.swagger.json b/newton/newton/swagger/multivim.limit.swagger.json
deleted file mode 100644
index 3fea1b72..00000000
--- a/newton/newton/swagger/multivim.limit.swagger.json
+++ /dev/null
@@ -1,158 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/limits": {
- "get": {
- "tags": [
- "vim limits"
- ],
- "summary": "query vim limits list",
- "description": "query vim limits list",
- "operationId": "query_vim_limits",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimLimitsInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim limits is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "VimLimitsInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "maxPersonality": {
- "type": "integer",
- "description": "The number of allowed injected files for each tenant"
- },
- "maxPersonalitySize": {
- "type": "integer",
- "description": "The number of allowed bytes of content for each injected file"
- },
- "maxServerGroupMembers": {
- "type": "integer",
- "description": "The number of allowed members for each server group"
- },
- "maxServerGroups": {
- "type": "integer",
- "description": "The number of allowed server groups for each tenant"
- },
- "maxServerMeta": {
- "type": "integer",
- "description": "The number of allowed metadata items for each instance"
- },
- "maxTotalCores": {
- "type": "integer",
- "description": "The number of allowed instance cores for each tenant"
- },
- "maxTotalInstances": {
- "type": "integer",
- "description": "The number of allowed instances for each tenant"
- },
- "maxTotalKeypairs": {
- "type": "integer",
- "description": "The number of allowed key pairs for each user"
- },
- "maxTotalRAMSize": {
- "type": "integer",
- "description": "The amount of allowed instance RAM, in MB, for each tenant"
- },
- "maxTotalVolumeGigabytes": {
- "type": "integer",
- "description": "The maximum total amount of volumes, in gibibytes (GiB)."
- },
- "maxTotalVolumes": {
- "type": "integer",
- "description": "The maximum number of volumes"
- },
- "totalGigabytesUsed": {
- "type": "integer",
- "description": "The total number of gibibytes (GiB) used"
- },
- "network": {
- "type": "integer",
- "description": "The number of networks allowed for each project"
- },
- "subnet": {
- "type": "integer",
- "description": "The number of subnets allowed for each project"
- },
- "subnetpool": {
- "type": "integer",
- "description": "The number of subnet pools allowed for each project"
- },
- "security_group_rule": {
- "type": "integer",
- "description": "The number of security group rules allowed for each project"
- },
- "security_group": {
- "type": "integer",
- "description": "The number of security groups allowed for each project"
- },
- "router": {
- "type": "integer",
- "description": "The number of routers allowed for each project"
- },
- "port": {
- "type": "integer",
- "description": "The number of ports allowed for each project"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.network.swagger.json b/newton/newton/swagger/multivim.network.swagger.json
deleted file mode 100644
index 3962e891..00000000
--- a/newton/newton/swagger/multivim.network.swagger.json
+++ /dev/null
@@ -1,349 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/networks": {
- "post": {
- "tags": [
- "vim networks"
- ],
- "summary": "create a network",
- "description": "create a network",
- "operationId": "create_vim_network",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "create vim network request param",
- "required": true,
- "schema": {
- "$ref": "#/definitions/CreateVimNetwork"
- }
- }
- ],
- "responses": {
- "201": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimNetworkInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim network is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim networks"
- ],
- "summary": "query vim networks list",
- "description": "query vim networks list",
- "operationId": "query_vim_networks",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "network name to filter list",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimNetworksInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim network is not accessable"
- }
- }
- }
- },
- "/{vimid}/{tenantid}/networks/{networkid}": {
- "delete": {
- "tags": [
- "vim networks"
- ],
- "summary": "delete specific vim network",
- "description": "delete specific vim network",
- "operationId": "delete_vim_network",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "networkid",
- "in": "path",
- "description": "vim network id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "204": {
- "description": "successful operation"
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the network is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim networks"
- ],
- "summary": "query specific vim network",
- "description": "query specific vim network",
- "operationId": "query_vim_network",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "networkid",
- "in": "path",
- "description": "vim network id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimNetworkInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim network is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "CreateVimNetwork": {
- "type": "object",
- "required": [
- "networkType",
- "name",
- "shared"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "network name"
- },
- "networkType": {
- "type": "string",
- "description": "network type"
- },
- "physicalNetwork": {
- "type": "string",
- "description": "physical network name"
- },
- "segmentationId": {
- "type": "integer",
- "description": "segmentation ID of physical network"
- },
- "vlanTransparent": {
- "type": "boolean",
- "description": "vlan transparent"
- },
- "shared": {
- "type": "boolean",
- "description": "network is shared across tenants"
- },
- "routerExternal": {
- "type": "boolean",
- "description": "network can provide floating IPs via a router"
- }
- }
- },
- "VimNetworksInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "networks"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "networks": {
- "type": "array",
- "description": "network information",
- "items": {
- "$ref": "#/definitions/VimNetworkInfo"
- }
- }
- }
- },
- "VimNetworkInfo": {
- "type": "object",
- "required": [
- "name",
- "status",
- "id"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "network name"
- },
- "id": {
- "type": "string",
- "description": "network UUID"
- },
- "status": {
- "type": "string",
- "description": "network status"
- },
- "networkType": {
- "type": "string",
- "description": "network type"
- },
- "physicalNetwork": {
- "type": "string",
- "description": "physical network name"
- },
- "segmentationId": {
- "type": "boolean",
- "description": "segmentationId of physical network"
- },
- "vlanTransparent": {
- "type": "boolean",
- "description": "vlan transparent"
- },
- "shared": {
- "type": "boolean",
- "description": "network is shared across tenants"
- },
- "routerExternal": {
- "type": "boolean",
- "description": "network can provide floating IPs via a router"
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "returnCode": {
- "type": "integer",
- "description": "0: Already exist 1: Newly created"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.server.swagger.json b/newton/newton/swagger/multivim.server.swagger.json
deleted file mode 100644
index c309a394..00000000
--- a/newton/newton/swagger/multivim.server.swagger.json
+++ /dev/null
@@ -1,488 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/servers": {
- "post": {
- "tags": [
- "vim servers"
- ],
- "summary": "create a server",
- "description": "create a server",
- "operationId": "create_vim_server",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "create vim server request param",
- "required": true,
- "schema": {
- "$ref": "#/definitions/CreateVimServer"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimServerInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim server is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim servers"
- ],
- "summary": "query vim servers list",
- "description": "query vim servers list",
- "operationId": "query_vim_servers",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "server name to filter list",
- "required": false,
- "type": "string"
- },
- {
- "name": "limit",
- "in": "query",
- "description": "Requests a page size of items",
- "required": false,
- "type": "string"
- },
- {
- "name": "marker",
- "in": "query",
- "description": "image ID of the last-seen item",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimServersInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim server is not accessable"
- }
- }
- }
- },
- "/{vimid}/{tenantid}/servers/{serverid}": {
- "delete": {
- "tags": [
- "vim servers"
- ],
- "summary": "delete specific vim server",
- "description": "delete specific vim server",
- "operationId": "delete_vim_server",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "serverid",
- "in": "path",
- "description": "vim server id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "204": {
- "description": "successful operation"
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim server is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim servers"
- ],
- "summary": "query specific vim server",
- "description": "query specific vim server",
- "operationId": "query_vim_server",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "serverid",
- "in": "path",
- "description": "vim server id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimServerInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim server is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "CreateVimServer": {
- "type": "object",
- "required": [
- "name",
- "boot",
- "flavorId"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "server name"
- },
- "boot": {
- "type": "object",
- "description": "Parameters to start a server",
- "properties": {
- "type": {
- "type": "integer",
- "description": "boot type: 1: boot from volume, 2: boot from image"
- },
- "volumeId": {
- "type": "string",
- "description": "volume UUID to boot server"
- },
- "imageId": {
- "type": "string",
- "description": "image UUID to boot server"
- }
- }
- },
- "flavorId": {
- "type": "string",
- "description": "flavor uuid to start server"
- },
- "contextArray": {
- "type": "array",
- "description": "list of injected files",
- "items": {
- "$ref": "#/definitions/VimServerContextInfo"
- }
- },
- "volumeArray": {
- "type": "array",
- "description": "list of volumes attached to a server",
- "items": {
- "$ref": "#/definitions/VimServerVolumeInfo"
- }
- },
- "nicArray": {
- "type": "array",
- "description": "list of volumes attached to a server",
- "items": {
- "$ref": "#/definitions/VimServerNicInfo"
- }
- },
- "availabilityZone": {
- "type": "string",
- "description": "The availability zone from which to launch the server."
- },
- "metadata": {
- "type": "array",
- "description": "list of key-value pairs for metadata to start a server",
- "items": {
- "$ref": "#/definitions/VimServerKeyValuePair"
- }
- },
- "userdata": {
- "type": "string",
- "description": "user data to start a aserver"
- },
- "securityGroups": {
- "type": "array",
- "description": "list of security groups for a server",
- "items": {
- "type": "string",
- "description": "name of security group"
- }
- },
- "serverGroup": {
- "type": "string",
- "description": "server group"
- }
- }
- },
- "VimServerKeyValuePair": {
- "type": "object",
- "properties": {
- "keyName": {
- "type": "string",
- "description": "key name"
- },
- "value": {
- "type": "string",
- "description": "value "
- }
- }
- },
- "VimServerContextInfo": {
- "type": "object",
- "properties": {
- "fileName": {
- "type": "string",
- "description": "Injected file name"
- },
- "fileData": {
- "type": "string",
- "description": "Injected file content "
- }
- }
- },
- "VimServerVolumeInfo": {
- "type": "object",
- "properties": {
- "volumeId": {
- "type": "string",
- "description": "volume UUID"
- }
- }
- },
- "VimServerNicInfo": {
- "type": "object",
- "properties": {
- "portId": {
- "type": "string",
- "description": "virtual port UUID to boot a server"
- }
- }
- },
- "VimServersInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "servers"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "servers": {
- "type": "array",
- "description": "server list information",
- "items": {
- "$ref": "#/definitions/VimServerInfo"
- }
- }
- }
- },
- "VimServerInfo": {
- "type": "object",
- "required": [
- "name",
- "status",
- "id"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "server name"
- },
- "id": {
- "type": "string",
- "description": "server UUID"
- },
- "status": {
- "type": "string",
- "description": "server status,0:INACTIVE,1:ACTIVE,2:ERROR"
- },
- "boot": {
- "type": "object",
- "description": "Parameters to start a server",
- "properties": {
- "type": {
- "type": "integer",
- "description": "boot type: 1: boot from volume, 2: boot from image"
- },
- "volumeId": {
- "type": "string",
- "description": "volume UUID to boot server"
- },
- "ImageId": {
- "type": "string",
- "description": "image UUID to boot server"
- }
- }
- },
- "flavorId": {
- "type": "string",
- "description": "flavor uuid to start server"
- },
- "volumeArray": {
- "type": "array",
- "description": "list of volumes attached to a server",
- "items": {
- "$ref": "#/definitions/VimServerVolumeInfo"
- }
- },
- "nicArray": {
- "type": "array",
- "description": "list of volumes attached to a server",
- "items": {
- "$ref": "#/definitions/VimServerNicInfo"
- }
- },
- "availabilityZone": {
- "type": "string",
- "description": "available zone for a server"
- },
- "metadata": {
- "type": "array",
- "description": "list of key-value pairs for metadata to start a server",
- "items": {
- "$ref": "#/definitions/VimServerKeyValuePair"
- }
- },
- "securityGroups": {
- "type": "array",
- "description": "list of security groups for a server",
- "items": {
- "type": "string",
- "description": "name of security group"
- }
- },
- "serverGroup": {
- "type": "string",
- "description": "server group"
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "returnCode": {
- "type": "integer",
- "description": "0: Already exist 1: Newly created"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.subnet.swagger.json b/newton/newton/swagger/multivim.subnet.swagger.json
deleted file mode 100644
index ae466d49..00000000
--- a/newton/newton/swagger/multivim.subnet.swagger.json
+++ /dev/null
@@ -1,417 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/subnets": {
- "post": {
- "tags": [
- "vim subnets"
- ],
- "summary": "create a subnet",
- "description": "create a subnet",
- "operationId": "create_vim_subnet",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "create vim subnet request param",
- "required": true,
- "schema": {
- "$ref": "#/definitions/CreateVimSubnet"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimSubnetInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim subnet is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim subnets"
- ],
- "summary": "query vim subnets list",
- "description": "query vim subnets list",
- "operationId": "query_vim_subnets",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "subnet name to filter list",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimSubnetsInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim subnet is not accessable"
- }
- }
- }
- },
- "/{vimid}/{tenantid}/subnets/{subnetid}": {
- "delete": {
- "tags": [
- "vim subnets"
- ],
- "summary": "delete specific vim subnet",
- "description": "delete specific vim subnet",
- "operationId": "delete_vim_subnet",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "subnetid",
- "in": "path",
- "description": "vim subnet id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "204": {
- "description": "successful operation"
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the subnet is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim subnets"
- ],
- "summary": "query specific vim subnet",
- "description": "query specific vim subnet",
- "operationId": "query_vim_subnet",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "subnetid",
- "in": "path",
- "description": "vim subnet id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimSubnetInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim subnet id is invalid"
- }
- }
- }
- }
- },
- "definitions": {
- "CreateVimSubnet": {
- "type": "object",
- "required": [
- "networkId",
- "name",
- "cidr",
- "ipVersion"
- ],
- "properties": {
- "networkId": {
- "type": "string",
- "description": "network UUID"
- },
- "name": {
- "type": "string",
- "description": "subnet name"
- },
- "cidr": {
- "type": "string",
- "description": "subnet CIDR"
- },
- "ipVersion": {
- "type": "integer",
- "description": "IP version: 4 for IPv4, 6 for IPv6"
- },
- "enableDhcp": {
- "type": "boolean",
- "description": "Enable DHCP or not"
- },
- "gatewayIp": {
- "type": "string",
- "description": "gateway IP address"
- },
- "dnsNameservers": {
- "type": "array",
- "description": "DNS Nameservers",
- "items": {
- "type": "string"
- }
- },
- "hostRoutes": {
- "type": "array",
- "description": "Host route entries",
- "items": {
- "$ref": "#/definitions/VimHostRouteInfo"
- }
- },
- "allocationPools": {
- "type": "array",
- "description": "IP address allocation pools",
- "items": {
- "$ref": "#/definitions/VimIpAllocationPoolInfo"
- }
- }
- }
- },
- "VimHostRouteInfo": {
- "type": "object",
- "properties": {
- "destination": {
- "type": "string",
- "description": "destination field of a route entry"
- },
- "nexthop ": {
- "type": "string",
- "description": "next hop of a route entry"
- }
- }
- },
- "VimIpAllocationPoolInfo": {
- "type": "object",
- "properties": {
- "start": {
- "type": "string",
- "description": "start IP address of a pool"
- },
- "end ": {
- "type": "string",
- "description": "end IP address of a pool"
- }
- }
- },
- "VimSubnetsInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "subnets"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "subnets": {
- "type": "array",
- "description": "subnets information",
- "items": {
- "$ref": "#/definitions/VimSubnetInfo"
- }
- }
- }
- },
- "VimSubnetInfo": {
- "type": "object",
- "required": [
- "name",
- "status",
- "id",
- "networkId",
- "cidr",
- "ipVersion"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "subnet name"
- },
- "id": {
- "type": "string",
- "description": "subnet UUID"
- },
- "status": {
- "type": "string",
- "description": "subnet status"
- },
- "networkId": {
- "type": "string",
- "description": "network UUID"
- },
- "networkName": {
- "type": "string",
- "description": "network name"
- },
- "cidr": {
- "type": "string",
- "description": "subnet CIDR"
- },
- "ipVersion": {
- "type": "integer",
- "description": "IP version: 4 for IPv4, 6 for IPv6"
- },
- "enableDhcp": {
- "type": "boolean",
- "description": "Enable DHCP or not"
- },
- "gatewayIp": {
- "type": "string",
- "description": "gateway IP address"
- },
- "dnsNameservers": {
- "type": "array",
- "description": "DNS Nameservers",
- "items": {
- "type": "string"
- }
- },
- "hostRoutes": {
- "type": "array",
- "description": "Host route entries",
- "items": {
- "$ref": "#/definitions/VimHostRouteInfo"
- }
- },
- "allocationPools": {
- "type": "array",
- "description": "IP address allocation pools",
- "items": {
- "$ref": "#/definitions/VimIpAllocationPoolInfo"
- }
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "returnCode": {
- "type": "integer",
- "description": "0: Already exist 1: Newly created"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.tenant.swagger.json b/newton/newton/swagger/multivim.tenant.swagger.json
deleted file mode 100644
index ed0c6c45..00000000
--- a/newton/newton/swagger/multivim.tenant.swagger.json
+++ /dev/null
@@ -1,102 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/tenants": {
- "get": {
- "tags": [
- "vim tenants"
- ],
- "summary": "query vim tenants list",
- "description": "query vim tenants list",
- "operationId": "query_vim_tenants",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "tenant name to filter tenant list",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimTenantsInfo"
- }
- },
- "404": {
- "description": "the vim id is wrong"
- },
- "500": {
- "description": "the vim tenants is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "VimTenantsInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenants"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenants": {
- "type": "array",
- "description": "tenant list information",
- "items": {
- "$ref": "#/definitions/VimTenantInfo"
- }
- }
- }
- },
- "VimTenantInfo": {
- "type": "object",
- "required": [
- "name",
- "id"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "tenant name"
- },
- "id": {
- "type": "string",
- "description": "tenant UUID"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.volume.swagger.json b/newton/newton/swagger/multivim.volume.swagger.json
deleted file mode 100644
index 7dd787d1..00000000
--- a/newton/newton/swagger/multivim.volume.swagger.json
+++ /dev/null
@@ -1,378 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/volumes": {
- "post": {
- "tags": [
- "vim volumes"
- ],
- "summary": "create a volume",
- "description": "create a volume",
- "operationId": "create_vim_volume",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "create vim volume request param",
- "required": true,
- "schema": {
- "$ref": "#/definitions/CreateVimVolume"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimVolumeInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim volume is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim volumes"
- ],
- "summary": "query vim volumes list",
- "description": "query vim volumes list",
- "operationId": "query_vim_volumes",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "volumn name to filter list",
- "required": false,
- "type": "string"
- },
- {
- "name": "limit",
- "in": "query",
- "description": "Requests a page size of items",
- "required": false,
- "type": "string"
- },
- {
- "name": "marker",
- "in": "query",
- "description": "image ID of the last-seen item",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimVolumesInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim volume is not accessable"
- }
- }
- }
- },
- "/{vimid}/{tenantid}/volumes/{volumeid}": {
- "delete": {
- "tags": [
- "vim volumes"
- ],
- "summary": "delete specific vim volume",
- "description": "delete specific vim volume",
- "operationId": "delete_vim_volume",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "volumeid",
- "in": "path",
- "description": "vim volume id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "204": {
- "description": "successful operation"
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim volume is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim volumes"
- ],
- "summary": "query specific vim volume",
- "description": "query specific vim volume",
- "operationId": "query_vim_volume",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "volumeid",
- "in": "path",
- "description": "vim volume id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimVolumeInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim volume is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "CreateVimVolume": {
- "type": "object",
- "required": [
- "name",
- "volumeSize"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "volume name"
- },
- "volumeSize": {
- "type": "integer",
- "description": "volume size"
- },
- "imageId": {
- "type": "string",
- "description": "image UUID to create volume"
- },
- "volumeType": {
- "type": "string",
- "description": "volume type"
- },
- "availabilityZone": {
- "type": "integer",
- "description": "available zone for volume"
- }
- }
- },
- "VimVolumesInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "volumes"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "volumes": {
- "type": "array",
- "description": "volume list information",
- "items": {
- "$ref": "#/definitions/VimVolumeInfo"
- }
- }
- }
- },
- "VimVolumeInfo": {
- "type": "object",
- "required": [
- "name",
- "id",
- "status"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "volume name"
- },
- "id": {
- "type": "string",
- "description": "volume UUID"
- },
- "createTime": {
- "type": "string",
- "description": "created time"
- },
- "volumeSize": {
- "type": "integer",
- "description": "volume size"
- },
- "volumeType": {
- "type": "string",
- "description": "volume type"
- },
- "availabilityZone": {
- "type": "integer",
- "description": "available zone for volume"
- },
- "attachments": {
- "type": "array",
- "description": "attachment list information",
- "items": {
- "$ref": "#/definitions/VimVolumeAttachmentInfo"
- }
- },
- "status": {
- "type": "string",
- "description": "volume status"
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "returnCode": {
- "type": "integer",
- "description": "return code: 0: Already exist 1: Newly created"
- }
- }
- },
- "VimVolumeAttachmentInfo": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string",
- "description": "attachment UUID"
- },
- "serverId": {
- "type": "string",
- "description": "server UUID"
- },
- "volumeId": {
- "type": "string",
- "description": "volume UUID"
- },
- "device": {
- "type": "string",
- "description": "device to be attached"
- },
- "hostName": {
- "type": "string",
- "description": "host name"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/multivim.vport.swagger.json b/newton/newton/swagger/multivim.vport.swagger.json
deleted file mode 100644
index 5b0a04a7..00000000
--- a/newton/newton/swagger/multivim.vport.swagger.json
+++ /dev/null
@@ -1,363 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "MultiVIM Service rest API"
- },
- "basePath": "/api/multicloud-newton/v0/",
- "tags": [
- {
- "name": "MultiVIM services"
- }
- ],
- "paths": {
- "/{vimid}/{tenantid}/ports": {
- "post": {
- "tags": [
- "vim virtual ports"
- ],
- "summary": "create a virtual port",
- "description": "create a virtual port",
- "operationId": "create_vim_port",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "create vim virtual port request param",
- "required": true,
- "schema": {
- "$ref": "#/definitions/CreateVimPort"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimPortInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim virtual port is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim virtual ports"
- ],
- "summary": "query vim ports list",
- "description": "query vim ports list",
- "operationId": "query_vim_ports",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "virtual port name to filter list",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimPortsInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim virtual port is not accessable"
- }
- }
- }
- },
- "/{vimid}/{tenantid}/ports/{portid}": {
- "delete": {
- "tags": [
- "vim virtual ports"
- ],
- "summary": "delete specific vim virtual port",
- "description": "delete specific vim virtual port",
- "operationId": "delete_vim_port",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "portid",
- "in": "path",
- "description": "vim virtual port id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "204": {
- "description": "successful operation"
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the virtual port is not accessable"
- }
- }
- },
- "get": {
- "tags": [
- "vim virtual ports"
- ],
- "summary": "query specific vim virtual port",
- "description": "query specific vim virtual port",
- "operationId": "query_vim_port",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vimid",
- "in": "path",
- "description": "vim instance id",
- "required": true,
- "type": "string"
- },
- {
- "name": "tenantid",
- "in": "path",
- "description": "tenant UUID",
- "required": true,
- "type": "string"
- },
- {
- "name": "portid",
- "in": "path",
- "description": "vim virtual port id",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "$ref": "#/definitions/VimPortInfo"
- }
- },
- "404": {
- "description": "the vim id or tenant UUID is wrong"
- },
- "500": {
- "description": "the vim virtual port id is not accessable"
- }
- }
- }
- }
- },
- "definitions": {
- "CreateVimPort": {
- "type": "object",
- "required": [
- "networkId",
- "name"
- ],
- "properties": {
- "networkId": {
- "type": "string",
- "description": "network UUID"
- },
- "subnetId": {
- "type": "string",
- "description": "subnet UUID"
- },
- "name": {
- "type": "string",
- "description": "virtual port name"
- },
- "ip": {
- "type": "string",
- "description": "virtual port fixed IP"
- },
- "macAddress": {
- "type": "string",
- "description": "virtual port MAC address"
- },
- "vnicType": {
- "type": "string",
- "description": "vnicType: normal,direct,macvtap"
- },
- "securityGroups": {
- "type": "array",
- "description": "List of security group names",
- "items": {
- "type": "string"
- }
- }
- }
- },
- "VimPortsInfo": {
- "type": "object",
- "required": [
- "vimId",
- "tenantId",
- "ports"
- ],
- "properties": {
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "ports": {
- "type": "array",
- "description": "ports information",
- "items": {
- "$ref": "#/definitions/VimPortInfo"
- }
- }
- }
- },
- "VimPortInfo": {
- "type": "object",
- "required": [
- "name",
- "status",
- "id",
- "networkId"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "virtual port name"
- },
- "id": {
- "type": "string",
- "description": "virtual port UUID"
- },
- "status": {
- "type": "string",
- "description": "subnet status"
- },
- "networkId": {
- "type": "string",
- "description": "network UUID"
- },
- "networkName": {
- "type": "string",
- "description": "network name"
- },
- "subnetName": {
- "type": "string",
- "description": "subnet name"
- },
- "subnetId": {
- "type": "string",
- "description": "subnet UUID"
- },
- "ip": {
- "type": "string",
- "description": "virtual port fixed IP"
- },
- "macAddress": {
- "type": "string",
- "description": "virtual port MAC address"
- },
- "vnicType": {
- "type": "string",
- "description": "vnicType: normal,direct,macvtap"
- },
- "securityGroups": {
- "type": "array",
- "description": "list of securityGroups names",
- "items": {
- "type": "string"
- }
- },
- "vimId": {
- "type": "string"
- },
- "vimName": {
- "type": "string"
- },
- "tenantId": {
- "type": "string",
- "description": "tenant UUID"
- },
- "returnCode": {
- "type": "integer",
- "description": "0: Already exist 1: Newly created"
- }
- }
- }
- }
-}
diff --git a/newton/newton/swagger/tests.py b/newton/newton/swagger/tests.py
index dc82ed13..832221a9 100644
--- a/newton/newton/swagger/tests.py
+++ b/newton/newton/swagger/tests.py
@@ -16,7 +16,7 @@ import unittest
from django.test import Client
from rest_framework import status
-from newton.requests.tests import test_base
+from newton_base.tests import test_base
class SampleViewTest(unittest.TestCase):
diff --git a/newton/newton/swagger/urls.py b/newton/newton/swagger/urls.py
index 3174c14e..62046bc1 100644
--- a/newton/newton/swagger/urls.py
+++ b/newton/newton/swagger/urls.py
@@ -15,7 +15,6 @@
from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
-from newton.swagger import views
from newton.swagger.views import SwaggerJsonView
urlpatterns = [
diff --git a/newton/newton/swagger/views.py b/newton/newton/swagger/views.py
index d832400b..42f596aa 100644
--- a/newton/newton/swagger/views.py
+++ b/newton/newton/swagger/views.py
@@ -21,79 +21,28 @@ from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
-from newton.pub.exceptions import VimDriverNewtonException
+from common.exceptions import VimDriverNewtonException
+from newton_base.swagger import views as newton_json_view
logger = logging.getLogger(__name__)
-class SwaggerJsonView(APIView):
- def get(self, request):
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.flavor.swagger.json')
- f = open(json_file)
- json_data = json.JSONDecoder().decode(f.read())
- f.close()
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.image.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.network.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.subnet.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.server.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.volume.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.vport.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.tenant.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.host.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
- json_file = os.path.join(os.path.dirname(__file__), 'multivim.limit.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
- json_data["definitions"].update(json_data_temp["definitions"])
+class SwaggerJsonView(newton_json_view.SwaggerJsonView):
- json_file = os.path.join(os.path.dirname(__file__), 'multicloud.identity.swagger.json')
- f = open(json_file)
- json_data_temp = json.JSONDecoder().decode(f.read())
- f.close()
- json_data["paths"].update(json_data_temp["paths"])
+ def get(self, request):
+ '''
+ reuse newton code and update the basePath
+ :param request:
+ :return:
+ '''
+
+ resp = super(SwaggerJsonView,self).get(request)
+ json_data = resp.data if resp else None
+ if json_data:
+ json_data["basePath"] = "/api/multicloud-ocata/v0/"
+ json_data["info"]["title"] = "Service NBI of MultiCloud plugin for OpenStack Ocata"
+ return Response(data=json_data, status=200)
+ else:
+ return Response(data={'error':'internal error'}, status=500)
- json_data["basePath"] = "/api/multicloud-newton/v0/"
- json_data["info"]["title"] = "Service NBI of MultiCloud plugin for OpenStack Newton"
- return Response(json_data)
diff --git a/newton/newton/urls.py b/newton/newton/urls.py
index ab269cad..ca827480 100644
--- a/newton/newton/urls.py
+++ b/newton/newton/urls.py
@@ -15,7 +15,7 @@
from django.conf.urls import include, url
from newton.registration.views import registration
-from newton.requests.views import tenants
+from newton_base.openoapi import tenants
urlpatterns = [
url(r'^', include('newton.swagger.urls')),
diff --git a/newton/pom.xml b/newton/pom.xml
index af99be78..ba375609 100644
--- a/newton/pom.xml
+++ b/newton/pom.xml
@@ -66,51 +66,4 @@
</plugin>
</plugins>
</build>
- <profiles>
- <profile>
- <id>docker</id>
- <build>
- <plugins>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>0.16.5</version>
- <inherited>false</inherited>
- <configuration>
- <images>
- <image>
- <name>onap/multicloud/multicloud-openstack-newton</name>
- <build>
- <cleanup>try</cleanup>
- <dockerFileDir>${basedir}/docker/</dockerFileDir>
- <dockerFile>${basedir}/docker/Dockerfile</dockerFile>
- <tags>
- <tag>${project.version}-STAGING-latest</tag>
- </tags>
- </build>
- </image>
- </images>
- </configuration>
- <executions>
- <execution>
- <id>generate-images</id>
- <phase>package</phase>
- <goals>
- <goal>build</goal>
- </goals>
- </execution>
- <execution>
- <id>push-images</id>
- <phase>deploy</phase>
- <goals>
- <goal>build</goal>
- <goal>push</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
</project>
diff --git a/newton/requirements.txt b/newton/requirements.txt
index 71654d76..cb42f78c 100644
--- a/newton/requirements.txt
+++ b/newton/requirements.txt
@@ -1,14 +1,19 @@
-pbr!=2.1.0,>=2.0.0 # Apache-2.0
+pbr!=2.1.0,>=2.0.0
# rest framework
-Django==1.9.6 # BSD
-djangorestframework==3.3.3 # BSD
+Django==1.9.6
+djangorestframework==3.3.3
# for call rest api
-httplib2==0.9.2 # MIT
+httplib2==0.9.2
# for call openstack auth and transport api
-keystoneauth1==2.19.0 # Apache-2.0
+keystoneauth1==2.19.0
-# for memcached
-python-memcached # PSF
+#python-memcached
+python-memcached
+
+# for unit test
+coverage==4.2
+mock==2.0.0
+unittest_xml_reporting==1.12.0
diff --git a/newton/run.sh b/newton/run.sh
index 0c88c903..0e2bee32 100755
--- a/newton/run.sh
+++ b/newton/run.sh
@@ -13,16 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-sed -i "s/MSB_SERVICE_ADDR =.*/MSB_SERVICE_ADDR = \"${MSB_ADDR}\"/g" newton/pub/config/config.py
-sed -i "s/MSB_SERVICE_PORT =.*/MSB_SERVICE_PORT = \"${MSB_PORT}\"/g" newton/pub/config/config.py
-sed -i "s/AAI_ADDR =.*/AAI_ADDR = \"${AAI_ADDR}\"/g" newton/pub/config/config.py
-sed -i "s/AAI_PORT =.*/AAI_PORT = \"${AAI_PORT}\"/g" newton/pub/config/config.py
-sed -i "s/AAI_SCHEMA_VERSION =.*/AAI_SCHEMA_VERSION = \"${AAI_SCHEMA_VERSION}\"/g" newton/pub/config/config.py
-sed -i "s/AAI_USERNAME =.*/AAI_USERNAME = \"${AAI_USERNAME}\"/g" newton/pub/config/config.py
-sed -i "s/AAI_PASSWORD =.*/AAI_PASSWORD = \"${AAI_PASSWORD}\"/g" newton/pub/config/config.py
-
memcached -d -m 2048 -u root -c 1024 -p 11211 -P /tmp/memcached1.pid
-
+export PYTHONPATH=lib/share
nohup python manage.py runserver 0.0.0.0:9003 2>&1 &
while [ ! -f logs/runtime_newton.log ]; do
diff --git a/newton/setup.cfg b/newton/setup.cfg
deleted file mode 100644
index d5b74b07..00000000
--- a/newton/setup.cfg
+++ /dev/null
@@ -1,24 +0,0 @@
-[metadata]
-name = openstack-multicloud
-summary = Python Application Layer for OpenStack API usage
-author = ONAP
-license = Apache-2
-classifier =
- Environment :: ONAP
- Intended Audience :: Information Technology
- Intended Audience :: System Administrators
- License :: OSI Approved :: Apache Software License
- Operating System :: POSIX :: Linux
- Programming Language :: Python
- Programming Language :: Python :: 2
- Programming Language :: Python :: 2.7
- Programming Language :: Python :: 3
- Programming Language :: Python :: 3.5
-
-[files]
-packages =
- newton
-
-[entry_points]
-wsgi_scripts =
- multicloud-api = newton.wsgi:get_application
diff --git a/newton/setup.py b/newton/setup.py
deleted file mode 100644
index 0e04baae..00000000
--- a/newton/setup.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2017 Intel Corporation
-#
-# 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
-import setuptools
-
-setuptools.setup(
- setup_requires=['pbr'],
- pbr=True)
diff --git a/newton/test-requirements.txt b/newton/test-requirements.txt
deleted file mode 100644
index 91213a4c..00000000
--- a/newton/test-requirements.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-coverage==4.2 # Apache-2.0
-mock==2.0.0 # BSD
-unittest_xml_reporting==1.12.0 #BSD
diff --git a/newton/tox.ini b/newton/tox.ini
index 919ad18f..70ca1ae5 100644
--- a/newton/tox.ini
+++ b/newton/tox.ini
@@ -6,15 +6,10 @@ skipsdist = true
downloadcache = ~/cache/pip
[testenv]
-passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
-deps =
- -r{toxinidir}/requirements.txt
- -r{toxinidir}/test-requirements.txt
-commands =
- coverage run --branch manage.py test
-
-[testenv:cover]
-commands =
- coverage html --omit=".tox/*,*tests*,*__init__.py"
- coverage report --omit=".tox/*,*tests*,*__init__.py" --fail-under=30
- coverage xml -i
+setenv =
+ PYTHONPATH = {toxinidir}/../share
+deps = -r{toxinidir}/requirements.txt
+commands =
+ coverage run --branch manage.py test
+ coverage report --omit=".tox/*,*tests*,*__init__.py" --fail-under=30
+ coverage xml -i