6.1.2
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
# Список изменений в версии 6.1.1
|
# Список изменений в версии 6.1.2
|
||||||
|
|
||||||
## Добавлено
|
## Добавлено
|
||||||
|
|
||||||
## Удалено
|
## Удалено
|
||||||
|
|
||||||
## Исправлено
|
## Исправлено
|
||||||
### Модуль decort_kvmvm
|
### Модуль decort_k8s
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BANS-676 | При удалении ВМ, модуль завершал свою работу ошибкой запроса к API. |
|
| BANS-682 | При создании кластера k8s, модуль завершал свою работу ошибкой запроса к API. |
|
||||||
| BANS-677 | Параметр `custom_fields` не устанавливался при создании ВМ без образа. |
|
|
||||||
|
|||||||
@@ -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'],
|
self.comp_id, self.comp_info, self.rg_id = self.compute_find(comp_id=arg_amodule.params['id'],
|
||||||
comp_name=arg_amodule.params['name'],
|
comp_name=arg_amodule.params['name'],
|
||||||
rg_id=validated_rg_id,
|
rg_id=validated_rg_id,
|
||||||
check_state=False)
|
check_state=False,
|
||||||
|
need_custom_fields=True)
|
||||||
|
|
||||||
if self.comp_id:
|
if self.comp_id:
|
||||||
self.comp_should_exist = True
|
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
|
# 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
|
self.skip_final_get = True
|
||||||
|
|
||||||
@@ -369,7 +373,10 @@ class decort_kvmvm(DecortController):
|
|||||||
"""
|
"""
|
||||||
self.compute_restore(comp_id=self.comp_id)
|
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?
|
# 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.modify()
|
||||||
self.comp_should_exist = True
|
self.comp_should_exist = True
|
||||||
return
|
return
|
||||||
@@ -801,7 +808,10 @@ def main():
|
|||||||
# TODO - check if restore API returns VM ID (similarly to VM create API)
|
# TODO - check if restore API returns VM ID (similarly to VM create API)
|
||||||
subj.compute_restore(comp_id=subj.comp_id)
|
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?
|
# 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()
|
subj.modify()
|
||||||
elif amodule.params['state'] == 'absent':
|
elif amodule.params['state'] == 'absent':
|
||||||
# subj.nop()
|
# subj.nop()
|
||||||
@@ -837,7 +847,10 @@ def main():
|
|||||||
if subj.comp_should_exist:
|
if subj.comp_should_exist:
|
||||||
if subj.result['changed'] and not subj.skip_final_get:
|
if subj.result['changed'] and not subj.skip_final_get:
|
||||||
# There were changes to the Compute - refresh Compute facts.
|
# 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
|
# We no longer need to re-read RG facts, as all network info is now available inside
|
||||||
# compute structure
|
# compute structure
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user