API upgrading for OPENOAPI 61/60661/1
authorBin Yang <bin.yang@windriver.com>
Wed, 15 Aug 2018 06:11:24 +0000 (06:11 +0000)
committerBin Yang <bin.yang@windriver.com>
Wed, 15 Aug 2018 06:11:24 +0000 (06:11 +0000)
Change-Id: I8d0fdc7671d9333ee24e77dda9e07c32a0767950
Issue-ID: MULTICLOUD-297
Signed-off-by: Bin Yang <bin.yang@windriver.com>
16 files changed:
share/newton_base/openoapi/flavor.py
share/newton_base/openoapi/hosts.py
share/newton_base/openoapi/hypervisor.py
share/newton_base/openoapi/image.py
share/newton_base/openoapi/limits.py
share/newton_base/openoapi/network.py
share/newton_base/openoapi/server.py
share/newton_base/openoapi/subnet.py
share/newton_base/openoapi/tenants.py
share/newton_base/openoapi/volume.py
share/newton_base/openoapi/vport.py
windriver/titanium_cloud/registration/views/registration.py
windriver/titanium_cloud/requests/urlsV1.py [new file with mode: 0644]
windriver/titanium_cloud/resource/views/capacity.py
windriver/titanium_cloud/urls.py
windriver/titanium_cloud/vesagent/vesagent_ctrl.py

index 4b3c597..af811f6 100644 (file)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 
 from common.exceptions import VimDriverNewtonException
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -110,6 +111,8 @@ class Flavors(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
             }
             content.update(vim_dict)
@@ -209,6 +212,8 @@ class Flavors(APIView):
                 vim_dict = {
                     "vimName": vim["name"],
                     "vimId": vim["vimId"],
+                    "cloud-owner": vim["cloud_owner"],
+                    "cloud-region-id": vim["cloud_region_id"],
                     "tenantId": tenantid,
                      "returnCode": 0,
                 }
@@ -246,6 +251,8 @@ class Flavors(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
                  "returnCode": 1,
             }
@@ -396,3 +403,25 @@ class Flavors(APIView):
         logger.info("request returns with status %s" % resp.status_code)
 
         return resp
+
+
+
+class APIv1Flavors(Flavors):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", flavorid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Flavors, self).get(request, vimid, tenantid, flavorid)
+
+    def post(self, request, cloud_owner="", cloud_region_id="", tenantid="", flavorid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Flavors, self).post(request, vimid, tenantid, flavorid)
+
+    def delete(self, request, cloud_owner="", cloud_region_id="", tenantid="", flavorid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Flavors, self).delete(request, vimid, tenantid, flavorid)
index 2d50886..d93336a 100644 (file)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 from common.exceptions import VimDriverNewtonException
 
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -97,3 +98,11 @@ class Hosts(APIView):
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
+
+class APIv1Hosts(Hosts):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", hostname=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Hosts, self).get(request, vimid, tenantid, hostname)
index e920130..eb0debd 100755 (executable)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 \r
 from common.exceptions import VimDriverNewtonException\r
 from newton_base.util import VimDriverUtils\r
+from common.msapi import extsys\r
 \r
 logger = logging.getLogger(__name__)\r
 \r
@@ -48,7 +49,7 @@ class Hypervisors(APIView):
             query = VimDriverUtils.get_query_part(request)\r
             content, status_code = self.get_hypervisors(query, vimid, tenantid, hypervisorid)\r
 \r
-            logger.info("response with status = %s" % resp.status_code)\r
+            logger.info("response with status = %s" % status_code)\r
 \r
             return Response(data=content, status=status_code)\r
         except VimDriverNewtonException as e:\r
@@ -71,7 +72,7 @@ class Hypervisors(APIView):
         vim["domain"] = "Default"\r
         sess = VimDriverUtils.get_session(vim, tenantid)\r
 \r
-        logger.info("making request with URI:%s" % req_resouce)\r
+        logger.info("making request with URI:%s" % req_resource)\r
 \r
         resp = sess.get(req_resource, endpoint_filter = self.service)\r
 \r
@@ -84,3 +85,17 @@ class Hypervisors(APIView):
 \r
         return content, resp.status_code\r
 \r
+\r
+class APIv1Hypervisors(Hypervisors):\r
+\r
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", hypervisorid=""):\r
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))\r
+\r
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)\r
+        return super(APIv1Hypervisors, self).get(request, vimid, tenantid, hypervisorid)\r
+\r
+    def get_hypervisors(self, request, cloud_owner="", cloud_region_id="", tenantid="", hypervisorid=""):\r
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))\r
+\r
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)\r
+        return super(APIv1Hypervisors, self).get_hypervisors(request, vimid, tenantid, hypervisorid)\r
index 7a18bdb..e27d019 100644 (file)
@@ -24,6 +24,7 @@ from rest_framework.views import APIView
 from common.exceptions import VimDriverNewtonException
 
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -87,7 +88,7 @@ class Images(APIView):
         try:
             # prepare request resource to vim instance
             query = VimDriverUtils.get_query_part(request)
-            content, status_code = self.get_images(query, vimid, tenantid, imageid)
+            content, status_code = self._get_images(query, vimid, tenantid, imageid)
             return Response(data=content, status=status_code)
         except VimDriverNewtonException as e:
             logger.error("response with status = %s" % e.status_code)
@@ -100,7 +101,7 @@ class Images(APIView):
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
-    def get_images(self, query="", vimid="", tenantid="", imageid=""):
+    def _get_images(self, query="", vimid="", tenantid="", imageid=""):
         logger.info("vimid, tenantid, imageid, query = %s,%s,%s,%s" % (vimid, tenantid, imageid, query))
         # prepare request resource to vim instance
         req_resouce = "v2/images"
@@ -149,7 +150,7 @@ class Images(APIView):
         try:
             #check if created already: check name
             query = "name=%s" % request.data["name"]
-            content, status_code = self.get_images(query, vimid, tenantid)
+            content, status_code = self._get_images(query, vimid, tenantid)
             existed = False
             if status_code == 200:
                 for image in content["images"]:
@@ -253,3 +254,23 @@ class Images(APIView):
             logger.error(traceback.format_exc())
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+class APIv1Images(Images):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", imageid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Images, self).get(request, vimid, tenantid, imageid)
+
+    def post(self, request, cloud_owner="", cloud_region_id="", tenantid="", imageid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Images, self).post(request, vimid, tenantid, imageid)
+
+    def delete(self, request, cloud_owner="", cloud_region_id="", tenantid="", imageid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Images, self).delete(request, vimid, tenantid, imageid)
index 5789dfd..fad710f 100644 (file)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 from common.exceptions import VimDriverNewtonException
 
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -56,6 +57,8 @@ class Limits(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
             }
             content_all.update(vim_dict)
@@ -91,3 +94,12 @@ class Limits(APIView):
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
+
+class APIv1Limits(Limits):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Limits, self).get(request, vimid, tenantid)
+
index b780ab4..9ad7a83 100644 (file)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 from common.exceptions import VimDriverNewtonException
 
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -45,7 +46,7 @@ class Networks(APIView):
             pass
         try:
             query = VimDriverUtils.get_query_part(request)
-            content, status_code = self.get_networks(query, vimid, tenantid, networkid)
+            content, status_code = self._get_networks(query, vimid, tenantid, networkid)
             logger.info("response with status = %s" % status_code)
             return Response(data=content, status=status_code)
 
@@ -60,7 +61,7 @@ class Networks(APIView):
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
-    def get_networks(self, query, vimid="", tenantid="", networkid=""):
+    def _get_networks(self, query, vimid="", tenantid="", networkid=""):
 
         # prepare request resource to vim instance
         req_resouce = "v2.0/networks"
@@ -82,6 +83,8 @@ class Networks(APIView):
         vim_dict = {
             "vimName": vim["name"],
             "vimId": vim["vimId"],
+            "cloud-owner": vim["cloud_owner"],
+            "cloud-region-id": vim["cloud_region_id"],
             "tenantId": tenantid,
         }
         content.update(vim_dict)
@@ -108,7 +111,7 @@ class Networks(APIView):
         try:
             #check if created already: check name
             query = "name=%s" % request.data["name"]
-            content, status_code = self.get_networks(query, vimid, tenantid)
+            content, status_code = self._get_networks(query, vimid, tenantid)
             existed = False
             if status_code == 200:
                 for network in content["networks"]:
@@ -143,6 +146,8 @@ class Networks(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
                 "returnCode": 1,
             }
@@ -190,5 +195,23 @@ class Networks(APIView):
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
 
-class Subnets(APIView):
-    pass
+
+class APIv1Networks(Networks):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", networkid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Networks, self).get(request, vimid, tenantid, networkid)
+
+    def post(self, request, cloud_owner="", cloud_region_id="", tenantid="", networkid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Networks, self).post(request, vimid, tenantid, networkid)
+
+    def delete(self, request, cloud_owner="", cloud_region_id="", tenantid="", networkid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Networks, self).delete(request, vimid, tenantid, networkid)
index cf2fffe..c5011f1 100644 (file)
@@ -24,6 +24,7 @@ from rest_framework.views import APIView
 
 from common.exceptions import VimDriverNewtonException
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -267,6 +268,8 @@ class Servers(APIView):
         vim_dict = {
             "vimName": vim["name"],
             "vimId": vim["vimId"],
+            "cloud-owner": vim["cloud_owner"],
+            "cloud-region-id": vim["cloud_region_id"],
             "tenantId": tenantid,
         }
         content.update(vim_dict)
@@ -414,6 +417,8 @@ class Servers(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
                 "returnCode": 1,
             }
@@ -470,3 +475,23 @@ class Servers(APIView):
             logger.error(traceback.format_exc())
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+class APIv1Servers(Servers):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", serverid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Servers, self).get(request, vimid, tenantid, serverid)
+
+    def post(self, request, cloud_owner="", cloud_region_id="", tenantid="", serverid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Servers, self).post(request, vimid, tenantid, serverid)
+
+    def delete(self, request, cloud_owner="", cloud_region_id="", tenantid="", serverid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Servers, self).delete(request, vimid, tenantid, serverid)
index 02f24b4..9ff61f2 100644 (file)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 from common.exceptions import VimDriverNewtonException
 
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -48,7 +49,7 @@ class Subnets(APIView):
         try:
             # prepare request resource to vim instance
             query = VimDriverUtils.get_query_part(request)
-            content, status_code = self.get_subnets(query, vimid, tenantid, subnetid)
+            content, status_code = self._get_subnets(query, vimid, tenantid, subnetid)
             logger.info("request returns with status %s" % status_code)
             return Response(data=content, status=status_code)
         except VimDriverNewtonException as e:
@@ -62,7 +63,7 @@ class Subnets(APIView):
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
-    def get_subnets(self, query="", vimid="", tenantid="", subnetid=""):
+    def _get_subnets(self, query="", vimid="", tenantid="", subnetid=""):
 
         # prepare request resource to vim instance
         req_resouce = "v2.0/subnets"
@@ -84,6 +85,8 @@ class Subnets(APIView):
         vim_dict = {
             "vimName": vim["name"],
             "vimId": vim["vimId"],
+            "cloud-owner": vim["cloud_owner"],
+            "cloud-region-id": vim["cloud_region_id"],
             "tenantId": tenantid,
         }
         content.update(vim_dict)
@@ -110,7 +113,7 @@ class Subnets(APIView):
         try:
             #check if created already: check name
             query = "name=%s" % request.data["name"]
-            content, status_code = self.get_subnets(query, vimid, tenantid)
+            content, status_code = self._get_subnets(query, vimid, tenantid)
             existed = False
             if status_code == 200:
                 for subnet in content["subnets"]:
@@ -143,6 +146,8 @@ class Subnets(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
                 "returnCode": 1,
             }
@@ -189,3 +194,24 @@ class Subnets(APIView):
             logger.error(traceback.format_exc())
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+
+class APIv1Subnets(Subnets):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", subnetid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Subnets, self).get(request, vimid, tenantid, subnetid)
+
+    def post(self, request, cloud_owner="", cloud_region_id="", tenantid="", subnetid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Subnets, self).post(request, vimid, tenantid, subnetid)
+
+    def delete(self, request, cloud_owner="", cloud_region_id="", tenantid="", subnetid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Subnets, self).delete(request, vimid, tenantid, subnetid)
index db5cc8a..76fd213 100644 (file)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 
 from common.exceptions import VimDriverNewtonException
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -62,6 +63,8 @@ class Tenants(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
             }
             content.update(vim_dict)
 
@@ -93,3 +96,14 @@ class Tenants(APIView):
             return Response(
                 data={'error': str(e)},
                 status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+
+
+class APIv1Tenants(Tenants):
+
+    def get(self, request, cloud_owner="", cloud_region_id=""):
+        self._logger.info("registration with : %s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Tenants, self).get(request, vimid)
+
index d9d9598..827baea 100644 (file)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 from common.exceptions import VimDriverNewtonException
 
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -48,7 +49,7 @@ class Volumes(APIView):
         try:
             # prepare request resource to vim instance
             query = VimDriverUtils.get_query_part(request)
-            content, status_code = self.get_volumes(query, vimid, tenantid, volumeid)
+            content, status_code = self._get_volumes(query, vimid, tenantid, volumeid)
             logger.info("response with status = %s" % status_code)
             return Response(data=content, status=status_code)
         except VimDriverNewtonException as e:
@@ -62,7 +63,7 @@ class Volumes(APIView):
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
-    def get_volumes(self, query="", vimid="", tenantid="", volumeid=None):
+    def _get_volumes(self, query="", vimid="", tenantid="", volumeid=None):
 
         # prepare request resource to vim instance
         req_resouce = "volumes"
@@ -85,6 +86,8 @@ class Volumes(APIView):
         vim_dict = {
             "vimName": vim["name"],
             "vimId": vim["vimId"],
+            "cloud-owner": vim["cloud_owner"],
+            "cloud-region-id": vim["cloud_region_id"],
             "tenantId": tenantid,
         }
         content.update(vim_dict)
@@ -111,7 +114,7 @@ class Volumes(APIView):
         try:
             #check if created already: check name
             query = "name=%s" % request.data["name"]
-            content, status_code = self.get_volumes(query, vimid, tenantid)
+            content, status_code = self._get_volumes(query, vimid, tenantid)
             existed = False
             if status_code == 200:
                 for volume in content["volumes"]:
@@ -145,6 +148,8 @@ class Volumes(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
                 "returnCode": 1,
             }
@@ -188,3 +193,23 @@ class Volumes(APIView):
             logger.error(traceback.format_exc())
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+class APIv1Volumes(Volumes):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", volumeid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Volumes, self).get(request, vimid, tenantid, volumeid)
+
+    def post(self, request, cloud_owner="", cloud_region_id="", tenantid="", volumeid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Volumes, self).post(request, vimid, tenantid, volumeid)
+
+    def delete(self, request, cloud_owner="", cloud_region_id="", tenantid="", volumeid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Volumes, self).delete(request, vimid, tenantid, volumeid)
index 7f916d3..648ec02 100644 (file)
@@ -22,6 +22,7 @@ from rest_framework.views import APIView
 from common.exceptions import VimDriverNewtonException
 
 from newton_base.util import VimDriverUtils
+from common.msapi import extsys
 
 logger = logging.getLogger(__name__)
 
@@ -47,7 +48,7 @@ class Vports(APIView):
         try:
             # prepare request resource to vim instance
             query = VimDriverUtils.get_query_part(request)
-            content, status_code = self.get_ports(query, vimid, tenantid, portid)
+            content, status_code = self._get_ports(query, vimid, tenantid, portid)
             logger.info("response with status = %s" % status_code)
             return Response(data=content, status=status_code)
         except VimDriverNewtonException as e:
@@ -61,7 +62,7 @@ class Vports(APIView):
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
-    def get_ports(self, query="", vimid="", tenantid="", portid=""):
+    def _get_ports(self, query="", vimid="", tenantid="", portid=""):
         vim = VimDriverUtils.get_vim_info(vimid)
         sess = VimDriverUtils.get_session(vim, tenantid)
 
@@ -87,6 +88,8 @@ class Vports(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
             }
             content.update(vim_dict)
@@ -120,7 +123,7 @@ class Vports(APIView):
         try:
             #check if already created: name
             query = "name=%s" % request.data["name"]
-            content, status_code = self.get_ports(query, vimid, tenantid, portid)
+            content, status_code = self._get_ports(query, vimid, tenantid, portid)
             existed = False
             if status_code == 200:
                 for port in content["ports"]:
@@ -135,7 +138,7 @@ class Vports(APIView):
                     return Response(data=port, status=status_code)
 
             #otherwise create a new one
-            return self.create_port(request, vimid, tenantid)
+            return self._create_port(request, vimid, tenantid)
         except VimDriverNewtonException as e:
             logger.error("response with status = %s" % e.status_code)
             return Response(data={'error': e.content}, status=e.status_code)
@@ -147,7 +150,7 @@ class Vports(APIView):
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
-    def create_port(self, request, vimid, tenantid):
+    def _create_port(self, request, vimid, tenantid):
         vim = VimDriverUtils.get_vim_info(vimid)
         sess = VimDriverUtils.get_session(vim, tenantid)
         if sess:
@@ -185,6 +188,8 @@ class Vports(APIView):
             vim_dict = {
                 "vimName": vim["name"],
                 "vimId": vim["vimId"],
+                "cloud-owner": vim["cloud_owner"],
+                "cloud-region-id": vim["cloud_region_id"],
                 "tenantId": tenantid,
                 "returnCode": 1,
             }
@@ -222,3 +227,24 @@ class Vports(APIView):
             logger.error(traceback.format_exc())
             return Response(data={'error': str(e)},
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+
+class APIv1Vports(Vports):
+
+    def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", portid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Vports, self).get(request, vimid, tenantid, portid)
+
+    def post(self, request, cloud_owner="", cloud_region_id="", tenantid="", portid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Vports, self).post(request, vimid, tenantid, portid)
+
+    def delete(self, request, cloud_owner="", cloud_region_id="", tenantid="", portid=""):
+        self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+        vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+        return super(APIv1Vports, self).delete(request, vimid, tenantid, portid)
index b54772e..5bf3f1c 100644 (file)
@@ -365,7 +365,8 @@ class Registry(newton_registration.Registry):
         return instruction_capability
 
 
-class RegistryV1(Registry):
+class APIv1Registry(Registry):
+
     def __init__(self):
         self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
         self.aai_base_url = settings.AAI_BASE_URL
@@ -373,13 +374,12 @@ class RegistryV1(Registry):
 
     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)
+        return super(APIv1Registry, 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)
+        return super(APIv1Registry, self).delete(request, vimid)
diff --git a/windriver/titanium_cloud/requests/urlsV1.py b/windriver/titanium_cloud/requests/urlsV1.py
new file mode 100644 (file)
index 0000000..f155244
--- /dev/null
@@ -0,0 +1,47 @@
+# 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 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_-]+))?',
+        network.APIv1Networks.as_view()),
+    url(r'^subnets(/(?P<subnetid>[0-9a-zA-Z_-]+))?',
+        subnet.APIv1Subnets.as_view()),
+    url(r'^images(/(?P<imageid>[0-9a-zA-Z_-]+))?',
+        image.APIv1Images.as_view()),
+    url(r'^volumes(/(?P<volumeid>[0-9a-zA-Z_-]+))?',
+        volume.APIv1Volumes.as_view()),
+    url(r'^servers(/(?P<serverid>[0-9a-zA-Z_-]+))?',
+        server.APIv1Servers.as_view()),
+    url(r'^ports(/(?P<portid>[0-9a-zA-Z_-]+))?',
+        vport.APIv1Vports.as_view()),
+    url(r'^flavors(/(?P<flavorid>[0-9a-zA-Z_-]+))?',
+        flavor.APIv1Flavors.as_view()),
+    url(r'^limits$', limits.APIv1Limits.as_view()),
+    url(r'^hosts(/(?P<hostname>[0-9a-zA-Z_-]+))?', hosts.APIv1Hosts.as_view()),
+]
+
+urlpatterns = format_suffix_patterns(urlpatterns)
index 26a673c..74470ca 100644 (file)
@@ -142,7 +142,7 @@ class CapacityCheck(APIView):
 
 
 
-class CapacityCheckV1(APIView):
+class APIv1CapacityCheck(APIView):
 
     def __init__(self):
         self._logger = logger
@@ -152,4 +152,5 @@ class CapacityCheckV1(APIView):
         self._logger.debug("META> %s" % request.META)
 
         vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
-        return super(CapacityCheckV1, self).post(request, vimid)
+        return super(APIv1CapacityCheck, self).post(request, vimid)
+
index 5a4e64b..d56be23 100644 (file)
@@ -46,25 +46,25 @@ urlpatterns = [
 
 #API upgrading
     url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/registry/?$',
-        registration.RegistryV1.as_view()),
+        registration.APIv1Registry.as_view()),
     url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/?$',
-        registration.RegistryV1.as_view()),
+        registration.APIv1Registry.as_view()),
     url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/exten',
         include('titanium_cloud.extensions.urlsV1')),
     url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/',
         include('titanium_cloud.proxy.urlsV1')),
-#    url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/tenants/?$',
-#        tenants.Tenants.as_view()),
-#    url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/'
-#        '(?P<tenantid>[0-9a-zA-Z_-]{20,})/', include('titanium_cloud.requests.urls')),
+    url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/tenants/?$',
+        tenants.APIv1Tenants.as_view()),
+    url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/'
+        '(?P<tenantid>[0-9a-zA-Z_-]{20,})/', include('titanium_cloud.requests.urlsV1')),
     # CapacityCheck
     url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/capacity_check/?$',
-        capacity.CapacityCheckV1.as_view()),
+        capacity.APIv1CapacityCheck.as_view()),
     # events
 #    url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/events_check/?$',
 #        events.EventsCheck.as_view()),
     url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/vesagent/?$',
-        vesagent_ctrl.VesAgentCtrlV1.as_view()),
+        vesagent_ctrl.APIv1VesAgentCtrl.as_view()),
 ]
 
 
index 39c3658..a85ce15 100644 (file)
@@ -406,7 +406,7 @@ class VesAgentCtrl(APIView):
         return None
 
 
-class VesAgentCtrlV1(VesAgentCtrl):
+class APIv1VesAgentCtrl(VesAgentCtrl):
 
     def __init__(self):
         self._logger = logger
@@ -421,10 +421,9 @@ class VesAgentCtrlV1(VesAgentCtrl):
         :return:
         '''
         self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
-        self._logger.debug("with META: %s" % request.META)
 
         vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
-        return super(VesAgentCtrlV1,self).get(request, vimid)
+        return super(APIv1VesAgentCtrl,self).get(request, vimid)
 
 
     def post(self, request, cloud_owner="", cloud_region_id=""):
@@ -436,9 +435,9 @@ class VesAgentCtrlV1(VesAgentCtrl):
         :return:
         '''
         self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
-        self._logger.debug("with META: %s, with data: %s" % (request.META, request.data))
+
         vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
-        return super(VesAgentCtrlV1,self).post(request, vimid)
+        return super(APIv1VesAgentCtrl,self).post(request, vimid)
 
 
     def delete(self, request, cloud_owner="", cloud_region_id=""):
@@ -450,7 +449,7 @@ class VesAgentCtrlV1(VesAgentCtrl):
         :return:
         '''
         self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
-        self._logger.debug("with META: %s" % request.META)
+
         vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
-        return super(VesAgentCtrlV1,self).delete(request, vimid)
+        return super(APIv1VesAgentCtrl,self).delete(request, vimid)