summaryrefslogtreecommitdiffstats
path: root/share/newton_base/openoapi
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2018-08-15 06:11:24 +0000
committerBin Yang <bin.yang@windriver.com>2018-08-15 06:11:24 +0000
commit400e1b7c35a1db4cdcf20f4453631bc0888a330f (patch)
tree49d1c5355fb2072f8be9975fa83ae93ae5d7dc60 /share/newton_base/openoapi
parent8eacf7b7496a7864313595dcf3780d83b423c338 (diff)
API upgrading for OPENOAPI
Change-Id: I8d0fdc7671d9333ee24e77dda9e07c32a0767950 Issue-ID: MULTICLOUD-297 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share/newton_base/openoapi')
-rw-r--r--share/newton_base/openoapi/flavor.py29
-rw-r--r--share/newton_base/openoapi/hosts.py9
-rwxr-xr-xshare/newton_base/openoapi/hypervisor.py19
-rw-r--r--share/newton_base/openoapi/image.py27
-rw-r--r--share/newton_base/openoapi/limits.py12
-rw-r--r--share/newton_base/openoapi/network.py33
-rw-r--r--share/newton_base/openoapi/server.py25
-rw-r--r--share/newton_base/openoapi/subnet.py32
-rw-r--r--share/newton_base/openoapi/tenants.py14
-rw-r--r--share/newton_base/openoapi/volume.py31
-rw-r--r--share/newton_base/openoapi/vport.py36
11 files changed, 246 insertions, 21 deletions
diff --git a/share/newton_base/openoapi/flavor.py b/share/newton_base/openoapi/flavor.py
index 4b3c5977..af811f67 100644
--- a/share/newton_base/openoapi/flavor.py
+++ b/share/newton_base/openoapi/flavor.py
@@ -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)
diff --git a/share/newton_base/openoapi/hosts.py b/share/newton_base/openoapi/hosts.py
index 2d50886f..d93336a4 100644
--- a/share/newton_base/openoapi/hosts.py
+++ b/share/newton_base/openoapi/hosts.py
@@ -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)
diff --git a/share/newton_base/openoapi/hypervisor.py b/share/newton_base/openoapi/hypervisor.py
index e9201307..eb0debd4 100755
--- a/share/newton_base/openoapi/hypervisor.py
+++ b/share/newton_base/openoapi/hypervisor.py
@@ -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 Hypervisors(APIView):
query = VimDriverUtils.get_query_part(request)
content, status_code = self.get_hypervisors(query, vimid, tenantid, hypervisorid)
- logger.info("response with status = %s" % resp.status_code)
+ logger.info("response with status = %s" % status_code)
return Response(data=content, status=status_code)
except VimDriverNewtonException as e:
@@ -71,7 +72,7 @@ class Hypervisors(APIView):
vim["domain"] = "Default"
sess = VimDriverUtils.get_session(vim, tenantid)
- logger.info("making request with URI:%s" % req_resouce)
+ logger.info("making request with URI:%s" % req_resource)
resp = sess.get(req_resource, endpoint_filter = self.service)
@@ -84,3 +85,17 @@ class Hypervisors(APIView):
return content, resp.status_code
+
+class APIv1Hypervisors(Hypervisors):
+
+ def get(self, request, cloud_owner="", cloud_region_id="", tenantid="", hypervisorid=""):
+ self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1Hypervisors, self).get(request, vimid, tenantid, hypervisorid)
+
+ def get_hypervisors(self, request, cloud_owner="", cloud_region_id="", tenantid="", hypervisorid=""):
+ self._logger.info("%s, %s" % (cloud_owner, cloud_region_id))
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1Hypervisors, self).get_hypervisors(request, vimid, tenantid, hypervisorid)
diff --git a/share/newton_base/openoapi/image.py b/share/newton_base/openoapi/image.py
index 7a18bdbd..e27d0190 100644
--- a/share/newton_base/openoapi/image.py
+++ b/share/newton_base/openoapi/image.py
@@ -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)
diff --git a/share/newton_base/openoapi/limits.py b/share/newton_base/openoapi/limits.py
index 5789dfd4..fad710f3 100644
--- a/share/newton_base/openoapi/limits.py
+++ b/share/newton_base/openoapi/limits.py
@@ -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)
+
diff --git a/share/newton_base/openoapi/network.py b/share/newton_base/openoapi/network.py
index b780ab42..9ad7a83f 100644
--- a/share/newton_base/openoapi/network.py
+++ b/share/newton_base/openoapi/network.py
@@ -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)
diff --git a/share/newton_base/openoapi/server.py b/share/newton_base/openoapi/server.py
index cf2fffef..c5011f15 100644
--- a/share/newton_base/openoapi/server.py
+++ b/share/newton_base/openoapi/server.py
@@ -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)
diff --git a/share/newton_base/openoapi/subnet.py b/share/newton_base/openoapi/subnet.py
index 02f24b4f..9ff61f2a 100644
--- a/share/newton_base/openoapi/subnet.py
+++ b/share/newton_base/openoapi/subnet.py
@@ -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)
diff --git a/share/newton_base/openoapi/tenants.py b/share/newton_base/openoapi/tenants.py
index db5cc8a8..76fd2137 100644
--- a/share/newton_base/openoapi/tenants.py
+++ b/share/newton_base/openoapi/tenants.py
@@ -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)
+
diff --git a/share/newton_base/openoapi/volume.py b/share/newton_base/openoapi/volume.py
index d9d95983..827baea9 100644
--- a/share/newton_base/openoapi/volume.py
+++ b/share/newton_base/openoapi/volume.py
@@ -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)
diff --git a/share/newton_base/openoapi/vport.py b/share/newton_base/openoapi/vport.py
index 7f916d3d..648ec02b 100644
--- a/share/newton_base/openoapi/vport.py
+++ b/share/newton_base/openoapi/vport.py
@@ -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)