|
|
@ -1184,7 +1184,7 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def _compute_get_by_id(self, comp_id):
|
|
|
|
def _compute_get_by_id(self, comp_id, need_custom_fields: bool = False):
|
|
|
|
"""Helper function that locates compute instance by ID and returns Compute facts.
|
|
|
|
"""Helper function that locates compute instance by ID and returns Compute facts.
|
|
|
|
|
|
|
|
|
|
|
|
@param (int) comp_id: ID of the Compute instance to find and return facts for.
|
|
|
|
@param (int) comp_id: ID of the Compute instance to find and return facts for.
|
|
|
@ -1208,12 +1208,15 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
ret_rg_id = ret_comp_dict['rgId']
|
|
|
|
ret_rg_id = ret_comp_dict['rgId']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if need_custom_fields:
|
|
|
|
|
|
|
|
if ret_comp_dict['status'] in ('DESTROYED', 'DELETED'):
|
|
|
|
custom_fields = None
|
|
|
|
custom_fields = None
|
|
|
|
if ret_comp_dict['status'] not in ('DESTROYED', 'DELETED'):
|
|
|
|
else:
|
|
|
|
custom_fields = self.compute_get_custom_fields(
|
|
|
|
custom_fields = self.compute_get_custom_fields(
|
|
|
|
compute_id=ret_comp_id,
|
|
|
|
compute_id=ret_comp_id,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
ret_comp_dict['custom_fields'] = custom_fields
|
|
|
|
ret_comp_dict['custom_fields'] = custom_fields
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.result['warning'] = ("compute_get_by_id(): failed to get Compute by ID {}. HTTP code {}, "
|
|
|
|
self.result['warning'] = ("compute_get_by_id(): failed to get Compute by ID {}. HTTP code {}, "
|
|
|
|
"response {}.").format(comp_id, api_resp.status_code, api_resp.reason)
|
|
|
|
"response {}.").format(comp_id, api_resp.status_code, api_resp.reason)
|
|
|
@ -1222,7 +1225,8 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
|
|
def compute_find(self, comp_id,
|
|
|
|
def compute_find(self, comp_id,
|
|
|
|
comp_name="", rg_id=0,
|
|
|
|
comp_name="", rg_id=0,
|
|
|
|
check_state=True):
|
|
|
|
check_state=True,
|
|
|
|
|
|
|
|
need_custom_fields: bool = False):
|
|
|
|
"""Tries to find Compute instance according to the specified parameters. On success returns non-zero
|
|
|
|
"""Tries to find Compute instance according to the specified parameters. On success returns non-zero
|
|
|
|
Compute ID and a dictionary with Compute details, or 0 for ID and None for the dictionary on failure.
|
|
|
|
Compute ID and a dictionary with Compute details, or 0 for ID and None for the dictionary on failure.
|
|
|
|
|
|
|
|
|
|
|
@ -1255,7 +1259,12 @@ class DecortController(object):
|
|
|
|
# locate Compute instance by ID - if there is no Compute with such ID, the method will abort
|
|
|
|
# locate Compute instance by ID - if there is no Compute with such ID, the method will abort
|
|
|
|
# upstream Ansible module execution by calling fail_json(...)
|
|
|
|
# upstream Ansible module execution by calling fail_json(...)
|
|
|
|
# Note that in this mode check_state argument is ignored.
|
|
|
|
# Note that in this mode check_state argument is ignored.
|
|
|
|
ret_comp_id, ret_comp_dict, ret_rg_id = self._compute_get_by_id(comp_id)
|
|
|
|
ret_comp_id, ret_comp_dict, ret_rg_id = (
|
|
|
|
|
|
|
|
self._compute_get_by_id(
|
|
|
|
|
|
|
|
comp_id=comp_id,
|
|
|
|
|
|
|
|
need_custom_fields=need_custom_fields,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
if not ret_comp_id:
|
|
|
|
if not ret_comp_id:
|
|
|
|
self.result['failed'] = True
|
|
|
|
self.result['failed'] = True
|
|
|
|
self.result['msg'] = "compute_find(): cannot locate Compute with ID {}.".format(comp_id)
|
|
|
|
self.result['msg'] = "compute_find(): cannot locate Compute with ID {}.".format(comp_id)
|
|
|
@ -1291,7 +1300,10 @@ class DecortController(object):
|
|
|
|
ret_comp_id = runner['id']
|
|
|
|
ret_comp_id = runner['id']
|
|
|
|
# we still need to get compute info from the model to make sure
|
|
|
|
# we still need to get compute info from the model to make sure
|
|
|
|
# compute dictionary contains complete data in correct format
|
|
|
|
# compute dictionary contains complete data in correct format
|
|
|
|
_, ret_comp_dict, _ = self._compute_get_by_id(ret_comp_id)
|
|
|
|
_, ret_comp_dict, _ = self._compute_get_by_id(
|
|
|
|
|
|
|
|
comp_id=ret_comp_id,
|
|
|
|
|
|
|
|
need_custom_fields=need_custom_fields,
|
|
|
|
|
|
|
|
)
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
# NOTE: if there were no errors, but compute was not found, ret_comp_id=0 is returned
|
|
|
|
# NOTE: if there were no errors, but compute was not found, ret_comp_id=0 is returned
|
|
|
|