11.0.0
This commit is contained in:
@@ -8,871 +8,37 @@ 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
|
||||
|
||||
|
||||
class DecortUserInfo(DecortController):
|
||||
def __init__(self):
|
||||
super().__init__(AnsibleModule(**self.amodule_init_args))
|
||||
self.check_amodule_args()
|
||||
|
||||
@property
|
||||
def amodule_init_args(self) -> dict:
|
||||
return self.pack_amodule_init_args(
|
||||
argument_spec=dict(
|
||||
accounts=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
deleted=dict(
|
||||
type='bool',
|
||||
default=False,
|
||||
),
|
||||
filter=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
rights=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
e.value for e in self.AccountUserRights
|
||||
],
|
||||
),
|
||||
id=dict(
|
||||
type='int',
|
||||
),
|
||||
name=dict(
|
||||
type='str',
|
||||
),
|
||||
status=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
e.value for e in self.AccountStatus
|
||||
],
|
||||
),
|
||||
zone_id=dict(
|
||||
type='int',
|
||||
),
|
||||
),
|
||||
),
|
||||
pagination=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
number=dict(
|
||||
type='int',
|
||||
default=1,
|
||||
),
|
||||
size=dict(
|
||||
type='int',
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
resource_consumption=dict(
|
||||
type='bool',
|
||||
default=False,
|
||||
),
|
||||
sorting=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
asc=dict(
|
||||
type='bool',
|
||||
default=True,
|
||||
),
|
||||
field=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
e.value
|
||||
for e in self.AccountSortableField
|
||||
],
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
api_methods=dict(
|
||||
type='bool',
|
||||
default=False,
|
||||
),
|
||||
audits=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
filter=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
api_method=dict(
|
||||
type='str',
|
||||
),
|
||||
status_code=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
min=dict(
|
||||
type='int',
|
||||
),
|
||||
max=dict(
|
||||
type='int',
|
||||
),
|
||||
),
|
||||
),
|
||||
time=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
start=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
timestamp=dict(
|
||||
type='int',
|
||||
),
|
||||
datetime=dict(
|
||||
type='str',
|
||||
),
|
||||
),
|
||||
mutually_exclusive=[
|
||||
('timestamp', 'datetime'),
|
||||
],
|
||||
),
|
||||
end=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
timestamp=dict(
|
||||
type='int',
|
||||
),
|
||||
datetime=dict(
|
||||
type='str',
|
||||
),
|
||||
),
|
||||
mutually_exclusive=[
|
||||
('timestamp', 'datetime'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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.AuditsSortableField
|
||||
],
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
objects_search=dict(
|
||||
type='str',
|
||||
),
|
||||
resource_consumption=dict(
|
||||
type='bool',
|
||||
default=False,
|
||||
),
|
||||
zones=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
filter=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
deletable=dict(
|
||||
type='bool',
|
||||
),
|
||||
description=dict(
|
||||
type='str',
|
||||
),
|
||||
grid_id=dict(
|
||||
type='int',
|
||||
),
|
||||
id=dict(
|
||||
type='int',
|
||||
),
|
||||
name=dict(
|
||||
type='str',
|
||||
),
|
||||
node_id=dict(
|
||||
type='int',
|
||||
),
|
||||
status=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
e.value for e in self.ZoneStatus
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
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=self.ZoneField._member_names_,
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
trunks=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
filter=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
ids=dict(
|
||||
type='list',
|
||||
),
|
||||
account_ids=dict(
|
||||
type='list',
|
||||
),
|
||||
status=dict(
|
||||
type='str',
|
||||
choices=[
|
||||
e.value for e in self.TrunkStatus
|
||||
],
|
||||
),
|
||||
vlan_ids=dict(
|
||||
type='list',
|
||||
),
|
||||
),
|
||||
),
|
||||
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.TrunksSortableField
|
||||
],
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
)
|
||||
|
||||
def check_amodule_args(self):
|
||||
"""
|
||||
Additional validation of Ansible Module arguments.
|
||||
This validation cannot be implemented using
|
||||
Ansible Argument spec.
|
||||
"""
|
||||
|
||||
check_error = False
|
||||
|
||||
match self.aparams['audits']:
|
||||
case {
|
||||
'filter': {'time': {'start': {'datetime': str() as dt_str}}}
|
||||
}:
|
||||
if self.dt_str_to_sec(dt_str=dt_str) is None:
|
||||
self.message(self.MESSAGES.str_not_parsed(string=dt_str))
|
||||
check_error = True
|
||||
match self.aparams['audits']:
|
||||
case {
|
||||
'filter': {'time': {'end': {'datetime': str() as dt_str}}}
|
||||
}:
|
||||
if self.dt_str_to_sec(dt_str=dt_str) is None:
|
||||
self.message(self.MESSAGES.str_not_parsed(string=dt_str))
|
||||
check_error = True
|
||||
|
||||
aparam_trunks = self.aparams['trunks']
|
||||
if (
|
||||
aparam_trunks is not None
|
||||
and aparam_trunks['filter'] is not None
|
||||
and aparam_trunks['filter']['vlan_ids'] is not None
|
||||
):
|
||||
for vlan_id in aparam_trunks['filter']['vlan_ids']:
|
||||
if not (
|
||||
self.TRUNK_VLAN_ID_MIN_VALUE
|
||||
<= vlan_id
|
||||
<= self.TRUNK_VLAN_ID_MAX_VALUE
|
||||
):
|
||||
check_error = True
|
||||
self.message(
|
||||
'Check for parameter "trunks.filter.vlan_ids" failed: '
|
||||
f'VLAN ID {vlan_id} must be in range 1-4095.'
|
||||
)
|
||||
|
||||
if check_error:
|
||||
self.exit(fail=True)
|
||||
|
||||
@property
|
||||
def mapped_accounts_args(self) -> None | dict:
|
||||
"""
|
||||
Map the module argument `accounts` to
|
||||
arguments dictionary for the method
|
||||
`DecortController.user_accounts`.
|
||||
"""
|
||||
|
||||
input_args = self.aparams['accounts']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
mapped_args = {}
|
||||
|
||||
mapped_args['deleted'] = input_args['deleted']
|
||||
|
||||
mapped_args['resource_consumption'] = (
|
||||
input_args['resource_consumption']
|
||||
)
|
||||
|
||||
input_args_filter = input_args['filter']
|
||||
if input_args_filter:
|
||||
input_args_filter_rights = input_args_filter['rights']
|
||||
if input_args_filter_rights:
|
||||
mapped_args['account_user_rights'] = (
|
||||
self.AccountUserRights(input_args_filter_rights)
|
||||
)
|
||||
|
||||
mapped_args['account_id'] = input_args_filter['id']
|
||||
|
||||
mapped_args['account_name'] = input_args_filter['name']
|
||||
|
||||
input_args_filter_status = input_args_filter['status']
|
||||
if input_args_filter_status:
|
||||
mapped_args['account_status'] = (
|
||||
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']
|
||||
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.AccountSortableField(input_args_sorting_field)
|
||||
)
|
||||
|
||||
return mapped_args
|
||||
|
||||
@property
|
||||
def mapped_audits_args(self):
|
||||
"""
|
||||
Map the module argument `audits` to
|
||||
arguments dictionary for the method
|
||||
`DecortController.user_audits`.
|
||||
"""
|
||||
|
||||
input_args = self.aparams['audits']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
mapped_args = {}
|
||||
|
||||
input_args_filter = input_args['filter']
|
||||
if input_args_filter:
|
||||
mapped_args['api_method'] = input_args_filter['api_method']
|
||||
|
||||
match input_args_filter['status_code']:
|
||||
case {'min': int() as min_status_code}:
|
||||
mapped_args['min_status_code'] = min_status_code
|
||||
match input_args_filter['status_code']:
|
||||
case {'max': int() as max_status_code}:
|
||||
mapped_args['max_status_code'] = max_status_code
|
||||
|
||||
match input_args_filter['time']:
|
||||
case {'start': {'timestamp': int() as start_unix_time}}:
|
||||
mapped_args['start_unix_time'] = start_unix_time
|
||||
case {'start': {'datetime': str() as start_dt_str}}:
|
||||
mapped_args['start_unix_time'] = self.dt_str_to_sec(
|
||||
dt_str=start_dt_str
|
||||
)
|
||||
match input_args_filter['time']:
|
||||
case {'end': {'timestamp': int() as end_unix_time}}:
|
||||
mapped_args['end_unix_time'] = end_unix_time
|
||||
case {'end': {'datetime': str() as end_dt_str}}:
|
||||
mapped_args['end_unix_time'] = self.dt_str_to_sec(
|
||||
dt_str=end_dt_str
|
||||
)
|
||||
|
||||
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.AuditsSortableField(input_args_sorting_field)
|
||||
)
|
||||
|
||||
return mapped_args
|
||||
|
||||
@property
|
||||
def mapped_zones_args(self):
|
||||
"""
|
||||
Map the module argument `zones` to
|
||||
arguments dictionary for the method
|
||||
`DecortController.user_zones`.
|
||||
"""
|
||||
|
||||
input_args = self.aparams['zones']
|
||||
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.ZoneStatus(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.ZoneField._member_map_[input_args_sorting_field]
|
||||
)
|
||||
|
||||
return mapped_args
|
||||
|
||||
@property
|
||||
def mapped_trunks_args(self):
|
||||
"""
|
||||
Map the module argument `trunks` to
|
||||
arguments dictionary for the method
|
||||
`DecortController.user_trunks`.
|
||||
"""
|
||||
|
||||
input_args = self.aparams['trunks']
|
||||
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.TrunkStatus(input_args_filter_status)
|
||||
)
|
||||
|
||||
input_args_filter_vlan_ids = input_args_filter['vlan_ids']
|
||||
if input_args_filter_vlan_ids is not None:
|
||||
mapped_args['vlan_ids'] = ', '.join(
|
||||
map(str, input_args_filter_vlan_ids)
|
||||
)
|
||||
|
||||
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.TrunksSortableField(input_args_sorting_field)
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
def get_info(self):
|
||||
self.facts = self.user_whoami()
|
||||
self.id = self.facts['name']
|
||||
|
||||
user_get = self.user_get(id=self.id)
|
||||
for key in ['emailaddresses', 'data']:
|
||||
self.facts[key] = user_get[key]
|
||||
|
||||
if self.aparams['accounts']:
|
||||
self.facts['accounts'] = self.user_accounts(
|
||||
**self.mapped_accounts_args,
|
||||
)
|
||||
|
||||
if self.aparams['resource_consumption']:
|
||||
self.facts.update(self.user_resource_consumption())
|
||||
|
||||
if self.aparams['audits']:
|
||||
self.facts['audits'] = self.user_audits(**self.mapped_audits_args)
|
||||
|
||||
if self.aparams['api_methods']:
|
||||
self.facts['api_methods'] = self.user_api_methods(id=self.id)
|
||||
|
||||
search_string = self.aparams['objects_search']
|
||||
if search_string:
|
||||
self.facts['objects_search'] = self.user_objects_search(
|
||||
search_string=search_string,
|
||||
)
|
||||
|
||||
if self.aparams['zones']:
|
||||
self.facts['zones'] = self.user_zones(**self.mapped_zones_args)
|
||||
|
||||
if self.aparams['trunks']:
|
||||
self.facts['trunks'] = self.user_trunks(**self.mapped_trunks_args)
|
||||
for trunk_facts in self.facts['trunks']:
|
||||
trunk_facts['account_ids'] = trunk_facts.pop('accountIds')
|
||||
trunk_facts['created_timestamp'] = trunk_facts.pop(
|
||||
'created_at'
|
||||
)
|
||||
trunk_facts['deleted_timestamp'] = trunk_facts.pop(
|
||||
'deleted_at'
|
||||
)
|
||||
trunk_facts['updated_timestamp'] = trunk_facts.pop(
|
||||
'updated_at'
|
||||
)
|
||||
trunk_facts['native_vlan_id'] = trunk_facts.pop(
|
||||
'nativeVlanId'
|
||||
)
|
||||
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()
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
app_id=dict(type='raw'),
|
||||
app_secret=dict(type='raw'),
|
||||
authenticator=dict(type='raw'),
|
||||
controller_url=dict(type='raw'),
|
||||
domain=dict(type='raw'),
|
||||
jwt=dict(type='raw'),
|
||||
oauth2_url=dict(type='raw'),
|
||||
password=dict(type='raw'),
|
||||
username=dict(type='raw'),
|
||||
verify_ssl=dict(type='raw'),
|
||||
ignore_api_compatibility=dict(type='raw'),
|
||||
ignore_sdk_version_check=dict(type='raw'),
|
||||
api_methods=dict(type='raw'),
|
||||
objects_search=dict(type='raw'),
|
||||
resource_consumption=dict(type='raw'),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module.fail_json(
|
||||
msg=(
|
||||
'The module "decort_user_info" has been renamed to "decort_user". '
|
||||
'Please update your playbook to use "decort_user" '
|
||||
'instead of "decort_user_info".'
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user