10.0.0
This commit is contained in:
@@ -97,26 +97,57 @@ class decort_rg(DecortController):
|
||||
self.amodule.params['rg_name'],
|
||||
self.validated_acc_id)
|
||||
return
|
||||
|
||||
|
||||
def update(self):
|
||||
resources = self.rg_facts['Resources']['Reserved']
|
||||
incorrect_quota = dict(Requested=dict(),
|
||||
Reserved=dict(),)
|
||||
query_key_map = dict(cpu='cpu',
|
||||
ram='ram',
|
||||
disk='disksize',
|
||||
ext_ips='extips',
|
||||
net_transfer='exttraffic',)
|
||||
query_key_map = dict(
|
||||
cpu='cpu',
|
||||
ram='ram',
|
||||
disk='disksize',
|
||||
ext_ips='extips',
|
||||
net_transfer='exttraffic',
|
||||
storage_policies='policies',
|
||||
)
|
||||
if self.amodule.params['quotas']:
|
||||
for quota_item in self.amodule.params['quotas']:
|
||||
if self.amodule.params['quotas'][quota_item] < resources[query_key_map[quota_item]]:
|
||||
incorrect_quota['Requested'][quota_item]=self.amodule.params['quotas'][quota_item]
|
||||
incorrect_quota['Reserved'][quota_item]=resources[query_key_map[quota_item]]
|
||||
if quota_item == 'storage_policies':
|
||||
rg_storage_policies = resources[query_key_map[quota_item]]
|
||||
aparam_storage_policies = self.amodule.params['quotas'][
|
||||
quota_item
|
||||
]
|
||||
for aparam_storage_policy in aparam_storage_policies:
|
||||
aparam_storage_policy_id = aparam_storage_policy['id']
|
||||
rg_storage_policy = rg_storage_policies.get(
|
||||
str(aparam_storage_policy_id)
|
||||
)
|
||||
if (
|
||||
rg_storage_policy
|
||||
and aparam_storage_policy['storage_size_gb']
|
||||
< rg_storage_policy['disksize']
|
||||
):
|
||||
incorrect_quota['Requested'][quota_item] = (
|
||||
self.amodule.params['quotas'][quota_item]
|
||||
)
|
||||
incorrect_quota['Reserved'][quota_item] = (
|
||||
resources[query_key_map[quota_item]]
|
||||
)
|
||||
elif (
|
||||
self.amodule.params['quotas'][quota_item]
|
||||
< resources[query_key_map[quota_item]]
|
||||
):
|
||||
incorrect_quota['Requested'][quota_item] = (
|
||||
self.amodule.params['quotas'][quota_item]
|
||||
)
|
||||
incorrect_quota['Reserved'][quota_item] = (
|
||||
resources[query_key_map[quota_item]]
|
||||
)
|
||||
|
||||
if incorrect_quota['Requested']:
|
||||
self.result['msg'] = ("Cannot limit less than already reserved'{}'").format(incorrect_quota)
|
||||
self.result['failed'] = True
|
||||
|
||||
|
||||
if not self.result['failed']:
|
||||
self.rg_update(
|
||||
arg_rg_dict=self.rg_facts,
|
||||
@@ -243,6 +274,7 @@ class decort_rg(DecortController):
|
||||
ret_dict['uniqPools'] = self.rg_facts['uniqPools']
|
||||
ret_dict['description'] = self.rg_facts['desc']
|
||||
ret_dict['sdn_access_group_id'] = self.rg_facts['sdn_access_group_id']
|
||||
ret_dict['storage_policy_ids'] = self.rg_facts['storage_policy_ids']
|
||||
|
||||
return ret_dict
|
||||
|
||||
|
||||
Reference in New Issue
Block a user