From 207c04bb7712400d11c8c319d55bef54b8e42ae8 Mon Sep 17 00:00:00 2001 From: Alex_geth Date: Mon, 31 Jul 2023 17:19:50 +0300 Subject: [PATCH] 4.8.7 decort/basis version update --- module_utils/decort_utils.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/module_utils/decort_utils.py b/module_utils/decort_utils.py index e606e27..72b119d 100644 --- a/module_utils/decort_utils.py +++ b/module_utils/decort_utils.py @@ -541,7 +541,7 @@ class DecortController(object): return - def compute_delete(self, comp_id, permanently=False): + def compute_delete(self, comp_id, permanently=False,detach=True): """Delete a Compute instance identified by its ID. It is assumed that the Compute with the specified ID exists. @@ -559,7 +559,8 @@ class DecortController(object): return api_params = dict(computeId=comp_id, - permanently=permanently, ) + permanently=permanently, + detachDisks=detach, ) self.decort_api_call(requests.post, "/restmachine/cloudapi/compute/delete", api_params) # On success the above call will return here. On error it will abort execution by calling fail_json. self.result['failed'] = False @@ -657,7 +658,7 @@ class DecortController(object): # if we have validated RG ID at this point, look up Compute by name in this RG # rg.vms list contains IDs of compute instances registered with this RG until compute is # destroyed. So we may see here computes in "active" and DELETED states. - for runner in comp_list: + for runner in comp_list['data']: if runner['name'] == comp_name and runner['rgId'] == rg_id: if not check_state or runner['status'] not in COMP_INVALID_STATES: ret_comp_id = runner['id'] @@ -800,7 +801,7 @@ class DecortController(object): sepId=sep_id, pool=pool_name, start=start_on_create, # start_machine parameter requires DECORT API ver 3.3.1 or higher - netType="NONE") # we create VM without any network connections + interfaces='[]') # we create VM without any network connections if userdata: api_params['userdata'] = json.dumps(userdata) # we need to pass a string object as "userdata" @@ -1657,7 +1658,7 @@ class DecortController(object): if api_resp.status_code == 200: account_specs = json.loads(api_resp.content.decode('utf8')) #api_params.pop('accountId') - for rg_item in account_specs: + for rg_item in account_specs['data']: # if rg_item['name'] == arg_rg_name: # name matches @@ -2084,7 +2085,7 @@ class DecortController(object): if api_resp.status_code == 200: locations = json.loads(api_resp.content.decode('utf8')) if location_code == "" and locations: - ret_gid = locations[0]['gid'] + ret_gid = locations['data'][0]['gid'] else: for runner in locations: if runner['locationCode'] == location_code: @@ -2178,7 +2179,7 @@ class DecortController(object): "response {}.").format(rg_id, api_resp.status_code, api_resp.reason) return [] - return ret_rg_vins_list + return ret_rg_vins_list['data'] def vins_find(self, vins_id, vins_name="", account_id=0, rg_id=0, rg_facts="", check_state=True): """Find specified ViNS. @@ -2626,7 +2627,8 @@ class DecortController(object): else: self.result['warning'] = ("get_all_account_vinses(): failed to get list VINS in Account ID {}. HTTP code {}, " "response {}.").format(acc_id, api_resp.status_code, api_resp.reason) - return ret_listvins_dict + return [] + return ret_listvins_dict['data'] def _vins_vnf_addmgmtaddr(self,dev_id,mgmtip): api_params = dict(devId=dev_id,ip=mgmtip) @@ -3281,7 +3283,7 @@ class DecortController(object): api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/k8s/list", api_params) if api_resp.status_code == 200: k8s_list = json.loads(api_resp.content.decode('utf8')) - for k8s_item in k8s_list: + for k8s_item in k8s_list['data']: if k8s_item['name'] == k8s_name and k8s_item['rgId'] == rg_id: if not check_state or k8s_item['status'] not in K8S_INVALID_STATES: # TODO: rework after k8s/get wilb be updated @@ -3576,7 +3578,7 @@ class DecortController(object): k8ci_id_present = False if api_resp.status_code == 200: ret_k8ci_list = json.loads(api_resp.content.decode('utf8')) - for k8ci_item in ret_k8ci_list: + for k8ci_item in ret_k8ci_list['data']: if k8ci_item['id'] == arg_k8ci_id: k8ci_id_present = True break @@ -3636,7 +3638,8 @@ class DecortController(object): else: self.result['warning'] = ("bservice_rg_list(): failed to get B-service list. HTTP code {}, " "response {}.").format(api_resp.status_code, api_resp.reason) - return ret_bs_dict + return [] + return ret_bs_dict['data'] def bservice_find(self,account_id,rg_id,bservice_name="",bservice_id = 0,check_state=True): @@ -3992,7 +3995,7 @@ class DecortController(object): "response {}.").format(rg_id, api_resp.status_code, api_resp.reason) return [] - return ret_rg_vins_list + return ret_rg_vins_list['data'] def lb_find(self,lb_id=0,lb_name="",rg_id=0): """Find specified LB.