diff options
author | Bin Yang <bin.yang@windriver.com> | 2018-08-22 12:07:47 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-22 12:07:47 +0000 |
commit | 3e9f88b3f2a27a9bf9104719bb0b21312588b052 (patch) | |
tree | 104243d80b07ed5752667bb1f567565c8f28f60e | |
parent | 6cdf1099eeeea0fa818f13cafb99254d37f140e7 (diff) | |
parent | 98bf3833b9424314fa07a787cd572ba59617b3b5 (diff) |
Merge "API upgradeing for ocata"
-rw-r--r-- | ocata/ocata/extensions/urlsV1.py | 24 | ||||
-rw-r--r-- | ocata/ocata/extensions/views/extensions.py | 12 | ||||
-rw-r--r-- | ocata/ocata/proxy/views/identityV3.py | 48 | ||||
-rw-r--r-- | ocata/ocata/registration/views/registration.py | 19 | ||||
-rw-r--r-- | ocata/ocata/settings.py | 3 | ||||
-rw-r--r-- | ocata/ocata/urls.py | 8 |
6 files changed, 114 insertions, 0 deletions
diff --git a/ocata/ocata/extensions/urlsV1.py b/ocata/ocata/extensions/urlsV1.py new file mode 100644 index 00000000..0d6e3ada --- /dev/null +++ b/ocata/ocata/extensions/urlsV1.py @@ -0,0 +1,24 @@ +# 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.conf.urls import url +from rest_framework.urlpatterns import format_suffix_patterns + +from ocata.extensions.views import extensions + +urlpatterns = [ + url(r'^sions/?$', extensions.APIv1Extensions.as_view()), +] + +urlpatterns = format_suffix_patterns(urlpatterns) diff --git a/ocata/ocata/extensions/views/extensions.py b/ocata/ocata/extensions/views/extensions.py index 2c499f36..bd90a119 100644 --- a/ocata/ocata/extensions/views/extensions.py +++ b/ocata/ocata/extensions/views/extensions.py @@ -27,3 +27,15 @@ class Extensions(newton_extensions.Extensions): self._logger = logger self.proxy_prefix = settings.MULTICLOUD_PREFIX +class APIv1Extensions(Extensions): + + def __init__(self): + self._logger = logger + self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX + + + def get(self, request, cloud_owner="", cloud_region_id=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Extensions,self).get(request, vimid) diff --git a/ocata/ocata/proxy/views/identityV3.py b/ocata/ocata/proxy/views/identityV3.py index eaeeca47..ed0443dc 100644 --- a/ocata/ocata/proxy/views/identityV3.py +++ b/ocata/ocata/proxy/views/identityV3.py @@ -32,3 +32,51 @@ class TokensV2(newton_identityV3.TokensV2): def __init__(self): self.proxy_prefix = settings.MULTICLOUD_PREFIX self._logger = logger + +class APIv1Tokens(Tokens): + def __init__(self): + super(APIv1Tokens, self).__init__() + self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX + + + def get(self, request, cloud_owner="", cloud_region_id=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id)) + #self._logger.debug("META> %s" % request.META) + #self._logger.debug("data> %s" % request.data) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Tokens, self).get(request, vimid) + + + def post(self, request, cloud_owner="", cloud_region_id=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id)) + #self._logger.debug("META> %s" % request.META) + #self._logger.debug("data> %s" % request.data) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Tokens,self).post(request, vimid) + + +class APIv1TokensV2(TokensV2): + def __init__(self): + super(APIv1TokensV2, self).__init__() + self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX + + + def get(self, request, cloud_owner="", cloud_region_id=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id)) + #self._logger.debug("META> %s" % request.META) + #self._logger.debug("data> %s" % request.data) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1TokensV2, self).get(request, vimid) + + + def post(self, request, cloud_owner="", cloud_region_id=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id)) + #self._logger.debug("META> %s" % request.META) + #self._logger.debug("data> %s" % request.data) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1TokensV2,self).post(request, vimid) + diff --git a/ocata/ocata/registration/views/registration.py b/ocata/ocata/registration/views/registration.py index ccaea45a..4f8180b4 100644 --- a/ocata/ocata/registration/views/registration.py +++ b/ocata/ocata/registration/views/registration.py @@ -374,3 +374,22 @@ class Registry(newton_registration.Registry): 'hpa-attribute-value': '{{\"value\":\"{0}\"}}'.format(cloud_dpdk_info.get("libversion")) }) return ovsdpdk_capability + +class RegistryV1(Registry): + def __init__(self): + self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX + self.aai_base_url = settings.AAI_BASE_URL + self._logger = logger + + def post(self, request, cloud_owner="", cloud_region_id=""): + self._logger.info("registration with : %s, %s" % (cloud_owner, cloud_region_id)) + self._logger.debug("with data: %s" % request.data) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(RegistryV1, self).post(request, vimid) + + def delete(self, request, cloud_owner="", cloud_region_id=""): + self._logger.debug("unregister cloud region: %s, %s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(RegistryV1, self).delete(request, vimid) diff --git a/ocata/ocata/settings.py b/ocata/ocata/settings.py index f9f040ba..1e86178e 100644 --- a/ocata/ocata/settings.py +++ b/ocata/ocata/settings.py @@ -97,6 +97,9 @@ MSB_SERVICE_PORT = os.environ.get('MSB_PORT', "80") MULTICLOUD_PREFIX = "http://%s:%s/api/multicloud-ocata/v0" % ( MSB_SERVICE_ADDR, MSB_SERVICE_PORT) +MULTICLOUD_API_V1_PREFIX = "http://%s:%s/api/multicloud-ocata/v1" % ( + 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") diff --git a/ocata/ocata/urls.py b/ocata/ocata/urls.py index bcac8669..525650df 100644 --- a/ocata/ocata/urls.py +++ b/ocata/ocata/urls.py @@ -44,6 +44,14 @@ urlpatterns = [ url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)/vesagent/?$', vesagent_ctrl.VesAgentCtrl.as_view()), + # API upgrading + url(r'^api/multicloud-ocata/v1/(?P<vimid>[0-9a-zA-Z_-]+)/registry$', + registration.RegistryV1.as_view()), + url(r'^api/multicloud-ocata/v1/(?P<vimid>[0-9a-zA-Z_-]+)$', + registration.RegistryV1.as_view()), + url(r'^api/multicloud-ocata/v1/(?P<vimid>[0-9a-zA-Z_-]+)/exten', + include('ocata.extensions.urlsV1')), + ] |