11.0.0
This commit is contained in:
@@ -10,6 +10,8 @@ description: See L(Module Documentation,https://repository.basistech.ru/BASIS/de
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.decort_utils import DecortController
|
||||
|
||||
from dynamix_sdk import exceptions as sdk_exceptions
|
||||
|
||||
|
||||
class DecortStoragePolicy(DecortController):
|
||||
def __init__(self):
|
||||
@@ -28,18 +30,31 @@ class DecortStoragePolicy(DecortController):
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
@DecortController.handle_sdk_exceptions
|
||||
def run(self):
|
||||
self.get_info()
|
||||
self.exit()
|
||||
|
||||
def get_info(self):
|
||||
self.facts = self.storage_policy_get(id=self.id)
|
||||
self.facts['sep_pools'] = self.facts.pop('access_seps_pools')
|
||||
self.facts['iops_limit'] = self.facts.pop('limit_iops')
|
||||
self.facts['usage']['account_ids'] = self.facts['usage'].pop(
|
||||
'accounts'
|
||||
)
|
||||
self.facts['usage']['rg_ids'] = self.facts['usage'].pop('resgroups')
|
||||
try:
|
||||
storage_policy_model = self.api.cloudapi.storage_policy.get(
|
||||
id=self.id
|
||||
)
|
||||
except sdk_exceptions.RequestException as e:
|
||||
if (
|
||||
e.orig_exception.response
|
||||
and e.orig_exception.response.status_code == 404
|
||||
):
|
||||
self.message(
|
||||
self.MESSAGES.obj_not_found(
|
||||
obj='storage_policy',
|
||||
id=self.id,
|
||||
)
|
||||
)
|
||||
self.exit(fail=True)
|
||||
raise e
|
||||
|
||||
self.facts = storage_policy_model.model_dump()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user