summaryrefslogtreecommitdiffstats
path: root/newton
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2017-03-08 10:27:53 +0800
committerBin Yang <bin.yang@windriver.com>2017-03-08 10:27:53 +0800
commitaeca17f196c66dbda339d1efa76b210f34ebce1f (patch)
tree1797227bf307b6ae61fdec7b41e1b331912a7a97 /newton
parent9f729d2ed1700cfd9877da3b73b22015ace912fa (diff)
Refactor Networks API for newton
Change-Id: I407f2488f00307a864d78083167df54776b02808 Issue-Id: MULTIVIM-22 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'newton')
-rw-r--r--newton/newton/requests/views/network.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/newton/newton/requests/views/network.py b/newton/newton/requests/views/network.py
index ad17d398..0f591bee 100644
--- a/newton/newton/requests/views/network.py
+++ b/newton/newton/requests/views/network.py
@@ -41,7 +41,8 @@ class Networks(APIView):
def get(self, request, vimid="", tenantid="", networkid=""):
logger.debug("Networks--get::> %s" % request.data)
try:
- content, status_code = self.get_networks(request, vimid, tenantid, networkid)
+ query = VimDriverUtils.get_query_part(request)
+ content, status_code = self.get_networks(query, vimid, tenantid, networkid)
return Response(data=content, status=status_code)
except VimDriverNewtonException as e:
@@ -50,14 +51,14 @@ class Networks(APIView):
return Response(data={'error': str(e)},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
- def get_networks(self, request, vimid="", tenantid="", networkid=""):
+ def get_networks(self, query, vimid="", tenantid="", networkid=""):
logger.debug("Networks--get_networks::> %s" % networkid)
# prepare request resource to vim instance
req_resouce = "v2.0/networks"
if networkid:
req_resouce += "/%s" % networkid
- query = VimDriverUtils.get_query_part(request)
+
if query:
req_resouce += "?%s" % query
@@ -90,7 +91,8 @@ class Networks(APIView):
logger.debug("Networks--post::> %s" % request.data)
try:
#check if created already: check name
- content, status_code = self.get_networks(request, vimid, tenantid)
+ query = "name=%s" % request.data["name"]
+ content, status_code = self.get_networks(query, vimid, tenantid)
existed = False
if status_code == 200:
for network in content["networks"]:
@@ -107,11 +109,6 @@ class Networks(APIView):
# prepare request resource to vim instance
req_resouce = "v2.0/networks"
- if networkid:
- req_resouce += "/%s" % networkid
- query = VimDriverUtils.get_query_part(request)
- if query:
- req_resouce += "?%s" % query
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)