diff options
author | Xiaohua Zhang <xiaohua.zhang@windriver.com> | 2018-09-19 03:12:51 +0000 |
---|---|---|
committer | Xiaohua Zhang <xiaohua.zhang@windriver.com> | 2018-09-19 03:12:51 +0000 |
commit | 0c40f8947716932fa8b67acc19b3567837eebedc (patch) | |
tree | d005e60289e12721079adc530ef9bc0eee73d1a9 /share/common | |
parent | e9c7a8ad165a545b4a95e5278f7a709ef5ab805b (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')
-rw-r--r-- | share/common/msapi/helper.py | 21 | ||||
-rw-r--r-- | share/common/utils/restcall.py | 2 |
2 files changed, 9 insertions, 14 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 diff --git a/share/common/utils/restcall.py b/share/common/utils/restcall.py index 05788bc9..ec3abb30 100644 --- a/share/common/utils/restcall.py +++ b/share/common/utils/restcall.py @@ -80,7 +80,7 @@ def _call_req(base_url, user, passwd, auth_type, headers=headers) resp_status, resp_body = \ resp['status'], codecs.decode( - resp_content, 'UTF-8') + resp_content, 'UTF-8') if resp_content else None if resp_status in status_ok_list: ret = [0, resp_body, resp_status] else: |