main 6.1.2
sskarimov 2 months ago
parent 45355b3dd3
commit 59a23d6a41

@ -1,12 +1,11 @@
# Список изменений в версии 6.1.1
# Список изменений в версии 6.1.2
## Добавлено
## Удалено
## Исправлено
### Модуль decort_kvmvm
### Модуль decort_k8s
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BANS-676 | При удалении ВМ, модуль завершал свою работу ошибкой запроса к API. |
| BANS-677 | Параметр `custom_fields` не устанавливался при создании ВМ без образа. |
| BANS-682 | При создании кластера k8s, модуль завершал свою работу ошибкой запроса к API. |

@ -76,7 +76,8 @@ class decort_kvmvm(DecortController):
self.comp_id, self.comp_info, self.rg_id = self.compute_find(comp_id=arg_amodule.params['id'],
comp_name=arg_amodule.params['name'],
rg_id=validated_rg_id,
check_state=False)
check_state=False,
need_custom_fields=True)
if self.comp_id:
self.comp_should_exist = True
@ -346,7 +347,10 @@ class decort_kvmvm(DecortController):
)
# read in Compute facts once more after all initial setup is complete
_, self.comp_info, _ = self.compute_find(comp_id=self.comp_id)
_, self.comp_info, _ = self.compute_find(
comp_id=self.comp_id,
need_custom_fields=True,
)
self.skip_final_get = True
@ -369,7 +373,10 @@ class decort_kvmvm(DecortController):
"""
self.compute_restore(comp_id=self.comp_id)
# TODO - do we need updated comp_info to manage port forwards and size after VM is restored?
_, self.comp_info, _ = self.compute_find(comp_id=self.comp_id)
_, self.comp_info, _ = self.compute_find(
comp_id=self.comp_id,
need_custom_fields=True,
)
self.modify()
self.comp_should_exist = True
return
@ -801,7 +808,10 @@ def main():
# TODO - check if restore API returns VM ID (similarly to VM create API)
subj.compute_restore(comp_id=subj.comp_id)
# TODO - do we need updated comp_info to manage port forwards and size after VM is restored?
_, subj.comp_info, _ = subj.compute_find(comp_id=subj.comp_id)
_, subj.comp_info, _ = subj.compute_find(
comp_id=subj.comp_id,
need_custom_fields=True,
)
subj.modify()
elif amodule.params['state'] == 'absent':
# subj.nop()
@ -837,7 +847,10 @@ def main():
if subj.comp_should_exist:
if subj.result['changed'] and not subj.skip_final_get:
# There were changes to the Compute - refresh Compute facts.
_, subj.comp_info, _ = subj.compute_find(comp_id=subj.comp_id)
_, subj.comp_info, _ = subj.compute_find(
comp_id=subj.comp_id,
need_custom_fields=True,
)
#
# We no longer need to re-read RG facts, as all network info is now available inside
# compute structure

@ -1184,7 +1184,7 @@ class DecortController(object):
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.
@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']
custom_fields = None
if ret_comp_dict['status'] not in ('DESTROYED', 'DELETED'):
custom_fields = self.compute_get_custom_fields(
compute_id=ret_comp_id,
)
ret_comp_dict['custom_fields'] = custom_fields
if need_custom_fields:
if ret_comp_dict['status'] in ('DESTROYED', 'DELETED'):
custom_fields = None
else:
custom_fields = self.compute_get_custom_fields(
compute_id=ret_comp_id,
)
ret_comp_dict['custom_fields'] = custom_fields
else:
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)
@ -1222,7 +1225,8 @@ class DecortController(object):
def compute_find(self, comp_id,
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
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
# upstream Ansible module execution by calling fail_json(...)
# 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:
self.result['failed'] = True
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']
# we still need to get compute info from the model to make sure
# 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
# NOTE: if there were no errors, but compute was not found, ret_comp_id=0 is returned

Loading…
Cancel
Save