diff options
author | Bin Yang <bin.yang@windriver.com> | 2020-02-29 14:39:12 +0800 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2020-02-29 15:08:37 +0800 |
commit | a9ab01f7bc1c5c2a421d10d68d6f90b69462d6d0 (patch) | |
tree | 09f54a9ac87172c3b970902b8e4e1ecc7df29a06 | |
parent | 2dcceae964868572b56ca0cd25b48cf3d27dbe41 (diff) |
Fix bug in starlingx API handler
Change-Id: I6e8aabeba8329421385f81d1ce394e70c089d10d
Issue-ID: MULTICLOUD-1003
Signed-off-by: Bin Yang <bin.yang@windriver.com>
-rw-r--r-- | share/starlingx_base/resource/k8s_infra_workload_helper.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/share/starlingx_base/resource/k8s_infra_workload_helper.py b/share/starlingx_base/resource/k8s_infra_workload_helper.py index 5efb94e6..87309ff6 100644 --- a/share/starlingx_base/resource/k8s_infra_workload_helper.py +++ b/share/starlingx_base/resource/k8s_infra_workload_helper.py @@ -142,12 +142,14 @@ class InfraWorkloadHelper: # 2.forward infra_workload API requests with queries cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid) infraUrl = multicloudK8sUrl+"/%s/%s/infra_workload" % (cloud_owner, cloud_region_id) + if workloadid: + infraUrl += ("/%s" % workloadid) if workload_query: infraUrl += ("?%s" % workload_query) # should we forward headers ? TBD logger.debug("request with url,content: %s,%s" % (infraUrl, workload_data)) - resp = requests.post(infraUrl, data=workload_data, verify=False) + resp = requests.post(infraUrl, data=json.dumps(workload_data), verify=False) # resp_template["workload_status_reason"] = resp.content logger.debug("response status,content: %s,%s" % (resp.status_code, resp.content)) return Response(data=json.loads(resp.content), status=resp.status_code) @@ -174,12 +176,15 @@ class InfraWorkloadHelper: # 1.forward infra_workload API requests with queries cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid) infraUrl = multicloudK8sUrl+"/%s/%s/infra_workload" % (cloud_owner, cloud_region_id) + if workloadid: + infraUrl += ("/%s" % workloadid) if workload_query_str: infraUrl += ("?%s" % workload_query_str) # should we forward headers ? TBD logger.debug("request with url,content: %s,%s" % (infraUrl, workload_data)) - resp = requests.delete(infraUrl, data=workload_data, verify=False) + # resp = requests.delete(infraUrl, data=json.dumps(workload_data), verify=False) + resp = requests.delete(infraUrl, verify=False) # resp_template["workload_status_reason"] = resp.content logger.debug("response status,content: %s,%s" % (resp.status_code, resp.content)) return Response(data=json.loads(resp.content), status=resp.status_code) @@ -206,12 +211,15 @@ class InfraWorkloadHelper: # forward infra_workload API requests with queries cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid) infraUrl = multicloudK8sUrl+"/%s/%s/infra_workload" % (cloud_owner, cloud_region_id) + if workloadid: + infraUrl += ("/%s" % workloadid) if workload_query_str: infraUrl += ("?%s" % workload_query_str) # should we forward headers ? TBD logger.debug("request with url,content: %s,%s" % (infraUrl, workload_data)) - resp = requests.get(infraUrl, data=workload_data, verify=False) + # resp = requests.get(infraUrl, data=json.dumps(workload_data), verify=False) + resp = requests.get(infraUrl, verify=False) # resp_template["workload_status_reason"] = resp.content logger.debug("response status,content: %s,%s" % (resp.status_code, resp.content)) return Response(data=json.loads(resp.content), status=resp.status_code) |