10.0.0
This commit is contained in:
@@ -48,6 +48,9 @@ class DecortUserInfo(DecortController):
|
||||
e.value for e in self.AccountStatus
|
||||
],
|
||||
),
|
||||
zone_id=dict(
|
||||
type='int',
|
||||
),
|
||||
),
|
||||
),
|
||||
pagination=dict(
|
||||
@@ -303,6 +306,143 @@ class DecortUserInfo(DecortController):
|
||||
),
|
||||
),
|
||||
),
|
||||
storage_policies=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
filter=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
account_id=dict(
|
||||
type='int',
|
||||
),
|
||||
description=dict(
|
||||
type='str',
|
||||
),
|
||||
id=dict(
|
||||
type='int',
|
||||
),
|
||||
iops_limit=dict(
|
||||
type='int',
|
||||
),
|
||||
name=dict(
|
||||
type='str',
|
||||
),
|
||||
pool_name=dict(
|
||||
type='str',
|
||||
),
|
||||
rg_id=dict(
|
||||
type='int',
|
||||
),
|
||||
sep_id=dict(
|
||||
type='int',
|
||||
),
|
||||
status=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
e.value for e
|
||||
in self.StoragePolicyStatus
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
pagination=dict(
|
||||
type='dict',
|
||||
apply_defaults=True,
|
||||
options=dict(
|
||||
number=dict(
|
||||
type='int',
|
||||
default=1,
|
||||
),
|
||||
size=dict(
|
||||
type='int',
|
||||
default=50,
|
||||
),
|
||||
),
|
||||
),
|
||||
sorting=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
asc=dict(
|
||||
type='bool',
|
||||
default=True,
|
||||
),
|
||||
field=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
e.value for e
|
||||
in self.StoragePoliciesSortableField
|
||||
],
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
security_groups=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
filter=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
account_id=dict(
|
||||
type='int',
|
||||
),
|
||||
created_timestamp_max=dict(
|
||||
type='int',
|
||||
),
|
||||
created_timestamp_min=dict(
|
||||
type='int',
|
||||
),
|
||||
description=dict(
|
||||
type='str',
|
||||
),
|
||||
id=dict(
|
||||
type='int',
|
||||
),
|
||||
name=dict(
|
||||
type='str',
|
||||
),
|
||||
updated_timestamp_max=dict(
|
||||
type='int',
|
||||
),
|
||||
updated_timestamp_min=dict(
|
||||
type='int',
|
||||
),
|
||||
),
|
||||
),
|
||||
pagination=dict(
|
||||
type='dict',
|
||||
apply_defaults=True,
|
||||
options=dict(
|
||||
number=dict(
|
||||
type='int',
|
||||
default=1,
|
||||
),
|
||||
size=dict(
|
||||
type='int',
|
||||
default=50,
|
||||
),
|
||||
),
|
||||
),
|
||||
sorting=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
asc=dict(
|
||||
type='bool',
|
||||
default=True,
|
||||
),
|
||||
field=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
e.name for e
|
||||
in self.SecurityGroupSortableField
|
||||
],
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
@@ -390,6 +530,8 @@ class DecortUserInfo(DecortController):
|
||||
self.AccountStatus(input_args_filter_status)
|
||||
)
|
||||
|
||||
mapped_args['zone_id'] = input_args_filter['zone_id']
|
||||
|
||||
input_args_pagination = input_args['pagination']
|
||||
if input_args_pagination:
|
||||
mapped_args['page_number'] = input_args_pagination['number']
|
||||
@@ -552,6 +694,82 @@ class DecortUserInfo(DecortController):
|
||||
|
||||
return mapped_args
|
||||
|
||||
@property
|
||||
def mapped_storage_policies_args(self):
|
||||
"""
|
||||
Map the module argument `storage_policies` to
|
||||
arguments dictionary for the method
|
||||
`DecortController.user_storage_policies`.
|
||||
"""
|
||||
|
||||
input_args = self.aparams['storage_policies']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
mapped_args = {}
|
||||
|
||||
input_args_filter = input_args['filter']
|
||||
if input_args_filter:
|
||||
mapped_args.update(input_args_filter)
|
||||
|
||||
input_args_filter_status = input_args_filter['status']
|
||||
if input_args_filter_status:
|
||||
mapped_args['status'] = (
|
||||
self.StoragePolicyStatus(input_args_filter_status)
|
||||
)
|
||||
|
||||
input_args_pagination = input_args['pagination']
|
||||
if input_args_pagination:
|
||||
mapped_args['page_number'] = input_args_pagination['number']
|
||||
mapped_args['page_size'] = input_args_pagination['size']
|
||||
|
||||
input_args_sorting = input_args['sorting']
|
||||
if input_args_sorting:
|
||||
mapped_args['sort_by_asc'] = input_args_sorting['asc']
|
||||
|
||||
input_args_sorting_field = input_args_sorting['field']
|
||||
if input_args_sorting_field:
|
||||
mapped_args['sort_by_field'] = (
|
||||
self.StoragePoliciesSortableField(input_args_sorting_field)
|
||||
)
|
||||
|
||||
return mapped_args
|
||||
|
||||
@property
|
||||
def mapped_security_groups_args(self):
|
||||
"""
|
||||
Map the module argument `security_groups` to
|
||||
arguments dictionary for the method
|
||||
`DecortController.user_security_groups`.
|
||||
"""
|
||||
|
||||
input_args = self.aparams['security_groups']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
mapped_args = {}
|
||||
|
||||
input_args_filter = input_args['filter']
|
||||
if input_args_filter:
|
||||
mapped_args.update(input_args_filter)
|
||||
|
||||
input_args_pagination = input_args['pagination']
|
||||
if input_args_pagination:
|
||||
mapped_args['page_number'] = input_args_pagination['number']
|
||||
mapped_args['page_size'] = input_args_pagination['size']
|
||||
|
||||
input_args_sorting = input_args['sorting']
|
||||
if input_args_sorting:
|
||||
mapped_args['sort_by_asc'] = input_args_sorting['asc']
|
||||
|
||||
input_args_sorting_field = input_args_sorting['field']
|
||||
if input_args_sorting_field:
|
||||
mapped_args['sort_by_field'] = (
|
||||
self.SecurityGroupSortableField[input_args_sorting_field]
|
||||
)
|
||||
|
||||
return mapped_args
|
||||
|
||||
def run(self):
|
||||
self.get_info()
|
||||
self.exit()
|
||||
@@ -606,6 +824,52 @@ class DecortUserInfo(DecortController):
|
||||
trunk_facts['ovs_bridge'] = trunk_facts.pop('ovsBridge')
|
||||
trunk_facts['vlan_ids'] = trunk_facts.pop('trunkTags')
|
||||
|
||||
if self.aparams['storage_policies']:
|
||||
self.facts['storage_policies'] = self.user_storage_policies(
|
||||
**self.mapped_storage_policies_args
|
||||
)
|
||||
for storage_policy_facts in self.facts['storage_policies']:
|
||||
storage_policy_facts['sep_pools'] = storage_policy_facts.pop(
|
||||
'access_seps_pools'
|
||||
)
|
||||
storage_policy_facts['iops_limit'] = storage_policy_facts.pop(
|
||||
'limit_iops'
|
||||
)
|
||||
storage_policy_facts['usage']['account_ids'] = (
|
||||
storage_policy_facts['usage'].pop('accounts')
|
||||
)
|
||||
storage_policy_facts['usage']['rg_ids'] = (
|
||||
storage_policy_facts['usage'].pop('resgroups')
|
||||
)
|
||||
|
||||
if self.aparams['security_groups']:
|
||||
self.facts['security_groups'] = self.user_security_groups(
|
||||
**self.mapped_security_groups_args
|
||||
)
|
||||
for security_groups_facts in self.facts['security_groups']:
|
||||
for rule in security_groups_facts.get('rules', []):
|
||||
rule['port_range'] = {
|
||||
'min': rule.pop('port_range_min'),
|
||||
'max': rule.pop('port_range_max'),
|
||||
}
|
||||
|
||||
security_groups_facts['created_timestamp'] = (
|
||||
security_groups_facts.pop('created_at')
|
||||
)
|
||||
security_groups_facts['created_timestamp_readable'] = (
|
||||
self.sec_to_dt_str(security_groups_facts[
|
||||
'created_timestamp'
|
||||
])
|
||||
)
|
||||
security_groups_facts['updated_timestamp'] = (
|
||||
security_groups_facts.pop('updated_at')
|
||||
)
|
||||
security_groups_facts['updated_timestamp_readable'] = (
|
||||
self.sec_to_dt_str(security_groups_facts[
|
||||
'updated_timestamp'
|
||||
])
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
DecortUserInfo().run()
|
||||
|
||||
Reference in New Issue
Block a user