10.0.0
This commit is contained in:
@@ -36,11 +36,15 @@ class decort_group(DecortController):
|
||||
group_id=arg_amodule.params['id'],
|
||||
group_name=arg_amodule.params['name'],
|
||||
)
|
||||
self.acc_id = self.bservice_info['accountId']
|
||||
self.rg_id = self.bservice_info['rgId']
|
||||
|
||||
if self.group_id:
|
||||
self.group_should_exist = True
|
||||
self.check_amodule_args_for_change()
|
||||
|
||||
else:
|
||||
self.check_amodule_args_for_create()
|
||||
|
||||
return
|
||||
def nop(self):
|
||||
"""No operation (NOP) handler for B-service.
|
||||
@@ -84,6 +88,17 @@ class decort_group(DecortController):
|
||||
warning=True,
|
||||
)
|
||||
|
||||
driver = self.aparams['driver']
|
||||
if driver is None:
|
||||
driver = 'KVM_X86'
|
||||
self.message(
|
||||
msg=self.MESSAGES.default_value_used(
|
||||
param_name='driver',
|
||||
default_value=driver,
|
||||
),
|
||||
warning=True,
|
||||
)
|
||||
|
||||
self.group_id=self.group_provision(
|
||||
bs_id=self.bservice_id,
|
||||
arg_name=self.amodule.params['name'],
|
||||
@@ -92,14 +107,18 @@ class decort_group(DecortController):
|
||||
arg_ram=self.amodule.params['ram'],
|
||||
arg_boot_disk=self.amodule.params['boot_disk'],
|
||||
arg_image_id=self.amodule.params['image_id'],
|
||||
arg_driver=self.amodule.params['driver'],
|
||||
arg_role=self.amodule.params['role'],
|
||||
arg_network=self.amodule.params['networks'],
|
||||
arg_timeout=self.amodule.params['timeoutStart'],
|
||||
arg_timeout=self.amodule.params['timeoutStart'],
|
||||
chipset=chipset,
|
||||
storage_policy_id=self.aparams['storage_policy_id'],
|
||||
driver=driver,
|
||||
)
|
||||
|
||||
if self.amodule.params['state'] in ('started','present'):
|
||||
|
||||
if (
|
||||
self.amodule.params['state'] in ('started','present')
|
||||
and self.amodule.params['timeoutStart'] is None
|
||||
):
|
||||
self.group_state(self.bservice_id,self.group_id,self.amodule.params['state'])
|
||||
|
||||
self.group_should_exist = True
|
||||
@@ -196,6 +215,7 @@ class decort_group(DecortController):
|
||||
ret_dict['techStatus'] = self.group_info['techStatus']
|
||||
ret_dict['state'] = self.group_info['status']
|
||||
ret_dict['Computes'] = self.group_info['computes']
|
||||
ret_dict['driver'] = self.group_info['driver']
|
||||
return ret_dict
|
||||
|
||||
@property
|
||||
@@ -229,17 +249,6 @@ class decort_group(DecortController):
|
||||
image_id=dict(
|
||||
type='int',
|
||||
),
|
||||
image_name=dict(
|
||||
type='str',
|
||||
),
|
||||
driver=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
'KVM_X86',
|
||||
'SVA_KVM_X86',
|
||||
],
|
||||
default='KVM_X86',
|
||||
),
|
||||
boot_disk=dict(
|
||||
type='int',
|
||||
),
|
||||
@@ -287,17 +296,16 @@ class decort_group(DecortController):
|
||||
'i440fx',
|
||||
]
|
||||
),
|
||||
storage_policy_id=dict(
|
||||
type='int',
|
||||
),
|
||||
driver=dict(
|
||||
type='str',
|
||||
),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
required_one_of=[
|
||||
('id', 'name'),
|
||||
('id', 'networks'),
|
||||
('id', 'count'),
|
||||
('id', 'cpu'),
|
||||
('id', 'ram'),
|
||||
('id', 'boot_disk'),
|
||||
('id', 'image_id'),
|
||||
('id', 'driver'),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -306,7 +314,7 @@ class decort_group(DecortController):
|
||||
|
||||
if (
|
||||
self.aparams['chipset'] is None
|
||||
and self.aparams['count'] > len(self.group_info['computes'])
|
||||
and (self.aparams['count'] if self.aparams['count'] is not None else 0) > len(self.group_info['computes'])
|
||||
):
|
||||
check_errors = True
|
||||
self.message(
|
||||
@@ -335,9 +343,71 @@ class decort_group(DecortController):
|
||||
)
|
||||
break
|
||||
|
||||
aparam_storage_policy_id = self.aparams['storage_policy_id']
|
||||
if aparam_storage_policy_id is not None:
|
||||
for compute in self.group_info['computes']:
|
||||
_, compute_info, _ = self._compute_get_by_id(compute['id'])
|
||||
for disk in compute_info['disks']:
|
||||
if aparam_storage_policy_id != disk['storage_policy_id']:
|
||||
check_errors = True
|
||||
self.message(
|
||||
msg='Check for parameter "storage_policy_id" '
|
||||
'failed: storage_policy_id can not be changed '
|
||||
f'for compute ID {compute['id']} '
|
||||
f'disk ID {disk['id']}'
|
||||
)
|
||||
|
||||
aparam_driver = self.aparams['driver']
|
||||
if (
|
||||
aparam_driver is not None
|
||||
and aparam_driver != self.group_info['driver']
|
||||
):
|
||||
check_errors = True
|
||||
self.message(
|
||||
msg='Check for parameter "driver" failed: '
|
||||
'driver can not be changed'
|
||||
)
|
||||
|
||||
if check_errors:
|
||||
self.exit(fail=True)
|
||||
|
||||
def check_amodule_args_for_create(self):
|
||||
check_errors = False
|
||||
|
||||
aparam_storage_policy_id = self.aparams['storage_policy_id']
|
||||
if aparam_storage_policy_id is None:
|
||||
check_errors = True
|
||||
self.message(
|
||||
msg='Check for parameter "storage_policy_id" failed: '
|
||||
'storage_policy_id must be specified when creating '
|
||||
'a new group'
|
||||
)
|
||||
else:
|
||||
if (
|
||||
aparam_storage_policy_id
|
||||
not in self.rg_info['storage_policy_ids']
|
||||
):
|
||||
check_errors = True
|
||||
self.message(
|
||||
msg='Check for parameter "storage_policy_id" failed: '
|
||||
f'RG ID {self.rg_id} does not have access to '
|
||||
f'storage_policy_id {aparam_storage_policy_id}'
|
||||
)
|
||||
if (
|
||||
aparam_storage_policy_id
|
||||
not in self.acc_info['storage_policy_ids']
|
||||
):
|
||||
check_errors = True
|
||||
self.message(
|
||||
msg='Check for parameter "storage_policy_id" failed: '
|
||||
f'Account ID {self.acc_id} does not have access to '
|
||||
f'storage_policy_id {aparam_storage_policy_id}'
|
||||
)
|
||||
|
||||
if check_errors:
|
||||
self.exit(fail=True)
|
||||
|
||||
|
||||
def main():
|
||||
subj = decort_group()
|
||||
amodule = subj.amodule
|
||||
@@ -359,8 +429,7 @@ def main():
|
||||
|
||||
if subj.group_id:
|
||||
if subj.group_info['status'] in ("DELETING","DESTROYNG","CREATING","DESTROYING",
|
||||
"ENABLING","DISABLING","RESTORING","MODELED",
|
||||
"DISABLED","DESTROYED"):
|
||||
"ENABLING","DISABLING","RESTORING","MODELED","DESTROYED"):
|
||||
subj.error()
|
||||
elif subj.group_info['status'] in ("DELETED","DESTROYED"):
|
||||
if amodule.params['state'] == 'absent':
|
||||
|
||||
Reference in New Issue
Block a user