12.0.0
This commit is contained in:
@@ -42,7 +42,7 @@ class decort_vm(DecortController):
|
||||
|
||||
validated_acc_id = 0
|
||||
validated_rg_id = 0
|
||||
validated_rg_facts = None
|
||||
validated_rg_model = None
|
||||
|
||||
self.vm_to_clone_id = 0
|
||||
self.vm_to_clone_info = None
|
||||
@@ -118,21 +118,21 @@ class decort_vm(DecortController):
|
||||
self.fail_json(**self.result)
|
||||
# fail the module -> exit
|
||||
# now validate RG
|
||||
validated_rg_id, validated_rg_facts = self.rg_find(validated_acc_id,
|
||||
validated_rg_id, validated_rg_model = self.rg_find(validated_acc_id,
|
||||
arg_amodule.params['rg_id'],
|
||||
arg_amodule.params['rg_name'])
|
||||
if not validated_rg_id:
|
||||
if not validated_rg_id or not validated_rg_model:
|
||||
self.result['failed'] = True
|
||||
self.result['changed'] = False
|
||||
self.result['msg'] = "Cannot find RG ID {} / name '{}'.".format(arg_amodule.params['rg_id'],
|
||||
arg_amodule.params['rg_name'])
|
||||
self.fail_json(**self.result)
|
||||
self.amodule.fail_json(**self.result)
|
||||
# fail the module - exit
|
||||
|
||||
self.rg_id = validated_rg_id
|
||||
arg_amodule.params['rg_id'] = validated_rg_id
|
||||
arg_amodule.params['rg_name'] = validated_rg_facts['name']
|
||||
self.acc_id = validated_rg_facts['accountId']
|
||||
arg_amodule.params['rg_name'] = validated_rg_model.name
|
||||
self.acc_id = validated_rg_model.account_id
|
||||
|
||||
# at this point we are ready to locate Compute, and if anything fails now, then it must be
|
||||
# because this Compute does not exist or something goes wrong in the upstream API
|
||||
@@ -635,7 +635,11 @@ class decort_vm(DecortController):
|
||||
"""Compute destroy handler for VM management by decort_vm module.
|
||||
Note that this handler deletes the VM permanently together with all assigned disk resources.
|
||||
"""
|
||||
self.compute_delete(comp_id=self.comp_id, permanently=True)
|
||||
self.sdk_checkmode(self.api.ca.compute.delete)(
|
||||
vm_id=self.comp_id,
|
||||
detach_disks=True,
|
||||
permanently=True,
|
||||
)
|
||||
self.comp_id, self.comp_info, _ = self._compute_get_by_id(self.comp_id)
|
||||
return
|
||||
|
||||
@@ -693,7 +697,13 @@ class decort_vm(DecortController):
|
||||
aparam_disk_id = aparam_boot['disk_id']
|
||||
if aparam_disk_id is not None:
|
||||
for disk in self.comp_info['disks']:
|
||||
if disk['id'] == aparam_disk_id and disk['type'] != 'B':
|
||||
if (
|
||||
disk['id'] == aparam_disk_id
|
||||
and not self.is_vm_boot_disk(
|
||||
vm_chipset=self.comp_info['chipset'],
|
||||
vm_disk=disk,
|
||||
)
|
||||
):
|
||||
self.compute_boot_disk(
|
||||
comp_id=self.comp_info['id'],
|
||||
boot_disk=aparam_disk_id,
|
||||
@@ -1000,7 +1010,10 @@ class decort_vm(DecortController):
|
||||
|
||||
ret_dict['disks'] = self.comp_info['disks']
|
||||
for disk in ret_dict['disks']:
|
||||
if disk['type'] == 'B':
|
||||
if self.is_vm_boot_disk(
|
||||
vm_chipset=self.comp_info['chipset'],
|
||||
vm_disk=disk,
|
||||
):
|
||||
# if it is a boot disk - store its size
|
||||
ret_dict['disk_size'] = disk['sizeMax']
|
||||
|
||||
@@ -1073,6 +1086,8 @@ class decort_vm(DecortController):
|
||||
|
||||
ret_dict['read_only'] = self.comp_info['read_only']
|
||||
|
||||
ret_dict['weight'] = self.comp_info['weight']
|
||||
|
||||
return ret_dict
|
||||
|
||||
def check_amodule_args_for_create(self):
|
||||
@@ -1199,7 +1214,7 @@ class decort_vm(DecortController):
|
||||
)
|
||||
elif (
|
||||
aparam_storage_policy_id
|
||||
not in self.rg_info['storage_policy_ids']
|
||||
not in self.rg_info.storage_policy_ids
|
||||
):
|
||||
check_errors = True
|
||||
self.message(
|
||||
@@ -1681,7 +1696,9 @@ class decort_vm(DecortController):
|
||||
if new_boot_disk_size is not None:
|
||||
boot_disk_size = 0
|
||||
for disk in self.comp_info['disks']:
|
||||
if disk['type'] == 'B':
|
||||
if self.is_vm_boot_disk(
|
||||
vm_chipset=self.comp_info['chipset'], vm_disk=disk,
|
||||
):
|
||||
boot_disk_size = disk['sizeMax']
|
||||
break
|
||||
else:
|
||||
@@ -1844,7 +1861,9 @@ class decort_vm(DecortController):
|
||||
aparam_disks_ids = [disk['id'] for disk in aparam_disks]
|
||||
comp_boot_disk_id = None
|
||||
for comp_disk in self.comp_info['disks']:
|
||||
if comp_disk['type'] == 'B':
|
||||
if self.is_vm_boot_disk(
|
||||
vm_chipset=self.comp_info['chipset'], vm_disk=comp_disk,
|
||||
):
|
||||
comp_boot_disk_id = comp_disk['id']
|
||||
break
|
||||
disks_to_detach = []
|
||||
@@ -2137,8 +2156,8 @@ class decort_vm(DecortController):
|
||||
vm_has_shared_sep_disk = False
|
||||
vm_disk_ids = [disk['id'] for disk in self.comp_info['disks']]
|
||||
for disk_id in vm_disk_ids:
|
||||
_, disk_info = self._disk_get_by_id(disk_id=disk_id)
|
||||
if disk_info['sepType'] == 'SHARED':
|
||||
disk_info = self._disk_get_by_id(disk_id=disk_id)
|
||||
if disk_info.sep_type == sdk_types.SEPType.SHARED:
|
||||
vm_has_shared_sep_disk = True
|
||||
break
|
||||
|
||||
@@ -2230,7 +2249,9 @@ class decort_vm(DecortController):
|
||||
if disk_redeploy:
|
||||
vm_has_boot_disk = False
|
||||
for disk in self.comp_info['disks']:
|
||||
if disk['type'] == 'B':
|
||||
if self.is_vm_boot_disk(
|
||||
vm_chipset=self.comp_info['chipset'], vm_disk=disk,
|
||||
):
|
||||
vm_has_boot_disk = True
|
||||
break
|
||||
if not vm_has_boot_disk:
|
||||
@@ -2341,7 +2362,9 @@ class decort_vm(DecortController):
|
||||
check_errors = False
|
||||
|
||||
# check if account has vm feature “trunk”
|
||||
if not self.check_account_vm_features(vm_feature=self.VMFeature.trunk):
|
||||
if not self.check_account_vm_features(
|
||||
vm_feature=sdk_types.VMFeature.TRUNK,
|
||||
):
|
||||
check_errors = True
|
||||
self.message(
|
||||
'Check for parameter "networks" failed: '
|
||||
@@ -2349,7 +2372,7 @@ class decort_vm(DecortController):
|
||||
'trunk type networks '
|
||||
)
|
||||
# check if rg has vm feature “trunk”
|
||||
if not self.check_rg_vm_features(vm_feature=self.VMFeature.trunk):
|
||||
if not self.check_rg_vm_features(vm_feature=sdk_types.VMFeature.TRUNK):
|
||||
check_errors = True
|
||||
self.message(
|
||||
'Check for parameter "networks" failed: '
|
||||
|
||||
Reference in New Issue
Block a user