|
|
|
@ -24,22 +24,22 @@ from ansible.module_utils.decort_utils import DecortController
|
|
|
|
|
|
|
|
|
|
class DecortAccountInfo(DecortController):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
amodule = AnsibleModule(**self.module_args, supports_check_mode=True)
|
|
|
|
|
amodule = AnsibleModule(**self.amodule_init_args)
|
|
|
|
|
|
|
|
|
|
super().__init__(amodule)
|
|
|
|
|
|
|
|
|
|
self.id, self.facts = self.account_find(
|
|
|
|
|
account_name=amodule.params['name'],
|
|
|
|
|
account_id=amodule.params['id'],
|
|
|
|
|
computes_params=self.mapped_computes_params,
|
|
|
|
|
computes_args=self.mapped_computes_args,
|
|
|
|
|
resource_consumption=amodule.params['resource_consumption'],
|
|
|
|
|
resource_groups_params=self.mapped_rg_params,
|
|
|
|
|
vinses_params=self.mapped_vinses_params,
|
|
|
|
|
resource_groups_args=self.mapped_rg_args,
|
|
|
|
|
vinses_args=self.mapped_vinses_args,
|
|
|
|
|
fail_if_not_found=True
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def module_args(self) -> dict:
|
|
|
|
|
def amodule_init_args(self) -> dict:
|
|
|
|
|
return dict(
|
|
|
|
|
argument_spec=dict(
|
|
|
|
|
app_id=dict(
|
|
|
|
@ -261,116 +261,117 @@ class DecortAccountInfo(DecortController):
|
|
|
|
|
('authenticator', 'oauth2',
|
|
|
|
|
('oauth2_url', 'app_id', 'app_secret')),
|
|
|
|
|
('authenticator', 'jwt', ('jwt',))
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
supports_check_mode=True,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def mapped_computes_params(self) -> None | dict:
|
|
|
|
|
def mapped_computes_args(self) -> None | dict:
|
|
|
|
|
"""
|
|
|
|
|
Map the module parameter `computes` to
|
|
|
|
|
parameters dictionary for the method
|
|
|
|
|
Map the module argument `computes` to
|
|
|
|
|
arguments dictionary for the method
|
|
|
|
|
`DecortController.account_computes`
|
|
|
|
|
(excluding for `account_id`).
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
input_params = self.amodule.params['computes']
|
|
|
|
|
if not input_params:
|
|
|
|
|
return input_params
|
|
|
|
|
input_args = self.amodule.params['computes']
|
|
|
|
|
if not input_args:
|
|
|
|
|
return input_args
|
|
|
|
|
|
|
|
|
|
mapped_params = {}
|
|
|
|
|
if input_params['filter']:
|
|
|
|
|
mapped_params['compute_id'] = input_params['filter']['id']
|
|
|
|
|
mapped_params['compute_ip'] = input_params['filter']['ip']
|
|
|
|
|
mapped_params['compute_name'] = input_params['filter']['name']
|
|
|
|
|
mapped_params['compute_tech_status'] =\
|
|
|
|
|
input_params['filter']['tech_status']
|
|
|
|
|
mapped_params['ext_net_id'] = input_params['filter']['ext_net_id']
|
|
|
|
|
mapped_params['ext_net_name'] =\
|
|
|
|
|
input_params['filter']['ext_net_name']
|
|
|
|
|
mapped_params['rg_id'] = input_params['filter']['rg_id']
|
|
|
|
|
mapped_params['rg_name'] = input_params['filter']['rg_name']
|
|
|
|
|
if input_params['pagination']:
|
|
|
|
|
mapped_params['page_number'] =\
|
|
|
|
|
input_params['pagination']['number']
|
|
|
|
|
mapped_params['page_size'] =\
|
|
|
|
|
input_params['pagination']['size']
|
|
|
|
|
if input_params['sorting']:
|
|
|
|
|
mapped_params['sort_by_asc'] =\
|
|
|
|
|
input_params['sorting']['asc']
|
|
|
|
|
mapped_params['sort_by_field'] =\
|
|
|
|
|
input_params['sorting']['field']
|
|
|
|
|
mapped_args = {}
|
|
|
|
|
if input_args['filter']:
|
|
|
|
|
mapped_args['compute_id'] = input_args['filter']['id']
|
|
|
|
|
mapped_args['compute_ip'] = input_args['filter']['ip']
|
|
|
|
|
mapped_args['compute_name'] = input_args['filter']['name']
|
|
|
|
|
mapped_args['compute_tech_status'] =\
|
|
|
|
|
input_args['filter']['tech_status']
|
|
|
|
|
mapped_args['ext_net_id'] = input_args['filter']['ext_net_id']
|
|
|
|
|
mapped_args['ext_net_name'] =\
|
|
|
|
|
input_args['filter']['ext_net_name']
|
|
|
|
|
mapped_args['rg_id'] = input_args['filter']['rg_id']
|
|
|
|
|
mapped_args['rg_name'] = input_args['filter']['rg_name']
|
|
|
|
|
if input_args['pagination']:
|
|
|
|
|
mapped_args['page_number'] =\
|
|
|
|
|
input_args['pagination']['number']
|
|
|
|
|
mapped_args['page_size'] =\
|
|
|
|
|
input_args['pagination']['size']
|
|
|
|
|
if input_args['sorting']:
|
|
|
|
|
mapped_args['sort_by_asc'] =\
|
|
|
|
|
input_args['sorting']['asc']
|
|
|
|
|
mapped_args['sort_by_field'] =\
|
|
|
|
|
input_args['sorting']['field']
|
|
|
|
|
|
|
|
|
|
return mapped_params
|
|
|
|
|
return mapped_args
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def mapped_rg_params(self) -> None | dict:
|
|
|
|
|
def mapped_rg_args(self) -> None | dict:
|
|
|
|
|
"""
|
|
|
|
|
Map the module parameter `resource_groups` to
|
|
|
|
|
parameters dictionary for the method
|
|
|
|
|
Map the module argument `resource_groups` to
|
|
|
|
|
arguments dictionary for the method
|
|
|
|
|
`DecortController.account_resource_groups`
|
|
|
|
|
(excluding for `account_id`).
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
input_params = self.amodule.params['resource_groups']
|
|
|
|
|
if not input_params:
|
|
|
|
|
return input_params
|
|
|
|
|
input_args = self.amodule.params['resource_groups']
|
|
|
|
|
if not input_args:
|
|
|
|
|
return input_args
|
|
|
|
|
|
|
|
|
|
mapped_params = {}
|
|
|
|
|
if input_params['filter']:
|
|
|
|
|
mapped_params['rg_id'] =\
|
|
|
|
|
input_params['filter']['id']
|
|
|
|
|
mapped_params['rg_name'] =\
|
|
|
|
|
input_params['filter']['name']
|
|
|
|
|
mapped_params['rg_status'] =\
|
|
|
|
|
input_params['filter']['status']
|
|
|
|
|
mapped_params['vins_id'] =\
|
|
|
|
|
input_params['filter']['vins_id']
|
|
|
|
|
mapped_params['vm_id'] =\
|
|
|
|
|
input_params['filter']['vm_id']
|
|
|
|
|
if input_params['pagination']:
|
|
|
|
|
mapped_params['page_number'] =\
|
|
|
|
|
input_params['pagination']['number']
|
|
|
|
|
mapped_params['page_size'] =\
|
|
|
|
|
input_params['pagination']['size']
|
|
|
|
|
if input_params['sorting']:
|
|
|
|
|
mapped_params['sort_by_asc'] =\
|
|
|
|
|
input_params['sorting']['asc']
|
|
|
|
|
mapped_params['sort_by_field'] =\
|
|
|
|
|
input_params['sorting']['field']
|
|
|
|
|
mapped_args = {}
|
|
|
|
|
if input_args['filter']:
|
|
|
|
|
mapped_args['rg_id'] =\
|
|
|
|
|
input_args['filter']['id']
|
|
|
|
|
mapped_args['rg_name'] =\
|
|
|
|
|
input_args['filter']['name']
|
|
|
|
|
mapped_args['rg_status'] =\
|
|
|
|
|
input_args['filter']['status']
|
|
|
|
|
mapped_args['vins_id'] =\
|
|
|
|
|
input_args['filter']['vins_id']
|
|
|
|
|
mapped_args['vm_id'] =\
|
|
|
|
|
input_args['filter']['vm_id']
|
|
|
|
|
if input_args['pagination']:
|
|
|
|
|
mapped_args['page_number'] =\
|
|
|
|
|
input_args['pagination']['number']
|
|
|
|
|
mapped_args['page_size'] =\
|
|
|
|
|
input_args['pagination']['size']
|
|
|
|
|
if input_args['sorting']:
|
|
|
|
|
mapped_args['sort_by_asc'] =\
|
|
|
|
|
input_args['sorting']['asc']
|
|
|
|
|
mapped_args['sort_by_field'] =\
|
|
|
|
|
input_args['sorting']['field']
|
|
|
|
|
|
|
|
|
|
return mapped_params
|
|
|
|
|
return mapped_args
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def mapped_vinses_params(self) -> None | dict:
|
|
|
|
|
def mapped_vinses_args(self) -> None | dict:
|
|
|
|
|
"""
|
|
|
|
|
Map the module parameter `vinses` to
|
|
|
|
|
parameters dictionary for the method
|
|
|
|
|
Map the module argument `vinses` to
|
|
|
|
|
arguments dictionary for the method
|
|
|
|
|
`DecortController.account_vinses`
|
|
|
|
|
(excluding for `account_id`).
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
input_params = self.amodule.params['vinses']
|
|
|
|
|
if not input_params:
|
|
|
|
|
return input_params
|
|
|
|
|
input_args = self.amodule.params['vinses']
|
|
|
|
|
if not input_args:
|
|
|
|
|
return input_args
|
|
|
|
|
|
|
|
|
|
mapped_params = {}
|
|
|
|
|
if input_params['filter']:
|
|
|
|
|
mapped_params['vins_id'] = input_params['filter']['id']
|
|
|
|
|
mapped_params['vins_name'] = input_params['filter']['name']
|
|
|
|
|
mapped_params['ext_ip'] = input_params['filter']['ext_ip']
|
|
|
|
|
mapped_params['rg_id'] = input_params['filter']['rg_id']
|
|
|
|
|
if input_params['pagination']:
|
|
|
|
|
mapped_params['page_number'] =\
|
|
|
|
|
input_params['pagination']['number']
|
|
|
|
|
mapped_params['page_size'] =\
|
|
|
|
|
input_params['pagination']['size']
|
|
|
|
|
if input_params['sorting']:
|
|
|
|
|
mapped_params['sort_by_asc'] =\
|
|
|
|
|
input_params['sorting']['asc']
|
|
|
|
|
mapped_params['sort_by_field'] =\
|
|
|
|
|
input_params['sorting']['field']
|
|
|
|
|
mapped_args = {}
|
|
|
|
|
if input_args['filter']:
|
|
|
|
|
mapped_args['vins_id'] = input_args['filter']['id']
|
|
|
|
|
mapped_args['vins_name'] = input_args['filter']['name']
|
|
|
|
|
mapped_args['ext_ip'] = input_args['filter']['ext_ip']
|
|
|
|
|
mapped_args['rg_id'] = input_args['filter']['rg_id']
|
|
|
|
|
if input_args['pagination']:
|
|
|
|
|
mapped_args['page_number'] =\
|
|
|
|
|
input_args['pagination']['number']
|
|
|
|
|
mapped_args['page_size'] =\
|
|
|
|
|
input_args['pagination']['size']
|
|
|
|
|
if input_args['sorting']:
|
|
|
|
|
mapped_args['sort_by_asc'] =\
|
|
|
|
|
input_args['sorting']['asc']
|
|
|
|
|
mapped_args['sort_by_field'] =\
|
|
|
|
|
input_args['sorting']['field']
|
|
|
|
|
|
|
|
|
|
return mapped_params
|
|
|
|
|
return mapped_args
|
|
|
|
|
|
|
|
|
|
def exit(self):
|
|
|
|
|
self.result['facts'] = self.facts
|
|
|
|
|