From 35362278dc5e2f5f1543f2825bf3a380444a742f Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Fri, 3 Mar 2017 16:39:25 +0800 Subject: Refactor flavors API for newton Change-Id: I36c579b91be6c5874804b34489d5df1a66c053d5 Issue-Id: MULTIVIM-22 Signed-off-by: Bin Yang --- newton/newton/requests/views/flavor.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/newton/newton/requests/views/flavor.py b/newton/newton/requests/views/flavor.py index 22b84bbf..197ecd8b 100644 --- a/newton/newton/requests/views/flavor.py +++ b/newton/newton/requests/views/flavor.py @@ -76,13 +76,14 @@ class Flavors(APIView): else: wanted = None - #check if query contains name="???" - for queryone in query.split('&'): - k,v = queryone.split('=') - if k == "name": - wanted = v - break - pass + #check if query contains name="flavorname" + if query: + for queryone in query.split('&'): + k,v = queryone.split('=') + if k == "name": + wanted = v + break + pass if wanted: oldFlavors = content.pop("flavors", None) @@ -164,7 +165,7 @@ class Flavors(APIView): vim = VimDriverUtils.get_vim_info(vimid) sess = VimDriverUtils.get_session(vim, tenantid) - #check if the flavor name or id is used + #check if the flavor is already created: name or id tmpresp = self.get_flavor(sess, request) content = tmpresp.json() #iterate each flavor to get extra_specs @@ -178,7 +179,7 @@ class Flavors(APIView): break pass - if existed: + if existed == True: extraResp = self.get_flavor_extra_specs(sess, flavor["id"]) extraContent = extraResp.json() if extraContent["extra_specs"]: -- cgit 1.2.3-korg