summaryrefslogtreecommitdiffstats
path: root/newton
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2017-03-06 10:00:56 +0800
committerBin Yang <bin.yang@windriver.com>2017-03-06 10:00:56 +0800
commitb8d675b348a470c636a9c81c8dc55d17e39e9af7 (patch)
tree240867045944c731996c6f040d16f4a6dfa72d05 /newton
parentb41ab02979b62317b187a278c26ef387345ed50d (diff)
Refactor subnets API for newton
Change-Id: Ib302b832f85f6ddeaad42ec7f9d1586329b3a940 Issue-Id: MULTIVIM-22 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'newton')
-rw-r--r--newton/newton/requests/views/subnet.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/newton/newton/requests/views/subnet.py b/newton/newton/requests/views/subnet.py
index 44f84202..24304633 100644
--- a/newton/newton/requests/views/subnet.py
+++ b/newton/newton/requests/views/subnet.py
@@ -44,7 +44,8 @@ class Subnets(APIView):
logger.debug("Subnets--get::> %s" % request.data)
try:
# prepare request resource to vim instance
- content, status_code = self.get_subnets(request, vimid, tenantid, subnetid)
+ query = VimDriverUtils.get_query_part(request)
+ content, status_code = self.get_subnets(query, vimid, tenantid, subnetid)
return Response(data=content, status=status_code)
except VimDriverNewtonException as e:
return Response(data={'error': e.content}, status=e.status_code)
@@ -52,7 +53,7 @@ class Subnets(APIView):
return Response(data={'error': str(e)},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
- def get_subnets(self, request, vimid="", tenantid="", subnetid=""):
+ def get_subnets(self, query="", vimid="", tenantid="", subnetid=""):
logger.debug("Subnets--get_subnets::> %s" % subnetid)
# prepare request resource to vim instance
@@ -60,7 +61,6 @@ class Subnets(APIView):
if subnetid:
req_resouce += "/%s" % subnetid
- query = VimDriverUtils.get_query_part(request)
if query:
req_resouce += "?%s" % query
@@ -82,11 +82,10 @@ class Subnets(APIView):
self.keys_mapping)
else:
# convert the key naming in the subnet specified by id
- old_subnet = content["subnet"]
- content.pop("subnet", None)
- VimDriverUtils.replace_key_by_mapping(old_subnet,
+ subnet = content.pop("subnet", None)
+ VimDriverUtils.replace_key_by_mapping(subnet,
self.keys_mapping)
- content.update(old_subnet)
+ content.update(subnet)
return content, resp.status_code
@@ -94,7 +93,8 @@ class Subnets(APIView):
logger.debug("Subnets--post::> %s" % request.data)
try:
#check if created already: check name
- content, status_code = self.get_subnets(request, vimid, tenantid)
+ query = "name=%s" % request.data["name"]
+ content, status_code = self.get_subnets(query, vimid, tenantid)
existed = False
if status_code == 200:
for subnet in content["subnets"]: