6.0.0
This commit is contained in:
@@ -240,7 +240,7 @@ facts:
|
||||
pool: datastore
|
||||
state: ASSIGNED
|
||||
account_id: 7
|
||||
attached_to: 18
|
||||
computes: {vm_id: vm_name}
|
||||
gid: 1001
|
||||
'''
|
||||
|
||||
@@ -257,39 +257,45 @@ class decort_disk(DecortController):
|
||||
|
||||
validated_acc_id = 0
|
||||
validated_acc_info = None
|
||||
validated_disk_id = 0
|
||||
self.disk_id = 0
|
||||
self.account_id = 0
|
||||
validated_disk_facts = None
|
||||
# limitIO check for exclusive parameters
|
||||
|
||||
if arg_amodule.params['limitIO']:
|
||||
self.disk_check_iotune_arg(arg_amodule.params['limitIO'])
|
||||
|
||||
|
||||
if arg_amodule.params['id'] or arg_amodule.params['name']:
|
||||
if arg_amodule.params['account_id'] or arg_amodule.params['account_name'] :
|
||||
validated_acc_id,validated_acc_info = self.account_find(arg_amodule.params['account_name'],arg_amodule.params['account_id'])
|
||||
if not validated_acc_id:
|
||||
self.result['failed'] = True
|
||||
self.result['changed'] = False
|
||||
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'],
|
||||
arg_amodule.params['account_name'])
|
||||
self.amodule.fail_json(**self.result)
|
||||
else:
|
||||
self.acc_id = validated_acc_id
|
||||
self.acc_info = validated_acc_info
|
||||
validated_disk_id,validated_disk_facts = self.disk_find(
|
||||
disk_id=arg_amodule.params['id'],
|
||||
name=arg_amodule.params['name'] if "name" in arg_amodule.params else "",
|
||||
account_id=self.acc_id,
|
||||
check_state=False,
|
||||
if not arg_amodule.params['id']:
|
||||
if (
|
||||
not arg_amodule.params['account_id']
|
||||
and not arg_amodule.params['account_name']
|
||||
):
|
||||
self.result['changed'] = False
|
||||
self.result['msg'] = (
|
||||
'Cannot manage Disk by name without specifying account ID '
|
||||
'or name.'
|
||||
)
|
||||
else:
|
||||
self.result['failed'] = True
|
||||
self.result['msg'] = ("Cannot manage Disk when its ID is 0 and name is empty")
|
||||
self.amodule.fail_json(**self.result)
|
||||
self.amodule.fail_json(**self.result)
|
||||
validated_acc_id, validated_acc_info = self.account_find(
|
||||
arg_amodule.params['account_name'],
|
||||
arg_amodule.params['account_id'])
|
||||
if not validated_acc_id:
|
||||
self.result['changed'] = False
|
||||
self.result['msg'] = (
|
||||
f"Current user does not have access to the account "
|
||||
f"ID {arg_amodule.params['account_id']} / "
|
||||
f"name '{arg_amodule.params['account_name']}' "
|
||||
f"or non-existent account specified."
|
||||
)
|
||||
self.amodule.fail_json(**self.result)
|
||||
|
||||
self.acc_id = validated_acc_id
|
||||
self.acc_info = validated_acc_info
|
||||
validated_disk_id, validated_disk_facts = self.disk_find(
|
||||
disk_id=arg_amodule.params['id'],
|
||||
name=arg_amodule.params['name'] if "name" in arg_amodule.params else "",
|
||||
account_id=self.acc_id,
|
||||
check_state=False,
|
||||
)
|
||||
|
||||
if arg_amodule.params['place_with']:
|
||||
image_id, image_facts = self.image_find(arg_amodule.params['place_with'], "", 0)
|
||||
@@ -324,12 +330,17 @@ class decort_disk(DecortController):
|
||||
if restore:
|
||||
self.disk_restore(self.disk_id)
|
||||
#rename if id present
|
||||
if self.amodule.params['name'] != self.disk_info['name']:
|
||||
if (
|
||||
self.amodule.params['name'] is not None
|
||||
and self.amodule.params['name'] != self.disk_info['name']
|
||||
):
|
||||
self.disk_rename(disk_id=self.disk_id,
|
||||
name=self.amodule.params['name'])
|
||||
self.disk_info['name'] = self.amodule.params['name']
|
||||
#resize
|
||||
if self.amodule.params['size'] != self.disk_info['sizeMax']:
|
||||
if (
|
||||
self.amodule.params['size'] is not None
|
||||
and self.amodule.params['size'] != self.disk_info['sizeMax']
|
||||
):
|
||||
self.disk_resize(self.disk_info,self.amodule.params['size'])
|
||||
#IO TUNE
|
||||
if self.amodule.params['limitIO']:
|
||||
@@ -381,7 +392,6 @@ class decort_disk(DecortController):
|
||||
account_id=0,
|
||||
sep_id=0,
|
||||
pool="none",
|
||||
attached_to=0,
|
||||
gid=0
|
||||
)
|
||||
|
||||
@@ -399,7 +409,7 @@ class decort_disk(DecortController):
|
||||
ret_dict['account_id'] = self.disk_info['accountId']
|
||||
ret_dict['sep_id'] = self.disk_info['sepId']
|
||||
ret_dict['pool'] = self.disk_info['pool']
|
||||
ret_dict['attached_to'] = self.disk_info['vmid']
|
||||
ret_dict['computes'] = self.disk_info['computes']
|
||||
ret_dict['gid'] = self.disk_info['gid']
|
||||
ret_dict['iotune'] = self.disk_info['iotune']
|
||||
|
||||
@@ -441,7 +451,7 @@ class decort_disk(DecortController):
|
||||
place_with=dict(type='int', default=0),
|
||||
pool=dict(type='str', default=''),
|
||||
sep_id=dict(type='int', default=0),
|
||||
size=dict(type='int', default=0),
|
||||
size=dict(type='int'),
|
||||
type=dict(type='str',
|
||||
required=False,
|
||||
default="D",
|
||||
@@ -490,6 +500,9 @@ def main():
|
||||
['app_id', 'app_secret'],
|
||||
['user', 'password'],
|
||||
],
|
||||
required_one_of=[
|
||||
['id', 'name'],
|
||||
],
|
||||
)
|
||||
|
||||
decon = decort_disk(amodule)
|
||||
|
||||
Reference in New Issue
Block a user