From 4ae8aa7ee2389fcbe48046e85860eec659d428bc Mon Sep 17 00:00:00 2001 From: Huang Haibin Date: Mon, 15 Oct 2018 16:42:22 +0800 Subject: Upgrade vesagent v1 for ocata Change-Id: Icf852237f56fd587b092c0ff9743e8fdb738aba5 Issue-ID: MULTICLOUD-378 Signed-off-by: Huang Haibin --- ocata/ocata/urls.py | 2 ++ ocata/ocata/vesagent/vesagent_ctrl.py | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'ocata') diff --git a/ocata/ocata/urls.py b/ocata/ocata/urls.py index 34569968..d1601d6c 100644 --- a/ocata/ocata/urls.py +++ b/ocata/ocata/urls.py @@ -60,6 +60,8 @@ urlpatterns = [ '(?P[0-9a-zA-Z_-]{20,})/', include('ocata.requests.urlsV1')), url(r'^api/multicloud-ocata/v1/(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z_-]+)/capacity_check/?$', capacity.APIv1CapacityCheck.as_view()), + url(r'^api/multicloud-ocata/v1/(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z_-]+)/vesagent/?$', + vesagent_ctrl.APIv1VesAgentCtrl.as_view()), url(r'^api/multicloud-ocata/v1/(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z_-]+)/infra_workload/?$', infra_workload.APIv1InfraWorkload.as_view()), url(r'^api/multicloud-ocata/v1/(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z_-]+)/infra_workload/(?P[0-9a-zA-Z_-]*)/?$', diff --git a/ocata/ocata/vesagent/vesagent_ctrl.py b/ocata/ocata/vesagent/vesagent_ctrl.py index 99d55b62..3293f829 100644 --- a/ocata/ocata/vesagent/vesagent_ctrl.py +++ b/ocata/ocata/vesagent/vesagent_ctrl.py @@ -404,3 +404,53 @@ class VesAgentCtrl(APIView): self._logger.debug("return without backlog") return None + + +class APIv1VesAgentCtrl(VesAgentCtrl): + + def __init__(self): + super(APIv1VesAgentCtrl, self).__init__() + # self._logger = logger + self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX + + + def get(self, request, cloud_owner="", cloud_region_id=""): + ''' + :param request: + :param cloud_owner: + :param cloud_region_id: + :return: + ''' + 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(APIv1VesAgentCtrl,self).get(request, vimid) + + + def post(self, request, cloud_owner="", cloud_region_id=""): + ''' + wrapper for inherited API with VIM ID + :param request: + :param cloud_owner: + :param cloud_region_id: + :return: + ''' + 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(APIv1VesAgentCtrl,self).post(request, vimid) + + + def delete(self, request, cloud_owner="", cloud_region_id=""): + ''' + wrapper of inherited API with VIM ID + :param request: + :param cloud_owner: + :param cloud_region_id: + :return: + ''' + 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(APIv1VesAgentCtrl,self).delete(request, vimid) + -- cgit 1.2.3-korg