summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--windriver/titanium_cloud/registration/views/registration.py8
-rw-r--r--windriver/titanium_cloud/requests/urlsV1.py47
-rw-r--r--windriver/titanium_cloud/resource/views/capacity.py5
-rw-r--r--windriver/titanium_cloud/urls.py16
-rw-r--r--windriver/titanium_cloud/vesagent/vesagent_ctrl.py13
16 files changed, 314 insertions, 42 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)
diff --git a/windriver/titanium_cloud/registration/views/registration.py b/windriver/titanium_cloud/registration/views/registration.py
index b54772e3..5bf3f1c5 100644
--- a/windriver/titanium_cloud/registration/views/registration.py
+++ b/windriver/titanium_cloud/registration/views/registration.py
@@ -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
index 00000000..f1552443
--- /dev/null
+++ b/windriver/titanium_cloud/requests/urlsV1.py
@@ -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)
diff --git a/windriver/titanium_cloud/resource/views/capacity.py b/windriver/titanium_cloud/resource/views/capacity.py
index 26a673c0..74470ca2 100644
--- a/windriver/titanium_cloud/resource/views/capacity.py
+++ b/windriver/titanium_cloud/resource/views/capacity.py
@@ -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)
+
diff --git a/windriver/titanium_cloud/urls.py b/windriver/titanium_cloud/urls.py
index 5a4e64b0..d56be236 100644
--- a/windriver/titanium_cloud/urls.py
+++ b/windriver/titanium_cloud/urls.py
@@ -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()),
]
diff --git a/windriver/titanium_cloud/vesagent/vesagent_ctrl.py b/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
index 39c36581..a85ce150 100644
--- a/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
+++ b/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
@@ -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)