summaryrefslogtreecommitdiffstats
path: root/share/common/msapi
diff options
context:
space:
mode:
authorXiaohua Zhang <xiaohua.zhang@windriver.com>2018-09-19 03:12:51 +0000
committerXiaohua Zhang <xiaohua.zhang@windriver.com>2018-09-19 03:12:51 +0000
commit0c40f8947716932fa8b67acc19b3567837eebedc (patch)
treed005e60289e12721079adc530ef9bc0eee73d1a9 /share/common/msapi
parente9c7a8ad165a545b4a95e5278f7a709ef5ab805b (diff)
Implement infra_workload delete API
Change-Id: I16f198e44810278eafb5be08ed88268911554f57 Issue-ID: MULTICLOUD-358 Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com>
Diffstat (limited to 'share/common/msapi')
-rw-r--r--share/common/msapi/helper.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/share/common/msapi/helper.py b/share/common/msapi/helper.py
index 3ec404eb..3e10c0fd 100644
--- a/share/common/msapi/helper.py
+++ b/share/common/msapi/helper.py
@@ -16,6 +16,7 @@ import re
from common.exceptions import VimDriverNewtonException
from common.utils import restcall
+from rest_framework import status
logger = logging.getLogger(__name__)
@@ -30,12 +31,9 @@ class Helper(object):
f_uri=uri)
extra_headers = header
ret = restcall._call_req(multicloud_api_prefix, "", "", 0, auth_api_url, "POST", extra_headers, json.dumps(data))
- if ret[0] > 0 or ret[1] is None:
- logger.critical("call url %s failed with status %s" % (multicloud_api_prefix+auth_api_url, ret[0]))
- return ret
-
- resp = json.JSONDecoder().decode(ret[1])
- ret[1] = resp
+ if ret[0] == 0 and ret[1]:
+ content = json.JSONDecoder().decode(ret[1])
+ ret[1] = content
return ret
# The consumer of this api must be attaching to the same management network of multicloud,
@@ -51,11 +49,8 @@ class Helper(object):
endpoint_url = catalog['endpoints'][0]['publicURL']
extra_headers = {'X-Auth-Token': token}
ret = restcall._call_req(endpoint_url, "", "", 0, uri, method, extra_headers, json.dumps(data) if data else "")
- if ret[0] > 0 or ret[1] is None:
- logger.critical("call url %s failed with status %s" % (endpoint_url+uri, ret[0]))
- return ret
-
- content = json.JSONDecoder().decode(ret[1])
- ret[1] = content
+ if ret[0] == 0 and ret[1]:
+ content = json.JSONDecoder().decode(ret[1])
+ ret[1] = content
return ret
- pass
+ return [1, None, status.HTTP_404_NOT_FOUND] # return resource not found in case no type found \ No newline at end of file