13.0.0
This commit is contained in:
197
CHANGELOG.md
197
CHANGELOG.md
@@ -1,11 +1,200 @@
|
|||||||
# Список изменений в версии 12.0.3
|
# Список изменений в версии 13.0.0
|
||||||
|
|
||||||
|
## Изменено
|
||||||
|
### Глобально
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
|
||||||
|
### Модуль decort_bservice
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1200 | Переименованы возвращаемые значения `state`, `techStatus` в `status`, `tech_status`. |
|
||||||
|
|
||||||
|
### Модуль decort_disk_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1252 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_image_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1217 | У параметра `type` изменён тип с `str` на `list[str]`. |
|
||||||
|
|
||||||
|
### Модуль decort_account_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1251 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_vm_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1253 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_flip_group_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1254 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_rg_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1256 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_audit_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1282 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_vins_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1257 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_zone_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1258 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_security_group_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1278 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_trunk_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1306 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
|
### Модуль decort_storage_policy_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1307 | Для параметра `pagination.size` изменено значение по умолчанию с `50` на `100`. |
|
||||||
|
|
||||||
## Добавлено
|
## Добавлено
|
||||||
|
### Глобально
|
||||||
|
|
||||||
## Удалено
|
### Модуль decort_bservice
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1200 | Добавлены возвращаемые значения `account_name`, `base_domain`, `cpu_count_total`, `created_by`, `created_timestamp`, `deleted_by`, `deleted_timestamp`, `disk_size_total_gb`, `grid_id`, `guid`, `milestones`, `parent_service_id`, `parent_service_type`, `ram_size_total_mb`, `rg_name`, `snapshots`, `ssh_public_key`, `ssh_user_name`, `updated_by`, `updated_timestamp`, `user_managed`, `vms`. |
|
||||||
|
|
||||||
## Исправлено
|
|
||||||
### Модуль decort_vm
|
### Модуль decort_vm
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BANS-1377 | Модуль завершал работу ошибкой при передаче параметров `disks.objects.pci_slot_num_hex` и `disks.objects.bus_num_hex` в формате hex. |
|
| BANS-1284 | Добавлено возвращаемое значение `interfaces.enable_default_gateway`. |
|
||||||
|
| BANS-1222 | Добавлено возвращаемое значение `clock_sync_mode`. |
|
||||||
|
| BANS-1229 | Добавлен параметр `cpu_alignment_profile_name`. |
|
||||||
|
| BANS-1221 | Добавлено возвращаемое значение `cpu_alignment_profile`. |
|
||||||
|
| BANS-1230 | Добавлен параметр `clock_sync_mode`. |
|
||||||
|
| BANS-1238 | Добавлено возвращаемое значение `disks.read_only_mode`. |
|
||||||
|
| BANS-1280 | Добавлен параметр `networks.enable_default_gateway`. |
|
||||||
|
| BANS-1297 | Добавлено возвращаемое значение `disks.snapshots.pool_name`. |
|
||||||
|
| BANS-1313 | Добавлено возвращаемое значение `resized_online`. |
|
||||||
|
|
||||||
|
### Модуль decort_vm_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1223 | Добавлено возвращаемое значение `cpu_alignment_profile`. |
|
||||||
|
| BANS-1224 | Добавлено возвращаемое значение `clock_sync_mode`. |
|
||||||
|
| BANS-1239 | Добавлено возвращаемое значение `disks.read_only_mode`. |
|
||||||
|
| BANS-1243 | Добавлено возвращаемое значение `snapshot_sets.vm`. |
|
||||||
|
| BANS-1244 | Добавлено возвращаемое значение `snapshot_sets.memory_dump_image_id`. |
|
||||||
|
| BANS-1283 | Добавлено возвращаемое значение `interfaces.enable_default_gateway`. |
|
||||||
|
| BANS-1312 | Добавлено возвращаемое значение `resized_online`. |
|
||||||
|
|
||||||
|
### Модуль decort_disk
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1218 | Добавлено возвращаемое значение `discard`. |
|
||||||
|
| BANS-1240 | Добавлено возвращаемое значение `vms_with_read_only`. |
|
||||||
|
| BANS-1298 | Добавлено возвращаемое значение `snapshots.pool_name`. |
|
||||||
|
|
||||||
|
### Модуль decort_disk_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1219 | Добавлено возвращаемое значение `discard`. |
|
||||||
|
| BANS-1241 | Добавлено возвращаемое значение `vms_with_read_only`. |
|
||||||
|
|
||||||
|
### Модуль decort_zone_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1226 | Добавлено возвращаемое значение `cpu_alignment_profiles`. |
|
||||||
|
| BANS-1287 | Добавлено возвращаемое значение `reserved_cpu`. |
|
||||||
|
| BANS-1288 | Добавлено возвращаемое значение `reserved_ram`. |
|
||||||
|
|
||||||
|
### Модуль decort_zone
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1225 | Добавлено возвращаемое значение `cpu_alignment_profiles`. |
|
||||||
|
| BANS-1289 | Добавлено возвращаемое значение `reserved_cpu`. |
|
||||||
|
| BANS-1290 | Добавлено возвращаемое значение `reserved_ram`. |
|
||||||
|
|
||||||
|
### Модуль decort_vm_snapshot
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1223 | Добавлен параметр `with_memory`. |
|
||||||
|
| BANS-1245 | Добавлено возвращаемое значение `memory_dump_image_id`. |
|
||||||
|
| BANS-1246 | Добавлено возвращаемое значение `vm`. |
|
||||||
|
|
||||||
|
### Модуль decort_vins
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1279 | Добавлен параметр `enable_default_gateway`. |
|
||||||
|
| BANS-1285 | Добавлено возвращаемое значение `enable_default_gateway`. |
|
||||||
|
| BANS-1286 | Добавлено возвращаемое значение `vnfdev.interfaces.enable_default_gateway`. |
|
||||||
|
|
||||||
|
### Модуль decort_rg
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1301 | Добавлен параметр `enable_default_gateway`. |
|
||||||
|
|
||||||
|
### Модуль decort_sdn_access_group
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1315 | Добавлено возвращаемое значение `default_security_policy.default_open_session_drop`. |
|
||||||
|
|
||||||
|
### Модуль decort_sdn_access_group_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1314 | Добавлено возвращаемое значение `default_security_policy.default_open_session_drop`. |
|
||||||
|
|
||||||
|
## Удалено
|
||||||
|
### Модуль decort_disk
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1327 | Удалено возвращаемое значение `blkdiscard`. |
|
||||||
|
|
||||||
|
### Модуль decort_disk_list
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1328 | Удалено возвращаемое значение `blkdiscard`. |
|
||||||
|
|
||||||
|
## Исправлено
|
||||||
|
### Модуль decort_bservice
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1203 | Модуль завершал работу ошибкой при `state: absent` для объекта, который не найден или безвозвратно удален. |
|
||||||
|
| BANS-1205 | Модуль завершал работу ошибкой запроса к API при `state: enabled` для объекта, который безвозвратно удален. |
|
||||||
|
| BANS-1207 | Модуль завершал работу ошибкой при создании объекта в режиме `Check mode`. |
|
||||||
|
| BANS-1206 | Модуль завершал работу без ошибки при передачи `id` объекта, который безвозвратно удален, и `state: disabled`. |
|
||||||
|
|
||||||
|
### Модуль decort_vm_snapshot
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1316 | Модуль завершал работу ошибкой при `state: absent` для снимка, который не найден или безвозвратно удален. |
|
||||||
|
|
||||||
|
### Модуль decort_vm
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1330 | Модуль завершал работу ошибкой запроса к API при изменении образа без указания `storage_policy_id`. |
|
||||||
|
|
||||||
|
### Модуль decort_image
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1338 | Модуль завершал работу ошибкой при `state: absent` для шаблонного образа, который не найден. |
|
||||||
|
| BANS-1339 | Модуль без необходимости выполнял запрос к API `/cloudapi/image/delete` для шаблонного образа, который безвозвратно удален. |
|
||||||
|
|
||||||
|
### Модуль decort_group
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BANS-1371 | Модуль завершал работу без ошибки при передаче `id` объекта, который не найден или безвозвратно удален, и `state: stopped`, `state: started` или без указания `state`. |
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
| Версия платформы | Версия модулей Ansible |
|
| Версия платформы | Версия модулей Ansible |
|
||||||
|:----------------:|:--------------------------:|
|
|:----------------:|:--------------------------:|
|
||||||
|
| 4.7.0 | 13.0.x |
|
||||||
| 4.6.0 | 12.0.x |
|
| 4.6.0 | 12.0.x |
|
||||||
| 4.5.0 | 11.0.x |
|
| 4.5.0 | 11.0.x |
|
||||||
| 4.4.0 | 10.0.x |
|
| 4.4.0 | 10.0.x |
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class DecortAccountList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class DecortAuditList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -19,13 +19,12 @@ class decort_bservice(DecortController):
|
|||||||
|
|
||||||
validated_acc_id = 0
|
validated_acc_id = 0
|
||||||
validated_rg_id = 0
|
validated_rg_id = 0
|
||||||
self.bservice_info = None
|
|
||||||
self.is_bservice_stopped_or_will_be_stopped: None | bool = None
|
self.is_bservice_stopped_or_will_be_stopped: None | bool = None
|
||||||
if arg_amodule.params['name'] == "" and arg_amodule.params['id'] == 0:
|
if arg_amodule.params['name'] == "" and arg_amodule.params['id'] == 0:
|
||||||
self.result['failed'] = True
|
self.result['failed'] = True
|
||||||
self.result['changed'] = False
|
self.result['changed'] = False
|
||||||
self.result['msg'] = "Cannot manage Basic Services when its ID is 0 and name is empty."
|
self.result['msg'] = "Cannot manage Basic Services when its ID is 0 and name is empty."
|
||||||
self.fail_json(**self.result)
|
self.amodule.fail_json(**self.result)
|
||||||
if not arg_amodule.params['id']:
|
if not arg_amodule.params['id']:
|
||||||
if not arg_amodule.params['rg_id']: # RG ID is not set -> locate RG by name -> need account ID
|
if not arg_amodule.params['rg_id']: # RG ID is not set -> locate RG by name -> need account ID
|
||||||
validated_acc_id, self._acc_info = self.account_find(arg_amodule.params['account_name'],
|
validated_acc_id, self._acc_info = self.account_find(arg_amodule.params['account_name'],
|
||||||
@@ -36,7 +35,7 @@ class decort_bservice(DecortController):
|
|||||||
self.result['msg'] = ("Current user does not have access to the account ID {} / "
|
self.result['msg'] = ("Current user does not have access to the account ID {} / "
|
||||||
"name '{}' or non-existent account specified.").format(arg_amodule.params['account_id'],
|
"name '{}' or non-existent account specified.").format(arg_amodule.params['account_id'],
|
||||||
arg_amodule.params['account_name'])
|
arg_amodule.params['account_name'])
|
||||||
self.fail_json(**self.result)
|
self.amodule.fail_json(**self.result)
|
||||||
# fail the module -> exit
|
# fail the module -> exit
|
||||||
# now validate RG
|
# now validate RG
|
||||||
validated_rg_id, validated_rg_model = self.rg_find(
|
validated_rg_id, validated_rg_model = self.rg_find(
|
||||||
@@ -55,14 +54,27 @@ class decort_bservice(DecortController):
|
|||||||
arg_amodule.params['rg_name'] = validated_rg_model.name
|
arg_amodule.params['rg_name'] = validated_rg_model.name
|
||||||
validated_acc_id = validated_rg_model.account_id
|
validated_acc_id = validated_rg_model.account_id
|
||||||
|
|
||||||
self.bservice_id, self.bservice_info = self.bservice_find(
|
self.bservice_id, self._bservice_info = self.bservice_find(
|
||||||
validated_acc_id,
|
account_id=validated_acc_id,
|
||||||
validated_rg_id,
|
rg_id=validated_rg_id,
|
||||||
arg_amodule.params['name'],
|
bservice_name=arg_amodule.params['name'],
|
||||||
arg_amodule.params['id']
|
bservice_id=arg_amodule.params['id'],
|
||||||
|
fail_if_not_found=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.acc_id = validated_acc_id or self.bservice_info['accountId']
|
if arg_amodule.params['id'] and self.bservice_id == 0:
|
||||||
|
if arg_amodule.params['state'] == 'absent':
|
||||||
|
self.exit()
|
||||||
|
else:
|
||||||
|
self.message(
|
||||||
|
self.MESSAGES.obj_not_found(
|
||||||
|
obj='bservice',
|
||||||
|
id=arg_amodule.params['id'],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.exit(fail=True)
|
||||||
|
|
||||||
|
self.acc_id = validated_acc_id or self.bservice_info['account_id']
|
||||||
|
|
||||||
if self.bservice_id and self.bservice_info['status'] != 'DESTROYED':
|
if self.bservice_id and self.bservice_info['status'] != 'DESTROYED':
|
||||||
self.bservice_should_exist = True
|
self.bservice_should_exist = True
|
||||||
@@ -92,8 +104,8 @@ class decort_bservice(DecortController):
|
|||||||
self.result['changed'] = False
|
self.result['changed'] = False
|
||||||
if self.bservice_id:
|
if self.bservice_id:
|
||||||
self.result['msg'] = ("Invalid target state '{}' requested for B-service ID {} in the "
|
self.result['msg'] = ("Invalid target state '{}' requested for B-service ID {} in the "
|
||||||
"current status '{}'.").format(self.bservice_id,
|
"current status '{}'.").format(self.amodule.params['state'],
|
||||||
self.amodule.params['state'],
|
self.bservice_id,
|
||||||
self.bservice_info['status'])
|
self.bservice_info['status'])
|
||||||
else:
|
else:
|
||||||
self.result['msg'] = ("Invalid target state '{}' requested for non-existent B-service name '{}' "
|
self.result['msg'] = ("Invalid target state '{}' requested for non-existent B-service name '{}' "
|
||||||
@@ -112,7 +124,7 @@ class decort_bservice(DecortController):
|
|||||||
zone_id=self.aparams['zone_id'],
|
zone_id=self.aparams['zone_id'],
|
||||||
)
|
)
|
||||||
if self.bservice_id:
|
if self.bservice_id:
|
||||||
_, self.bservice_info = self.bservice_get_by_id(self.bservice_id)
|
self._bservice_info = self.bservice_get_by_id(self.bservice_id)
|
||||||
self.bservice_state(self.bservice_info, self.aparams['state'])
|
self.bservice_state(self.bservice_info, self.aparams['state'])
|
||||||
|
|
||||||
self.bservice_should_exist = True
|
self.bservice_should_exist = True
|
||||||
@@ -122,9 +134,9 @@ class decort_bservice(DecortController):
|
|||||||
self.bservice_state(self.bservice_info,d_state)
|
self.bservice_state(self.bservice_info,d_state)
|
||||||
|
|
||||||
aparam_zone_id = self.aparams['zone_id']
|
aparam_zone_id = self.aparams['zone_id']
|
||||||
if aparam_zone_id is not None and aparam_zone_id != self.bservice_info['zoneId']:
|
if aparam_zone_id is not None and aparam_zone_id != self.bservice_info['zone_id']:
|
||||||
self.bservice_migrate_to_zone(
|
self.sdk_checkmode(self.api.cloudapi.bservice.migrate_to_zone)(
|
||||||
bs_id=self.bservice_id,
|
bservice_id=self.bservice_id,
|
||||||
zone_id=aparam_zone_id,
|
zone_id=aparam_zone_id,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@@ -155,18 +167,9 @@ class decort_bservice(DecortController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if check_mode:
|
if check_mode:
|
||||||
# in check mode return immediately with the default values
|
|
||||||
return ret_dict
|
return ret_dict
|
||||||
|
|
||||||
ret_dict['id'] = self.bservice_info['id']
|
return self.bservice_info
|
||||||
ret_dict['name'] = self.bservice_info['name']
|
|
||||||
ret_dict['techStatus'] = self.bservice_info['techStatus']
|
|
||||||
ret_dict['state'] = self.bservice_info['status']
|
|
||||||
ret_dict['rg_id'] = self.bservice_info['rgId']
|
|
||||||
ret_dict['account_id'] = self.bservice_info['accountId']
|
|
||||||
ret_dict['groups'] = self.bservice_info['groups']
|
|
||||||
ret_dict['zone_id'] = self.bservice_info['zoneId']
|
|
||||||
return ret_dict
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def amodule_init_args(self) -> dict:
|
def amodule_init_args(self) -> dict:
|
||||||
@@ -228,14 +231,14 @@ class decort_bservice(DecortController):
|
|||||||
|
|
||||||
self.is_bservice_stopped_or_will_be_stopped = (
|
self.is_bservice_stopped_or_will_be_stopped = (
|
||||||
(
|
(
|
||||||
self.bservice_info['techStatus'] == 'STOPPED'
|
self.bservice_info['tech_status'] == 'STOPPED'
|
||||||
and (
|
and (
|
||||||
self.aparams['state'] is None
|
self.aparams['state'] is None
|
||||||
or self.aparams['state'] in ('present', 'stopped')
|
or self.aparams['state'] in ('present', 'stopped')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
or (
|
or (
|
||||||
self.bservice_info['techStatus'] != 'STOPPED'
|
self.bservice_info['tech_status'] != 'STOPPED'
|
||||||
and self.aparams['state'] == 'stopped'
|
and self.aparams['state'] == 'stopped'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -244,7 +247,7 @@ class decort_bservice(DecortController):
|
|||||||
check_errors = True
|
check_errors = True
|
||||||
if (
|
if (
|
||||||
self.aparams['zone_id'] is not None
|
self.aparams['zone_id'] is not None
|
||||||
and self.aparams['zone_id'] != self.bservice_info['zoneId']
|
and self.aparams['zone_id'] != self.bservice_info['zone_id']
|
||||||
and not self.is_bservice_stopped_or_will_be_stopped
|
and not self.is_bservice_stopped_or_will_be_stopped
|
||||||
):
|
):
|
||||||
check_errors = True
|
check_errors = True
|
||||||
@@ -270,7 +273,10 @@ class decort_bservice(DecortController):
|
|||||||
|
|
||||||
if self.amodule.check_mode:
|
if self.amodule.check_mode:
|
||||||
self.result['changed'] = False
|
self.result['changed'] = False
|
||||||
if self.bservice_id:
|
if (
|
||||||
|
self.bservice_id
|
||||||
|
or (self.aparams['rg_id'] and self.aparams['name'])
|
||||||
|
):
|
||||||
self.result['failed'] = False
|
self.result['failed'] = False
|
||||||
self.result['facts'] = self.package_facts(amodule.check_mode)
|
self.result['facts'] = self.package_facts(amodule.check_mode)
|
||||||
amodule.exit_json(**self.result)
|
amodule.exit_json(**self.result)
|
||||||
@@ -309,10 +315,12 @@ class decort_bservice(DecortController):
|
|||||||
else:
|
else:
|
||||||
self.action(amodule.params['state'])
|
self.action(amodule.params['state'])
|
||||||
elif self.bservice_info['status'] == "DESTROYED":
|
elif self.bservice_info['status'] == "DESTROYED":
|
||||||
if amodule.params['state'] in ('present','enabled'):
|
if amodule.params['state'] == 'present':
|
||||||
self.create()
|
self.create()
|
||||||
self.action(amodule.params['state'])
|
self.action(amodule.params['state'])
|
||||||
if amodule.params['state'] == 'absent':
|
elif amodule.params['state'] in ['enabled', 'disabled']:
|
||||||
|
self.error()
|
||||||
|
elif amodule.params['state'] == 'absent':
|
||||||
self.nop()
|
self.nop()
|
||||||
else:
|
else:
|
||||||
state = amodule.params['state']
|
state = amodule.params['state']
|
||||||
@@ -329,7 +337,9 @@ class decort_bservice(DecortController):
|
|||||||
amodule.fail_json(**self.result)
|
amodule.fail_json(**self.result)
|
||||||
else:
|
else:
|
||||||
if self.bservice_should_exist:
|
if self.bservice_should_exist:
|
||||||
_, self.bservice_info = self.bservice_get_by_id(self.bservice_id)
|
self._bservice_info = self.bservice_get_by_id(
|
||||||
|
self.bservice_id
|
||||||
|
)
|
||||||
self.result['facts'] = self.package_facts(amodule.check_mode)
|
self.result['facts'] = self.package_facts(amodule.check_mode)
|
||||||
amodule.exit_json(**self.result)
|
amodule.exit_json(**self.result)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class decort_disk(DecortController):
|
|||||||
|
|
||||||
if arg_amodule.params['place_with']:
|
if arg_amodule.params['place_with']:
|
||||||
image_id, image_facts = self.image_find(arg_amodule.params['place_with'], "", 0)
|
image_id, image_facts = self.image_find(arg_amodule.params['place_with'], "", 0)
|
||||||
arg_amodule.params['sep_id'] = image_facts['sepId']
|
arg_amodule.params['sep_id'] = image_facts['sep_id']
|
||||||
|
|
||||||
self.disk_id = validated_disk_id
|
self.disk_id = validated_disk_id
|
||||||
self.disk_info = validated_disk_facts
|
self.disk_info = validated_disk_facts
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class DecortDiskList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class DecortFlipGroupList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -21,7 +21,12 @@ class decort_group(DecortController):
|
|||||||
validated_bservice_id = None
|
validated_bservice_id = None
|
||||||
#find and validate B-Service
|
#find and validate B-Service
|
||||||
|
|
||||||
validated_bservice_id, bservice_info = self.bservice_get_by_id(arg_amodule.params['bservice_id'])
|
validated_bservice_id, self._bservice_info = self.bservice_find(
|
||||||
|
account_id=None,
|
||||||
|
rg_id=None,
|
||||||
|
bservice_id=arg_amodule.params['bservice_id'],
|
||||||
|
fail_if_not_found=False,
|
||||||
|
)
|
||||||
if not validated_bservice_id:
|
if not validated_bservice_id:
|
||||||
self.result['failed'] = True
|
self.result['failed'] = True
|
||||||
self.result['changed'] = False
|
self.result['changed'] = False
|
||||||
@@ -29,15 +34,14 @@ class decort_group(DecortController):
|
|||||||
self.amodule.fail_json(**self.result)
|
self.amodule.fail_json(**self.result)
|
||||||
#find group
|
#find group
|
||||||
self.bservice_id = validated_bservice_id
|
self.bservice_id = validated_bservice_id
|
||||||
self.bservice_info = bservice_info
|
|
||||||
self.group_id,self.group_info = self.group_find(
|
self.group_id,self.group_info = self.group_find(
|
||||||
bs_id=validated_bservice_id,
|
bs_id=validated_bservice_id,
|
||||||
bs_info=bservice_info,
|
bs_info=self.bservice_info,
|
||||||
group_id=arg_amodule.params['id'],
|
group_id=arg_amodule.params['id'],
|
||||||
group_name=arg_amodule.params['name'],
|
group_name=arg_amodule.params['name'],
|
||||||
)
|
)
|
||||||
self.acc_id = self.bservice_info['accountId']
|
self.acc_id = self.bservice_info['account_id']
|
||||||
self.rg_id = self.bservice_info['rgId']
|
self.rg_id = self.bservice_info['rg_id']
|
||||||
|
|
||||||
if self.group_id:
|
if self.group_id:
|
||||||
self.group_should_exist = True
|
self.group_should_exist = True
|
||||||
@@ -88,17 +92,19 @@ class decort_group(DecortController):
|
|||||||
warning=True,
|
warning=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.group_id=self.group_provision(
|
aparam_networks = self.amodule.params['networks'] or []
|
||||||
bs_id=self.bservice_id,
|
self.group_id = self.sdk_checkmode(self.api.cloudapi.bservice.group_add)(
|
||||||
arg_name=self.amodule.params['name'],
|
bservice_id=self.bservice_id,
|
||||||
arg_count=self.amodule.params['count'],
|
name=self.amodule.params['name'],
|
||||||
arg_cpu=self.amodule.params['cpu'],
|
vm_count=self.amodule.params['count'],
|
||||||
arg_ram=self.amodule.params['ram'],
|
cpu_count=self.amodule.params['cpu'],
|
||||||
arg_boot_disk=self.amodule.params['boot_disk'],
|
ram_size_mb=self.amodule.params['ram'],
|
||||||
arg_image_id=self.amodule.params['image_id'],
|
boot_disk_size_gb=self.amodule.params['boot_disk'],
|
||||||
arg_role=self.amodule.params['role'],
|
image_id=self.amodule.params['image_id'],
|
||||||
arg_network=self.amodule.params['networks'],
|
role=self.amodule.params['role'],
|
||||||
arg_timeout=self.amodule.params['timeoutStart'],
|
vins_ids=[n['id'] for n in aparam_networks if n['type'] == 'VINS'],
|
||||||
|
extnet_ids=[n['id'] for n in aparam_networks if n['type'] == 'EXTNET'],
|
||||||
|
start_timeout=self.amodule.params['timeoutStart'],
|
||||||
chipset=chipset,
|
chipset=chipset,
|
||||||
storage_policy_id=self.aparams['storage_policy_id'],
|
storage_policy_id=self.aparams['storage_policy_id'],
|
||||||
)
|
)
|
||||||
@@ -146,14 +152,15 @@ class decort_group(DecortController):
|
|||||||
aparam_value = self.aparams[aparam_name]
|
aparam_value = self.aparams[aparam_name]
|
||||||
group_info_value = self.group_info[info_key]
|
group_info_value = self.group_info[info_key]
|
||||||
if aparam_value != None and aparam_value != group_info_value:
|
if aparam_value != None and aparam_value != group_info_value:
|
||||||
self.group_update(
|
self.sdk_checkmode(self.api.cloudapi.bservice.group_update)(
|
||||||
bs_id=self.bservice_id,
|
bservice_id=self.bservice_id,
|
||||||
gr_dict=self.group_info,
|
bsgroup_id=self.group_info['id'],
|
||||||
arg_cpu=self.aparams['cpu'],
|
force=True,
|
||||||
arg_disk=self.aparams['boot_disk'],
|
cpu_count=self.aparams['cpu'],
|
||||||
arg_name=self.aparams['name'],
|
boot_disk_size_gb=self.aparams['boot_disk'],
|
||||||
arg_role=self.aparams['role'],
|
name=self.aparams['name'],
|
||||||
arg_ram=self.aparams['ram'],
|
ram_size_mb=self.aparams['ram'],
|
||||||
|
role=self.aparams['role'],
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -166,9 +173,9 @@ class decort_group(DecortController):
|
|||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
|
|
||||||
self.group_delete(
|
self.sdk_checkmode(self.api.cloudapi.bservice.group_remove)(
|
||||||
self.bservice_id,
|
bservice_id=self.bservice_id,
|
||||||
self.group_id
|
bsgroup_id=self.group_id,
|
||||||
)
|
)
|
||||||
self.group_should_exist = False
|
self.group_should_exist = False
|
||||||
|
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ class decort_image(DecortController):
|
|||||||
)
|
)
|
||||||
if self.virt_image_info:
|
if self.virt_image_info:
|
||||||
_, linked_image_info = self._image_get_by_id(
|
_, linked_image_info = self._image_get_by_id(
|
||||||
image_id=self.virt_image_info['linkTo']
|
image_id=self.virt_image_info['link_to']
|
||||||
)
|
)
|
||||||
self.acc_id = linked_image_info['accountId']
|
self.acc_id = linked_image_info['account_id']
|
||||||
if (
|
if (
|
||||||
self.aparams['virt_name'] is not None
|
self.aparams['virt_name'] is not None
|
||||||
and self.aparams['virt_name']
|
and self.aparams['virt_name']
|
||||||
@@ -61,10 +61,10 @@ class decort_image(DecortController):
|
|||||||
or self.aparams['image_name'] is not None
|
or self.aparams['image_name'] is not None
|
||||||
):
|
):
|
||||||
self.validated_image_id, self.image_info = (
|
self.validated_image_id, self.image_info = (
|
||||||
self.decort_image_find(amodule)
|
self.decort_image_find(amodule, fail_if_not_found=False)
|
||||||
)
|
)
|
||||||
if self.image_info:
|
if self.image_info:
|
||||||
self.acc_id = self.image_info['accountId']
|
self.acc_id = self.image_info['account_id']
|
||||||
if (
|
if (
|
||||||
amodule.params['image_name']
|
amodule.params['image_name']
|
||||||
and amodule.params['image_name'] != self.image_info['name']
|
and amodule.params['image_name'] != self.image_info['name']
|
||||||
@@ -72,6 +72,23 @@ class decort_image(DecortController):
|
|||||||
decort_image.decort_image_rename(self,amodule)
|
decort_image.decort_image_rename(self,amodule)
|
||||||
self.result['msg'] = ("Image renamed successfully")
|
self.result['msg'] = ("Image renamed successfully")
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.validated_image_id == 0
|
||||||
|
and self.aparams['image_id']
|
||||||
|
and not self.validated_virt_image_id
|
||||||
|
and not self.aparams['virt_name']
|
||||||
|
):
|
||||||
|
if self.aparams['state'] == 'absent':
|
||||||
|
self.exit()
|
||||||
|
else:
|
||||||
|
self.message(
|
||||||
|
self.MESSAGES.obj_not_found(
|
||||||
|
obj='image',
|
||||||
|
id=self.aparams['image_id'],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.exit(fail=True)
|
||||||
|
|
||||||
if self.validated_image_id:
|
if self.validated_image_id:
|
||||||
self.check_amodule_args_for_change()
|
self.check_amodule_args_for_change()
|
||||||
elif self.validated_virt_image_id:
|
elif self.validated_virt_image_id:
|
||||||
@@ -81,12 +98,13 @@ class decort_image(DecortController):
|
|||||||
else:
|
else:
|
||||||
self.check_amodule_args_for_create_image()
|
self.check_amodule_args_for_create_image()
|
||||||
|
|
||||||
def decort_image_find(self, amodule):
|
def decort_image_find(self, amodule, fail_if_not_found=True):
|
||||||
# function that finds the OS image
|
# function that finds the OS image
|
||||||
image_id, image_facts = self.image_find(image_id=amodule.params['image_id'], image_name=self.validated_image_name,
|
image_id, image_facts = self.image_find(image_id=amodule.params['image_id'], image_name=self.validated_image_name,
|
||||||
account_id=self.validated_account_id, rg_id=0,
|
account_id=self.validated_account_id, rg_id=0,
|
||||||
sepid=amodule.params['sep_id'],
|
sepid=amodule.params['sep_id'],
|
||||||
pool=amodule.params['pool'])
|
pool=amodule.params['pool'],
|
||||||
|
fail_if_not_found=fail_if_not_found,)
|
||||||
return image_id, image_facts
|
return image_id, image_facts
|
||||||
|
|
||||||
def decort_virt_image_find(self, amodule):
|
def decort_virt_image_find(self, amodule):
|
||||||
@@ -150,28 +168,30 @@ class decort_image(DecortController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# function that creates OS image
|
# function that creates OS image
|
||||||
image_facts = self.image_create(
|
self.sdk_checkmode(self.api.ca.image.create)(
|
||||||
img_name=self.validated_image_name,
|
name=self.validated_image_name,
|
||||||
url=amodule.params['url'],
|
download_url=amodule.params['url'],
|
||||||
boot_mode=boot_mode,
|
boot_mode=boot_mode,
|
||||||
boot_loader_type=loader_type,
|
boot_loader_type=loader_type,
|
||||||
hot_resize=hot_resize,
|
hot_resize=hot_resize,
|
||||||
username=amodule.params['image_username'],
|
os_user_name=amodule.params['image_username'],
|
||||||
password=amodule.params['image_password'],
|
os_password=amodule.params['image_password'],
|
||||||
account_id=self.validated_account_id,
|
account_id=self.validated_account_id,
|
||||||
usernameDL=amodule.params['usernameDL'],
|
download_user_name=amodule.params['usernameDL'],
|
||||||
passwordDL=amodule.params['passwordDL'],
|
download_password=amodule.params['passwordDL'],
|
||||||
sepId=amodule.params['sepId'],
|
sep_id=amodule.params['sepId'],
|
||||||
poolName=amodule.params['poolName'],
|
sep_pool_name=amodule.params['poolName'],
|
||||||
network_interface_naming=network_interface_naming,
|
network_interface_naming=network_interface_naming,
|
||||||
storage_policy_id=amodule.params['storage_policy_id'],
|
storage_policy_id=amodule.params['storage_policy_id'],
|
||||||
)
|
)
|
||||||
self.result['changed'] = True
|
return
|
||||||
return image_facts
|
|
||||||
|
|
||||||
def decort_virt_image_link(self,amodule):
|
def decort_virt_image_link(self,amodule):
|
||||||
# function that links an OS image to a virtual one
|
# function that links an OS image to a virtual one
|
||||||
self.virt_image_link(imageId=self.validated_virt_image_id, targetId=self.target_image_id)
|
self.sdk_checkmode(self.api.ca.image.link)(
|
||||||
|
virtual_image_id=self.validated_virt_image_id,
|
||||||
|
target_image_id=self.target_image_id,
|
||||||
|
)
|
||||||
image_id, image_facts = decort_image.decort_virt_image_find(self, amodule)
|
image_id, image_facts = decort_image.decort_virt_image_find(self, amodule)
|
||||||
self.result['facts'] = decort_image.decort_image_package_facts(image_facts, amodule.check_mode)
|
self.result['facts'] = decort_image.decort_image_package_facts(image_facts, amodule.check_mode)
|
||||||
self.result['msg'] = ("Image '{}' linked to virtual image '{}'").format(self.target_image_id,
|
self.result['msg'] = ("Image '{}' linked to virtual image '{}'").format(self.target_image_id,
|
||||||
@@ -189,9 +209,9 @@ class decort_image(DecortController):
|
|||||||
|
|
||||||
def decort_virt_image_create(self,amodule):
|
def decort_virt_image_create(self,amodule):
|
||||||
# function that creates a virtual image
|
# function that creates a virtual image
|
||||||
image_facts = self.virt_image_create(
|
self.sdk_checkmode(self.api.ca.image.create_virtual)(
|
||||||
name=amodule.params['virt_name'],
|
name=amodule.params['virt_name'],
|
||||||
target_id=self.target_image_id,
|
target_image_id=self.target_image_id,
|
||||||
account_id=self.aparams['account_id'],
|
account_id=self.aparams['account_id'],
|
||||||
)
|
)
|
||||||
image_id, image_facts = decort_image.decort_virt_image_find(self, amodule)
|
image_id, image_facts = decort_image.decort_virt_image_find(self, amodule)
|
||||||
@@ -250,14 +270,14 @@ class decort_image(DecortController):
|
|||||||
|
|
||||||
ret_dict['id'] = arg_image_facts['id']
|
ret_dict['id'] = arg_image_facts['id']
|
||||||
ret_dict['name'] = arg_image_facts['name']
|
ret_dict['name'] = arg_image_facts['name']
|
||||||
ret_dict['size'] = arg_image_facts['size']
|
ret_dict['size'] = arg_image_facts['size_gb']
|
||||||
# ret_dict['arch'] = arg_image_facts['architecture']
|
# ret_dict['arch'] = arg_image_facts['architecture']
|
||||||
ret_dict['sep_id'] = arg_image_facts['sepId']
|
ret_dict['sep_id'] = arg_image_facts['sep_id']
|
||||||
ret_dict['pool'] = arg_image_facts['pool']
|
ret_dict['pool'] = arg_image_facts['sep_pool_name']
|
||||||
ret_dict['state'] = arg_image_facts['status']
|
ret_dict['state'] = arg_image_facts['status']
|
||||||
ret_dict['linkto'] = arg_image_facts['linkTo']
|
ret_dict['linkto'] = arg_image_facts['link_to']
|
||||||
ret_dict['accountId'] = arg_image_facts['accountId']
|
ret_dict['accountId'] = arg_image_facts['account_id']
|
||||||
ret_dict['boot_mode'] = arg_image_facts['bootType']
|
ret_dict['boot_mode'] = arg_image_facts['boot_mode']
|
||||||
|
|
||||||
ret_dict['boot_loader_type'] = ''
|
ret_dict['boot_loader_type'] = ''
|
||||||
match arg_image_facts['type']:
|
match arg_image_facts['type']:
|
||||||
@@ -268,13 +288,13 @@ class decort_image(DecortController):
|
|||||||
ret_dict['boot_loader_type'] = boot_loader_type
|
ret_dict['boot_loader_type'] = boot_loader_type
|
||||||
|
|
||||||
ret_dict['network_interface_naming'] = arg_image_facts[
|
ret_dict['network_interface_naming'] = arg_image_facts[
|
||||||
'networkInterfaceNaming'
|
'network_interface_naming'
|
||||||
]
|
]
|
||||||
ret_dict['hot_resize'] = arg_image_facts['hotResize']
|
ret_dict['hot_resize'] = arg_image_facts['hot_resize']
|
||||||
ret_dict['storage_policy_id'] = arg_image_facts['storage_policy_id']
|
ret_dict['storage_policy_id'] = arg_image_facts['storage_policy_id']
|
||||||
ret_dict['to_clean'] = arg_image_facts['to_clean']
|
ret_dict['to_clean'] = arg_image_facts['to_clean']
|
||||||
ret_dict['independent'] = arg_image_facts['independent']
|
ret_dict['independent'] = arg_image_facts['independent']
|
||||||
ret_dict['links_to'] = arg_image_facts['linksTo']
|
ret_dict['links_to'] = arg_image_facts['links_to']
|
||||||
return ret_dict
|
return ret_dict
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -502,7 +522,7 @@ class decort_image(DecortController):
|
|||||||
and amodule.params['storage_policy_id']
|
and amodule.params['storage_policy_id']
|
||||||
!= image_facts['storage_policy_id']
|
!= image_facts['storage_policy_id']
|
||||||
):
|
):
|
||||||
self.image_change_storage_policy(
|
self.sdk_checkmode(self.api.ca.image.change_storage_policy)(
|
||||||
image_id=self.validated_virt_image_id,
|
image_id=self.validated_virt_image_id,
|
||||||
storage_policy_id=amodule.params['storage_policy_id'],
|
storage_policy_id=amodule.params['storage_policy_id'],
|
||||||
)
|
)
|
||||||
@@ -510,7 +530,7 @@ class decort_image(DecortController):
|
|||||||
if amodule.params['state'] == "absent" and self.validated_virt_image_id:
|
if amodule.params['state'] == "absent" and self.validated_virt_image_id:
|
||||||
amodule.image_id_delete = self.validated_virt_image_id
|
amodule.image_id_delete = self.validated_virt_image_id
|
||||||
image_id, image_facts = self.decort_virt_image_find(amodule)
|
image_id, image_facts = self.decort_virt_image_find(amodule)
|
||||||
if image_facts['status'] != 'PURGED':
|
if image_facts['status'] != sdk_types.ImageStatus.PURGED:
|
||||||
self.decort_image_delete(amodule)
|
self.decort_image_delete(amodule)
|
||||||
|
|
||||||
elif amodule.params['image_name'] or amodule.params['image_id']:
|
elif amodule.params['image_name'] or amodule.params['image_id']:
|
||||||
@@ -530,7 +550,10 @@ class decort_image(DecortController):
|
|||||||
elif amodule.params['state'] == "absent" and self.validated_image_id:
|
elif amodule.params['state'] == "absent" and self.validated_image_id:
|
||||||
amodule.image_id_delete = self.validated_image_id
|
amodule.image_id_delete = self.validated_image_id
|
||||||
image_id, image_facts = self.decort_image_find(amodule)
|
image_id, image_facts = self.decort_image_find(amodule)
|
||||||
if image_facts['status'] != 'DESTROYED':
|
if image_facts['status'] not in [
|
||||||
|
sdk_types.ImageStatus.DESTROYED,
|
||||||
|
sdk_types.ImageStatus.PURGED,
|
||||||
|
]:
|
||||||
self.decort_image_delete(amodule)
|
self.decort_image_delete(amodule)
|
||||||
|
|
||||||
if self.validated_image_id:
|
if self.validated_image_id:
|
||||||
@@ -539,7 +562,7 @@ class decort_image(DecortController):
|
|||||||
and amodule.params['storage_policy_id']
|
and amodule.params['storage_policy_id']
|
||||||
!= image_facts['storage_policy_id']
|
!= image_facts['storage_policy_id']
|
||||||
):
|
):
|
||||||
self.image_change_storage_policy(
|
self.sdk_checkmode(self.api.ca.image.change_storage_policy)(
|
||||||
image_id=self.validated_image_id,
|
image_id=self.validated_image_id,
|
||||||
storage_policy_id=amodule.params['storage_policy_id'],
|
storage_policy_id=amodule.params['storage_policy_id'],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ class DecortImageList(DecortController):
|
|||||||
choices=sdk_types.ImageStatus._member_names_,
|
choices=sdk_types.ImageStatus._member_names_,
|
||||||
),
|
),
|
||||||
type=dict(
|
type=dict(
|
||||||
type='str',
|
type='list',
|
||||||
|
elements='str',
|
||||||
choices=sdk_types.ImageType._member_names_,
|
choices=sdk_types.ImageType._member_names_,
|
||||||
),
|
),
|
||||||
storage_policy_id=dict(
|
storage_policy_id=dict(
|
||||||
@@ -145,7 +146,7 @@ class DecortImageList(DecortController):
|
|||||||
),
|
),
|
||||||
storage_policy_id=aparam_filter['storage_policy_id'],
|
storage_policy_id=aparam_filter['storage_policy_id'],
|
||||||
type=(
|
type=(
|
||||||
sdk_types.ImageType[aparam_type]
|
[sdk_types.ImageType[type_] for type_ in aparam_type]
|
||||||
if aparam_type else None
|
if aparam_type else None
|
||||||
),
|
),
|
||||||
page_number=aparam_pagination['number'],
|
page_number=aparam_pagination['number'],
|
||||||
|
|||||||
@@ -104,7 +104,9 @@ class decort_k8s(DecortController):
|
|||||||
self.k8s_info['vins_id'] = self.k8s_vins_id
|
self.k8s_info['vins_id'] = self.k8s_vins_id
|
||||||
self.k8s_info['config'] = None
|
self.k8s_info['config'] = None
|
||||||
if self.amodule.params['getConfig'] and self.k8s_info['tech_status'] == "STARTED":
|
if self.amodule.params['getConfig'] and self.k8s_info['tech_status'] == "STARTED":
|
||||||
self.k8s_info['config'] = self.k8s_getConfig()
|
self.k8s_info['config'] = self.api.cloudapi.k8s.get_config(
|
||||||
|
k8s_id=self.k8s_id,
|
||||||
|
)
|
||||||
return self.k8s_info
|
return self.k8s_info
|
||||||
|
|
||||||
def nop(self):
|
def nop(self):
|
||||||
@@ -269,7 +271,7 @@ class decort_k8s(DecortController):
|
|||||||
aparam_zone_id is not None
|
aparam_zone_id is not None
|
||||||
and aparam_zone_id != self.k8s_info['zone_id']
|
and aparam_zone_id != self.k8s_info['zone_id']
|
||||||
):
|
):
|
||||||
self.k8s_migrate_to_zone(
|
self.sdk_checkmode(self.api.cloudapi.k8s.migrate_to_zone)(
|
||||||
k8s_id=self.k8s_id,
|
k8s_id=self.k8s_id,
|
||||||
zone_id=aparam_zone_id,
|
zone_id=aparam_zone_id,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ class decort_lb(DecortController):
|
|||||||
aparam_zone_id is not None
|
aparam_zone_id is not None
|
||||||
and aparam_zone_id != self.lb_info.zone_id
|
and aparam_zone_id != self.lb_info.zone_id
|
||||||
):
|
):
|
||||||
self.lb_migrate_to_zone(
|
self.sdk_checkmode(self.api.cloudapi.lb.migrate_to_zone)(
|
||||||
lb_id=self.lb_info.id,
|
lb_id=self.lb_info.id,
|
||||||
zone_id=aparam_zone_id,
|
zone_id=aparam_zone_id,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ class decort_rg(DecortController):
|
|||||||
self.amodule.params['quotas'],
|
self.amodule.params['quotas'],
|
||||||
"", # this is location code. TODO: add module argument
|
"", # this is location code. TODO: add module argument
|
||||||
sdn_access_group_id=self.aparams['sdn_access_group_id'],
|
sdn_access_group_id=self.aparams['sdn_access_group_id'],
|
||||||
|
enable_default_gateway=self.aparams['enable_default_gateway'],
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.rg_id:
|
if self.rg_id:
|
||||||
@@ -410,6 +411,9 @@ class decort_rg(DecortController):
|
|||||||
sdn_access_group_id=dict(
|
sdn_access_group_id=dict(
|
||||||
type='str',
|
type='str',
|
||||||
),
|
),
|
||||||
|
enable_default_gateway=dict(
|
||||||
|
type='bool',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
@@ -431,6 +435,66 @@ class decort_rg(DecortController):
|
|||||||
)
|
)
|
||||||
check_errors = True
|
check_errors = True
|
||||||
|
|
||||||
|
if self.aparams['enable_default_gateway'] is not None:
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
self.aparams['def_netType'] is None
|
||||||
|
and self.rg_info.default_net_type != sdk_types.RGDefaultNetType.PRIVATE # noqa: E501
|
||||||
|
) or (
|
||||||
|
self.aparams['def_netType'] is not None
|
||||||
|
and self.aparams['def_netType'] != "PRIVATE"
|
||||||
|
)
|
||||||
|
):
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "enable_default_gateway" failed: '
|
||||||
|
'cannot use param enable_default_gateway with a '
|
||||||
|
'non-private default network.'
|
||||||
|
)
|
||||||
|
check_errors = True
|
||||||
|
|
||||||
|
if self.rg_info.default_net_type == sdk_types.RGDefaultNetType.PRIVATE: # noqa: E501
|
||||||
|
def_net = self.api.cloudapi.vins.get(
|
||||||
|
vins_id=self.rg_info.default_net_id
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
def_net.enable_default_gateway
|
||||||
|
!= self.aparams['enable_default_gateway']
|
||||||
|
):
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "enable_default_gateway" '
|
||||||
|
'failed: cannot change enable_default_gateway for a '
|
||||||
|
f'default network ID {self.rg_info.default_net_id}.'
|
||||||
|
)
|
||||||
|
check_errors = True
|
||||||
|
|
||||||
|
if check_errors:
|
||||||
|
self.exit(fail=True)
|
||||||
|
|
||||||
|
def check_amodule_args_for_create(self):
|
||||||
|
check_errors = False
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.aparams['enable_default_gateway'] is None
|
||||||
|
and self.aparams['def_netType'] == "PRIVATE"
|
||||||
|
):
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "enable_default_gateway" failed: '
|
||||||
|
'enable_default_gateway is required when creating a '
|
||||||
|
'resource group with a private network.'
|
||||||
|
)
|
||||||
|
check_errors = True
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.aparams['enable_default_gateway'] is not None
|
||||||
|
and self.aparams['def_netType'] != "PRIVATE"
|
||||||
|
):
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "enable_default_gateway" failed: '
|
||||||
|
'cannot create resource group with enable_default_gateway '
|
||||||
|
'for a non-private network group ID.'
|
||||||
|
)
|
||||||
|
check_errors = True
|
||||||
|
|
||||||
if check_errors:
|
if check_errors:
|
||||||
self.exit(fail=True)
|
self.exit(fail=True)
|
||||||
|
|
||||||
@@ -496,6 +560,7 @@ class decort_rg(DecortController):
|
|||||||
' the "rg_name" parameter was not specified.'
|
' the "rg_name" parameter was not specified.'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
self.check_amodule_args_for_create()
|
||||||
self.create()
|
self.create()
|
||||||
if amodule.params['access'] and not amodule.check_mode:
|
if amodule.params['access'] and not amodule.check_mode:
|
||||||
self.access()
|
self.access()
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class DecortRGList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -301,7 +301,8 @@ class DecortSecurityGroup(DecortController):
|
|||||||
match aparam_rules['mode']:
|
match aparam_rules['mode']:
|
||||||
case self.SecurityGroupRuleMode.delete.value:
|
case self.SecurityGroupRuleMode.delete.value:
|
||||||
for rule in rules:
|
for rule in rules:
|
||||||
self.security_group_detele_rule(
|
self.sdk_checkmode(
|
||||||
|
self.api.cloudapi.security_group.delete_rule)(
|
||||||
security_group_id=self.id,
|
security_group_id=self.id,
|
||||||
rule_id=rule['id'],
|
rule_id=rule['id'],
|
||||||
)
|
)
|
||||||
@@ -318,7 +319,8 @@ class DecortSecurityGroup(DecortController):
|
|||||||
)
|
)
|
||||||
rules_ids_to_delete = sg_rules_ids - aparam_rules_ids
|
rules_ids_to_delete = sg_rules_ids - aparam_rules_ids
|
||||||
for rule_id in rules_ids_to_delete:
|
for rule_id in rules_ids_to_delete:
|
||||||
self.security_group_detele_rule(
|
self.sdk_checkmode(
|
||||||
|
self.api.cloudapi.security_group.delete_rule)(
|
||||||
security_group_id=self.id,
|
security_group_id=self.id,
|
||||||
rule_id=rule_id,
|
rule_id=rule_id,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class DecortSecurityGroupList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class DecortStoragePolicyList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class DecortTrunkList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -154,6 +154,17 @@ class decort_vins(DecortController):
|
|||||||
warning=True,
|
warning=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
enable_default_gateway = self.amodule.params['enable_default_gateway']
|
||||||
|
if enable_default_gateway is None:
|
||||||
|
enable_default_gateway = True
|
||||||
|
self.message(
|
||||||
|
msg=self.MESSAGES.default_value_used(
|
||||||
|
param_name='enable_default_gateway',
|
||||||
|
default_value=enable_default_gateway
|
||||||
|
),
|
||||||
|
warning=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.vins_id = self.vins_provision(
|
self.vins_id = self.vins_provision(
|
||||||
vins_name=self.amodule.params['vins_name'],
|
vins_name=self.amodule.params['vins_name'],
|
||||||
account_id=self.acc_id,
|
account_id=self.acc_id,
|
||||||
@@ -164,6 +175,7 @@ class decort_vins(DecortController):
|
|||||||
desc=self.amodule.params['description'],
|
desc=self.amodule.params['description'],
|
||||||
zone_id=self.amodule.params['zone_id'],
|
zone_id=self.amodule.params['zone_id'],
|
||||||
security_group_mode=security_group_mode,
|
security_group_mode=security_group_mode,
|
||||||
|
enable_default_gateway=enable_default_gateway,
|
||||||
)
|
)
|
||||||
if self.vins_id:
|
if self.vins_id:
|
||||||
self._vins_info = self._vins_get_by_id(vins_id=self.vins_id)
|
self._vins_info = self._vins_get_by_id(vins_id=self.vins_id)
|
||||||
@@ -233,11 +245,20 @@ class decort_vins(DecortController):
|
|||||||
aparam_zone_id is not None
|
aparam_zone_id is not None
|
||||||
and aparam_zone_id != self.vins_info.zone_id
|
and aparam_zone_id != self.vins_info.zone_id
|
||||||
):
|
):
|
||||||
self.vins_migrate_to_zone(
|
self.sdk_checkmode(self.api.cloudapi.vins.migrate_to_zone)(
|
||||||
net_id=self.vins_info.id,
|
vins_id=self.vins_info.id,
|
||||||
zone_id=aparam_zone_id,
|
zone_id=aparam_zone_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.amodule.params['enable_default_gateway']
|
||||||
|
!= self.vins_info.enable_default_gateway
|
||||||
|
):
|
||||||
|
self.sdk_checkmode(self.api.cloudbroker.vins.update)(
|
||||||
|
vins_id=self.vins_info.id,
|
||||||
|
enable_default_gateway=self.amodule.params['enable_default_gateway'], # noqa: E501
|
||||||
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
@@ -383,6 +404,9 @@ class decort_vins(DecortController):
|
|||||||
zone_id=dict(
|
zone_id=dict(
|
||||||
type=int,
|
type=int,
|
||||||
),
|
),
|
||||||
|
enable_default_gateway=dict(
|
||||||
|
type='bool',
|
||||||
|
),
|
||||||
security_group_mode=dict(
|
security_group_mode=dict(
|
||||||
type='bool',
|
type='bool',
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class DecortVINSList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -456,9 +456,9 @@ class decort_vm(DecortController):
|
|||||||
image_id=self.amodule.params['image_id'],
|
image_id=self.amodule.params['image_id'],
|
||||||
account_id=self.acc_id)
|
account_id=self.acc_id)
|
||||||
|
|
||||||
if validated_bdisk_size <= image_facts['size']:
|
if validated_bdisk_size <= image_facts['size_gb']:
|
||||||
# adjust disk size to the minimum allowed by OS image, which will be used to spin off this Compute
|
# adjust disk size to the minimum allowed by OS image, which will be used to spin off this Compute
|
||||||
validated_bdisk_size = image_facts['size']
|
validated_bdisk_size = image_facts['size_gb']
|
||||||
|
|
||||||
# NOTE: due to a libvirt "feature", that impacts management of a VM created without any network interfaces,
|
# NOTE: due to a libvirt "feature", that impacts management of a VM created without any network interfaces,
|
||||||
# we create KVM VM in HALTED state.
|
# we create KVM VM in HALTED state.
|
||||||
@@ -495,6 +495,10 @@ class decort_vm(DecortController):
|
|||||||
if numa_affinity is None:
|
if numa_affinity is None:
|
||||||
numa_affinity = 'none'
|
numa_affinity = 'none'
|
||||||
|
|
||||||
|
clock_sync_mode = self.aparams['clock_sync_mode']
|
||||||
|
if clock_sync_mode is None:
|
||||||
|
clock_sync_mode = 'default'
|
||||||
|
|
||||||
chipset = self.amodule.params['chipset']
|
chipset = self.amodule.params['chipset']
|
||||||
if chipset is None:
|
if chipset is None:
|
||||||
chipset = 'Q35'
|
chipset = 'Q35'
|
||||||
@@ -552,6 +556,8 @@ class decort_vm(DecortController):
|
|||||||
zone_id=self.aparams['zone_id'],
|
zone_id=self.aparams['zone_id'],
|
||||||
storage_policy_id=self.aparams['storage_policy_id'],
|
storage_policy_id=self.aparams['storage_policy_id'],
|
||||||
os_version=self.aparams['os_version'],
|
os_version=self.aparams['os_version'],
|
||||||
|
cpu_alignment_profile_name=self.aparams['cpu_alignment_profile_name'],
|
||||||
|
clock_sync_mode=clock_sync_mode,
|
||||||
)
|
)
|
||||||
self.comp_should_exist = True
|
self.comp_should_exist = True
|
||||||
|
|
||||||
@@ -704,9 +710,9 @@ class decort_vm(DecortController):
|
|||||||
vm_disk=disk,
|
vm_disk=disk,
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
self.compute_boot_disk(
|
self.sdk_checkmode(self.api.cloudapi.compute.boot_disk_set)(
|
||||||
comp_id=self.comp_info['id'],
|
vm_id=self.comp_info['id'],
|
||||||
boot_disk=aparam_disk_id,
|
disk_id=aparam_disk_id,
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -744,7 +750,7 @@ class decort_vm(DecortController):
|
|||||||
_, image_facts = self.image_find(
|
_, image_facts = self.image_find(
|
||||||
image_id=self.aparams['image_id'],
|
image_id=self.aparams['image_id'],
|
||||||
)
|
)
|
||||||
disk_size = image_facts['size']
|
disk_size = image_facts['size_gb']
|
||||||
|
|
||||||
os_version = None
|
os_version = None
|
||||||
if (
|
if (
|
||||||
@@ -782,8 +788,8 @@ class decort_vm(DecortController):
|
|||||||
compute_custom_fields = self.comp_info['custom_fields']
|
compute_custom_fields = self.comp_info['custom_fields']
|
||||||
if aparam_custom_fields['disable']:
|
if aparam_custom_fields['disable']:
|
||||||
if compute_custom_fields is not None:
|
if compute_custom_fields is not None:
|
||||||
self.compute_disable_custom_fields(
|
self.sdk_checkmode(self.api.ca.compute.delete_custom_fields)(
|
||||||
compute_id=self.comp_info['id'],
|
vm_id=self.comp_info['id'],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if compute_custom_fields != aparam_custom_fields['fields']:
|
if compute_custom_fields != aparam_custom_fields['fields']:
|
||||||
@@ -794,8 +800,8 @@ class decort_vm(DecortController):
|
|||||||
|
|
||||||
aparam_zone_id = self.aparams['zone_id']
|
aparam_zone_id = self.aparams['zone_id']
|
||||||
if aparam_zone_id is not None and aparam_zone_id != self.comp_info['zoneId']:
|
if aparam_zone_id is not None and aparam_zone_id != self.comp_info['zoneId']:
|
||||||
self.compute_migrate_to_zone(
|
self.sdk_checkmode(self.api.cloudapi.compute.migrate_to_zone)(
|
||||||
compute_id=self.comp_id,
|
vm_id=self.comp_id,
|
||||||
zone_id=aparam_zone_id,
|
zone_id=aparam_zone_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -806,15 +812,21 @@ class decort_vm(DecortController):
|
|||||||
aparam_guest_agent['enabled']
|
aparam_guest_agent['enabled']
|
||||||
and not self.comp_info['qemu_guest']['enabled']
|
and not self.comp_info['qemu_guest']['enabled']
|
||||||
):
|
):
|
||||||
self.compute_guest_agent_enable(vm_id=self.comp_id)
|
self.sdk_checkmode(
|
||||||
|
self.api.cloudapi.compute.guest_agent_enable
|
||||||
|
)(vm_id=self.comp_id)
|
||||||
elif (
|
elif (
|
||||||
aparam_guest_agent['enabled'] is False
|
aparam_guest_agent['enabled'] is False
|
||||||
and self.comp_info['qemu_guest']['enabled']
|
and self.comp_info['qemu_guest']['enabled']
|
||||||
):
|
):
|
||||||
self.compute_guest_agent_disable(vm_id=self.comp_id)
|
self.sdk_checkmode(
|
||||||
|
self.api.cloudapi.compute.guest_agent_disable
|
||||||
|
)(vm_id=self.comp_id)
|
||||||
|
|
||||||
if aparam_guest_agent['update_available_commands']:
|
if aparam_guest_agent['update_available_commands']:
|
||||||
self.compute_guest_agent_feature_update(vm_id=self.comp_id)
|
self.sdk_checkmode(
|
||||||
|
self.api.cloudapi.compute.guest_agent_feature_update
|
||||||
|
)(vm_id=self.comp_id)
|
||||||
|
|
||||||
aparam_guest_agent_exec = aparam_guest_agent['exec']
|
aparam_guest_agent_exec = aparam_guest_agent['exec']
|
||||||
if aparam_guest_agent_exec is not None:
|
if aparam_guest_agent_exec is not None:
|
||||||
@@ -848,6 +860,28 @@ class decort_vm(DecortController):
|
|||||||
vm_id=self.comp_id,
|
vm_id=self.comp_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cpu_alignment_profile = self.aparams['cpu_alignment_profile_name']
|
||||||
|
|
||||||
|
if cpu_alignment_profile:
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
self.comp_info['cpu_alignment_profile']
|
||||||
|
and cpu_alignment_profile != self.comp_info['cpu_alignment_profile']['name']
|
||||||
|
)
|
||||||
|
or not self.comp_info['cpu_alignment_profile']
|
||||||
|
):
|
||||||
|
self.sdk_checkmode(self.api.ca.compute.set_cpu_alignment_profile)(
|
||||||
|
vm_ids=[self.comp_id],
|
||||||
|
cpu_alignment_profile_name=self.aparams['cpu_alignment_profile_name'],
|
||||||
|
)
|
||||||
|
elif (
|
||||||
|
cpu_alignment_profile == ''
|
||||||
|
and self.comp_info['cpu_alignment_profile']
|
||||||
|
):
|
||||||
|
self.sdk_checkmode(self.api.ca.compute.delete_cpu_alignment_profile)(
|
||||||
|
vm_ids=[self.comp_id],
|
||||||
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -868,6 +902,7 @@ class decort_vm(DecortController):
|
|||||||
'network_interface_naming': 'networkInterfaceNaming',
|
'network_interface_naming': 'networkInterfaceNaming',
|
||||||
'hot_resize': 'hotResize',
|
'hot_resize': 'hotResize',
|
||||||
'os_version': 'os_version',
|
'os_version': 'os_version',
|
||||||
|
'clock_sync_mode': 'clock',
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_nested_value(
|
def get_nested_value(
|
||||||
@@ -948,7 +983,6 @@ class decort_vm(DecortController):
|
|||||||
password="",
|
password="",
|
||||||
public_ips=[], # direct IPs; this list can be empty
|
public_ips=[], # direct IPs; this list can be empty
|
||||||
private_ips=[], # IPs on ViNSes; usually, at least one IP is listed
|
private_ips=[], # IPs on ViNSes; usually, at least one IP is listed
|
||||||
nat_ip="", # IP of the external ViNS interface; can be empty.
|
|
||||||
tags={},
|
tags={},
|
||||||
chipset="",
|
chipset="",
|
||||||
interfaces=[],
|
interfaces=[],
|
||||||
@@ -987,16 +1021,9 @@ class decort_vm(DecortController):
|
|||||||
ret_dict['password'] = self.comp_info['osUsers'][0]['password']
|
ret_dict['password'] = self.comp_info['osUsers'][0]['password']
|
||||||
|
|
||||||
if self.comp_info['interfaces']:
|
if self.comp_info['interfaces']:
|
||||||
# We need a list of all ViNSes in the account, which owns this Compute
|
|
||||||
# to find a ViNS, which may have active external connection. Then
|
|
||||||
# we will save external IP address of that connection in ret_dict['nat_ip']
|
|
||||||
|
|
||||||
for iface in self.comp_info['interfaces']:
|
for iface in self.comp_info['interfaces']:
|
||||||
if iface['connType'] == "VXLAN": # This is ViNS connection
|
if iface['connType'] == "VXLAN": # This is ViNS connection
|
||||||
ret_dict['private_ips'].append(iface['ipAddress'])
|
ret_dict['private_ips'].append(iface['ipAddress'])
|
||||||
# if iface['connId']
|
|
||||||
# Now we need to check if this ViNS has GW function and external connection.
|
|
||||||
# If it does - save public IP address of GW VNF in ret_dict['nat_ip']
|
|
||||||
elif iface['connType'] == "VLAN": # This is direct external network connection
|
elif iface['connType'] == "VLAN": # This is direct external network connection
|
||||||
ret_dict['public_ips'].append(iface['ipAddress'])
|
ret_dict['public_ips'].append(iface['ipAddress'])
|
||||||
|
|
||||||
@@ -1010,6 +1037,7 @@ class decort_vm(DecortController):
|
|||||||
|
|
||||||
ret_dict['disks'] = self.comp_info['disks']
|
ret_dict['disks'] = self.comp_info['disks']
|
||||||
for disk in ret_dict['disks']:
|
for disk in ret_dict['disks']:
|
||||||
|
disk['read_only_mode'] = disk.pop('read_only')
|
||||||
if self.is_vm_boot_disk(
|
if self.is_vm_boot_disk(
|
||||||
vm_chipset=self.comp_info['chipset'],
|
vm_chipset=self.comp_info['chipset'],
|
||||||
vm_disk=disk,
|
vm_disk=disk,
|
||||||
@@ -1017,6 +1045,9 @@ class decort_vm(DecortController):
|
|||||||
# if it is a boot disk - store its size
|
# if it is a boot disk - store its size
|
||||||
ret_dict['disk_size'] = disk['sizeMax']
|
ret_dict['disk_size'] = disk['sizeMax']
|
||||||
|
|
||||||
|
for snapshot in disk['snapshots']:
|
||||||
|
snapshot['pool_name'] = snapshot.pop('poolName')
|
||||||
|
|
||||||
ret_dict['chipset'] = self.comp_info['chipset']
|
ret_dict['chipset'] = self.comp_info['chipset']
|
||||||
|
|
||||||
ret_dict['interfaces'] = self.comp_info['interfaces']
|
ret_dict['interfaces'] = self.comp_info['interfaces']
|
||||||
@@ -1088,6 +1119,12 @@ class decort_vm(DecortController):
|
|||||||
|
|
||||||
ret_dict['weight'] = self.comp_info['weight']
|
ret_dict['weight'] = self.comp_info['weight']
|
||||||
|
|
||||||
|
ret_dict['clock_sync_mode'] = self.comp_info['clock']
|
||||||
|
|
||||||
|
ret_dict['cpu_alignment_profile'] = self.comp_info['cpu_alignment_profile']
|
||||||
|
|
||||||
|
ret_dict['resized_online'] = self.comp_info['resizedOnline']
|
||||||
|
|
||||||
return ret_dict
|
return ret_dict
|
||||||
|
|
||||||
def check_amodule_args_for_create(self):
|
def check_amodule_args_for_create(self):
|
||||||
@@ -1175,6 +1212,20 @@ class decort_vm(DecortController):
|
|||||||
|
|
||||||
if self.check_aparam_zone_id() is False:
|
if self.check_aparam_zone_id() is False:
|
||||||
check_errors = True
|
check_errors = True
|
||||||
|
else:
|
||||||
|
if (
|
||||||
|
self.aparams['cpu_alignment_profile_name']
|
||||||
|
and self.aparams['zone_id']
|
||||||
|
):
|
||||||
|
zone_info = self.zone_get(self.aparams['zone_id'])
|
||||||
|
if not zone_info['cpu_alignment_profiles']:
|
||||||
|
check_errors = True
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "zone_id" failed:'
|
||||||
|
f' zone ID {self.aparams['zone_id']} must contain'
|
||||||
|
' cpu alignment profiles'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if self.aparams['guest_agent'] is not None:
|
if self.aparams['guest_agent'] is not None:
|
||||||
check_errors = True
|
check_errors = True
|
||||||
@@ -1230,6 +1281,17 @@ class decort_vm(DecortController):
|
|||||||
'abort_cloning can be specified only for existing compute.'
|
'abort_cloning can be specified only for existing compute.'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.aparams['cpu_alignment_profile_name'] is not None
|
||||||
|
and self.aparams['custom_fields'] is not None
|
||||||
|
):
|
||||||
|
check_errors = True
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "cpu_alignment_profile_name" failed: '
|
||||||
|
'cpu_alignment_profile_name cannot be used together '
|
||||||
|
'with parameter "custom_fields".'
|
||||||
|
)
|
||||||
|
|
||||||
if check_errors:
|
if check_errors:
|
||||||
self.exit(fail=True)
|
self.exit(fail=True)
|
||||||
|
|
||||||
@@ -1386,6 +1448,9 @@ class decort_vm(DecortController):
|
|||||||
net_prefix=dict(
|
net_prefix=dict(
|
||||||
type='int',
|
type='int',
|
||||||
),
|
),
|
||||||
|
enable_default_gateway=dict(
|
||||||
|
type='bool',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
required_if=[
|
required_if=[
|
||||||
('type', 'VINS', ('id',)),
|
('type', 'VINS', ('id',)),
|
||||||
@@ -1602,6 +1667,18 @@ class decort_vm(DecortController):
|
|||||||
abort_cloning=dict(
|
abort_cloning=dict(
|
||||||
type='bool',
|
type='bool',
|
||||||
),
|
),
|
||||||
|
cpu_alignment_profile_name=dict(
|
||||||
|
type='str',
|
||||||
|
),
|
||||||
|
clock_sync_mode=dict(
|
||||||
|
type='str',
|
||||||
|
choices=[
|
||||||
|
'default',
|
||||||
|
'linux',
|
||||||
|
'windows',
|
||||||
|
'none',
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
required_one_of=[
|
required_one_of=[
|
||||||
@@ -1928,6 +2005,22 @@ class decort_vm(DecortController):
|
|||||||
|
|
||||||
if self.check_aparam_zone_id() is False:
|
if self.check_aparam_zone_id() is False:
|
||||||
check_errors = True
|
check_errors = True
|
||||||
|
else:
|
||||||
|
if (
|
||||||
|
self.aparams['zone_id']
|
||||||
|
and self.aparams['zone_id'] != self.comp_info['zoneId']
|
||||||
|
):
|
||||||
|
zone_info = self.zone_get(self.aparams['zone_id'])
|
||||||
|
if (
|
||||||
|
not zone_info['cpu_alignment_profiles']
|
||||||
|
and self.comp_info['cpu_alignment_profile']
|
||||||
|
):
|
||||||
|
check_errors = True
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "zone_id" failed: '
|
||||||
|
f'zone ID {self.aparams['zone_id']} '
|
||||||
|
'must contain cpu alignment profiles.'
|
||||||
|
)
|
||||||
|
|
||||||
if self.check_aparam_guest_agent() is False:
|
if self.check_aparam_guest_agent() is False:
|
||||||
check_errors = True
|
check_errors = True
|
||||||
@@ -1993,6 +2086,18 @@ class decort_vm(DecortController):
|
|||||||
'Only networks of type VINS, EXTNET, DPDK, SDN, TRUNK '
|
'Only networks of type VINS, EXTNET, DPDK, SDN, TRUNK '
|
||||||
'can be enabled or disabled.'
|
'can be enabled or disabled.'
|
||||||
)
|
)
|
||||||
|
if (
|
||||||
|
network['enable_default_gateway'] is not None
|
||||||
|
and network['type'] != self.VMNetType.VINS.value
|
||||||
|
):
|
||||||
|
check_errors = True
|
||||||
|
self.message(
|
||||||
|
'Check for parameter '
|
||||||
|
'"networks.enable_default_gateway" failed: '
|
||||||
|
'Can not enable or disable default gateway for network'
|
||||||
|
f' ID {network['id']} and type {network['type']}. '
|
||||||
|
'Only networks of type VINS can have default gateway.'
|
||||||
|
)
|
||||||
|
|
||||||
if self.check_aparam_cdrom() is False:
|
if self.check_aparam_cdrom() is False:
|
||||||
check_errors = True
|
check_errors = True
|
||||||
@@ -2003,6 +2108,27 @@ class decort_vm(DecortController):
|
|||||||
if self.check_aparam_image_id() is False:
|
if self.check_aparam_image_id() is False:
|
||||||
check_errors = True
|
check_errors = True
|
||||||
|
|
||||||
|
if self.aparams['cpu_alignment_profile_name'] is not None:
|
||||||
|
if self.comp_info['snapSets'] or self.comp_info['custom_fields']:
|
||||||
|
check_errors = True
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "cpu_alignment_profile_name" failed: '
|
||||||
|
'VM should not contain snapshots or custom fields.'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.aparams['boot']
|
||||||
|
and self.aparams['boot']['disk_redeploy'] is not None
|
||||||
|
and self.aparams['image_id'] is not None
|
||||||
|
):
|
||||||
|
if self.aparams['storage_policy_id'] is None:
|
||||||
|
check_errors = True
|
||||||
|
self.message(
|
||||||
|
f'Check for parameter "storage_policy_id" failed: '
|
||||||
|
'storage_policy_id must be specified when changing '
|
||||||
|
'the OS image'
|
||||||
|
)
|
||||||
|
|
||||||
if check_errors:
|
if check_errors:
|
||||||
self.exit(fail=True)
|
self.exit(fail=True)
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class DecortVMList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ description: See L(Module Documentation,https://repository.basistech.ru/BASIS/de
|
|||||||
import time
|
import time
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.decort_utils import DecortController
|
from ansible.module_utils.decort_utils import DecortController
|
||||||
|
import dynamix_sdk.types as sdk_types
|
||||||
|
|
||||||
|
|
||||||
class DecortVMSnapshot(DecortController):
|
class DecortVMSnapshot(DecortController):
|
||||||
@@ -21,6 +22,7 @@ class DecortVMSnapshot(DecortController):
|
|||||||
self.vm_facts: dict
|
self.vm_facts: dict
|
||||||
self.aparams_label = self.aparams['label']
|
self.aparams_label = self.aparams['label']
|
||||||
self.aparams_vm_id = self.aparams['vm_id']
|
self.aparams_vm_id = self.aparams['vm_id']
|
||||||
|
self.vm_snapshot: sdk_types.SnapshotSetAPIResultNM | None = None
|
||||||
|
|
||||||
self.vm_id, self.vm_facts, _ = self._compute_get_by_id(
|
self.vm_id, self.vm_facts, _ = self._compute_get_by_id(
|
||||||
comp_id=self.aparams_vm_id,
|
comp_id=self.aparams_vm_id,
|
||||||
@@ -50,6 +52,9 @@ class DecortVMSnapshot(DecortController):
|
|||||||
and self.aparams_label is not None
|
and self.aparams_label is not None
|
||||||
and self.aparams_label not in self.vm_snapshot_labels
|
and self.aparams_label not in self.vm_snapshot_labels
|
||||||
):
|
):
|
||||||
|
if self.aparams['state'] == 'absent':
|
||||||
|
self.exit()
|
||||||
|
else:
|
||||||
self.message(
|
self.message(
|
||||||
f'Snapshot {self.aparams_label} '
|
f'Snapshot {self.aparams_label} '
|
||||||
f'not found for VM {self.aparams_vm_id}'
|
f'not found for VM {self.aparams_vm_id}'
|
||||||
@@ -79,6 +84,9 @@ class DecortVMSnapshot(DecortController):
|
|||||||
type='int',
|
type='int',
|
||||||
required=True,
|
required=True,
|
||||||
),
|
),
|
||||||
|
with_memory=dict(
|
||||||
|
type='bool',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
required_if=[
|
required_if=[
|
||||||
@@ -119,6 +127,7 @@ class DecortVMSnapshot(DecortController):
|
|||||||
label = self.new_snapshot_label or self.aparams_label
|
label = self.new_snapshot_label or self.aparams_label
|
||||||
for snapshot in self.vm_snapshots:
|
for snapshot in self.vm_snapshots:
|
||||||
if snapshot.label == label:
|
if snapshot.label == label:
|
||||||
|
self.vm_snapshot = snapshot
|
||||||
self.facts = snapshot.model_dump()
|
self.facts = snapshot.model_dump()
|
||||||
if self.aparams['usage']:
|
if self.aparams['usage']:
|
||||||
self.facts['stored'] = self.get_snapshot_usage()
|
self.facts['stored'] = self.get_snapshot_usage()
|
||||||
@@ -137,9 +146,22 @@ class DecortVMSnapshot(DecortController):
|
|||||||
self.abort_merge()
|
self.abort_merge()
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
|
with_memory = self.aparams['with_memory']
|
||||||
|
|
||||||
|
if with_memory is None:
|
||||||
|
with_memory = False
|
||||||
|
self.message(
|
||||||
|
msg=self.MESSAGES.default_value_used(
|
||||||
|
param_name='with_memory',
|
||||||
|
default_value=with_memory
|
||||||
|
),
|
||||||
|
warning=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.sdk_checkmode(self.api.cloudapi.compute.snapshot_create)(
|
self.sdk_checkmode(self.api.cloudapi.compute.snapshot_create)(
|
||||||
vm_id=self.aparams_vm_id,
|
vm_id=self.aparams_vm_id,
|
||||||
label=self.new_snapshot_label,
|
label=self.new_snapshot_label,
|
||||||
|
with_memory=with_memory,
|
||||||
)
|
)
|
||||||
self.get_info(update_vm_snapshots=True)
|
self.get_info(update_vm_snapshots=True)
|
||||||
|
|
||||||
@@ -151,10 +173,16 @@ class DecortVMSnapshot(DecortController):
|
|||||||
self.facts = {}
|
self.facts = {}
|
||||||
|
|
||||||
def abort_merge(self):
|
def abort_merge(self):
|
||||||
self.snapshot_abort_merge(
|
self.sdk_checkmode(
|
||||||
|
self.api.cloudapi.compute.abort_shared_snapshot_merge
|
||||||
|
)(
|
||||||
vm_id=self.aparams_vm_id,
|
vm_id=self.aparams_vm_id,
|
||||||
label=self.aparams_label,
|
label=self.aparams_label,
|
||||||
)
|
)
|
||||||
|
self.message(
|
||||||
|
f'Merge aborted for snapshot {self.aparams_label} of VM ID '
|
||||||
|
f'{self.aparams_vm_id}.'
|
||||||
|
)
|
||||||
self.get_info()
|
self.get_info()
|
||||||
|
|
||||||
def get_snapshot_usage(self) -> int:
|
def get_snapshot_usage(self) -> int:
|
||||||
@@ -178,7 +206,33 @@ class DecortVMSnapshot(DecortController):
|
|||||||
'Merge can be aborted only for VM in "MERGE" tech status.'
|
'Merge can be aborted only for VM in "MERGE" tech status.'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.aparams['with_memory'] is not None
|
||||||
|
and self.vm_snapshot
|
||||||
|
):
|
||||||
|
if self.aparams['with_memory'] != bool(
|
||||||
|
self.vm_snapshot.memory_dump_image_id
|
||||||
|
):
|
||||||
|
check_errors = True
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "with_memory" failed: '
|
||||||
|
'Changing the "with_memory" parameter is not '
|
||||||
|
'allowed for an existing snapshot.'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.vm_facts['techStatus'] != 'STARTED'
|
||||||
|
and self.aparams['with_memory']
|
||||||
|
):
|
||||||
|
check_errors = True
|
||||||
|
self.message(
|
||||||
|
'Check for parameter "with_memory" failed: '
|
||||||
|
f'VM ID {self.aparams_vm_id} must be started '
|
||||||
|
'to create snapshot with memory dump.'
|
||||||
|
)
|
||||||
|
|
||||||
if check_errors:
|
if check_errors:
|
||||||
|
self.facts = {}
|
||||||
self.exit(fail=True)
|
self.exit(fail=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class DecortZoneList(DecortController):
|
|||||||
),
|
),
|
||||||
size=dict(
|
size=dict(
|
||||||
type='int',
|
type='int',
|
||||||
default=50,
|
default=100,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,3 @@
|
|||||||
ansible==11.6.0
|
ansible==11.6.0
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
git+https://repository.basistech.ru/BASIS/dynamix-python-sdk.git@1.5.latest
|
git+https://repository.basistech.ru/BASIS/dynamix-python-sdk.git@2.0.latest
|
||||||
|
|||||||
Reference in New Issue
Block a user