5.5.0
This commit is contained in:
@@ -18,52 +18,22 @@ description: See L(Module Documentation,https://repository.basistech.ru/BASIS/de
|
||||
# RETURN = r'''
|
||||
# '''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.decort_utils import DecortController
|
||||
|
||||
|
||||
class DecortAccountInfo(DecortController):
|
||||
def __init__(self):
|
||||
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'],
|
||||
audits=amodule.params['audits'],
|
||||
computes_args=self.mapped_computes_args,
|
||||
disks_args=self.mapped_disks_args,
|
||||
flip_groups_args=self.mapped_flip_groups_args,
|
||||
images_args=self.mapped_images_args,
|
||||
resource_consumption=amodule.params['resource_consumption'],
|
||||
resource_groups_args=self.mapped_rg_args,
|
||||
vinses_args=self.mapped_vinses_args,
|
||||
fail_if_not_found=True,
|
||||
)
|
||||
super().__init__(AnsibleModule(**self.amodule_init_args))
|
||||
|
||||
@property
|
||||
def amodule_init_args(self) -> dict:
|
||||
return dict(
|
||||
return self.pack_amodule_init_args(
|
||||
argument_spec=dict(
|
||||
app_id=dict(
|
||||
type='str',
|
||||
fallback=(env_fallback, ['DECORT_APP_ID'])
|
||||
),
|
||||
app_secret=dict(
|
||||
type='str',
|
||||
fallback=(env_fallback, ['DECORT_APP_SECRET']),
|
||||
no_log=True
|
||||
),
|
||||
audits=dict(
|
||||
type='bool',
|
||||
default=False
|
||||
),
|
||||
authenticator=dict(
|
||||
type='str',
|
||||
required=True,
|
||||
choices=['oauth2', 'jwt']
|
||||
),
|
||||
computes=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
@@ -127,10 +97,6 @@ class DecortAccountInfo(DecortController):
|
||||
),
|
||||
),
|
||||
),
|
||||
controller_url=dict(
|
||||
type='str',
|
||||
required=True
|
||||
),
|
||||
disks=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
@@ -278,18 +244,9 @@ class DecortAccountInfo(DecortController):
|
||||
),
|
||||
),
|
||||
),
|
||||
jwt=dict(
|
||||
type='str',
|
||||
fallback=(env_fallback, ['DECORT_JWT']),
|
||||
no_log=True
|
||||
),
|
||||
name=dict(
|
||||
type='str',
|
||||
),
|
||||
oauth2_url=dict(
|
||||
type='str',
|
||||
fallback=(env_fallback, ['DECORT_OAUTH2_URL'])
|
||||
),
|
||||
resource_groups=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
@@ -348,10 +305,6 @@ class DecortAccountInfo(DecortController):
|
||||
type='bool',
|
||||
default=False
|
||||
),
|
||||
verify_ssl=dict(
|
||||
type='bool',
|
||||
default=True
|
||||
),
|
||||
vinses=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
@@ -409,11 +362,6 @@ class DecortAccountInfo(DecortController):
|
||||
required_one_of=[
|
||||
('id', 'name')
|
||||
],
|
||||
required_if=[
|
||||
('authenticator', 'oauth2',
|
||||
('oauth2_url', 'app_id', 'app_secret')),
|
||||
('authenticator', 'jwt', ('jwt',))
|
||||
],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
@@ -426,7 +374,7 @@ class DecortAccountInfo(DecortController):
|
||||
(excluding for `account_id`).
|
||||
"""
|
||||
|
||||
input_args = self.amodule.params['computes']
|
||||
input_args = self.aparams['computes']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
@@ -464,7 +412,7 @@ class DecortAccountInfo(DecortController):
|
||||
(excluding for `account_id`).
|
||||
"""
|
||||
|
||||
input_args = self.amodule.params['disks']
|
||||
input_args = self.aparams['disks']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
@@ -496,7 +444,7 @@ class DecortAccountInfo(DecortController):
|
||||
(excluding for `account_id`).
|
||||
"""
|
||||
|
||||
input_args = self.amodule.params['flip_groups']
|
||||
input_args = self.aparams['flip_groups']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
@@ -525,7 +473,7 @@ class DecortAccountInfo(DecortController):
|
||||
(excluding for `account_id`).
|
||||
"""
|
||||
|
||||
input_args = self.amodule.params['images']
|
||||
input_args = self.aparams['images']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
@@ -557,7 +505,7 @@ class DecortAccountInfo(DecortController):
|
||||
(excluding for `account_id`).
|
||||
"""
|
||||
|
||||
input_args = self.amodule.params['resource_groups']
|
||||
input_args = self.aparams['resource_groups']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
@@ -595,7 +543,7 @@ class DecortAccountInfo(DecortController):
|
||||
(excluding for `account_id`).
|
||||
"""
|
||||
|
||||
input_args = self.amodule.params['vinses']
|
||||
input_args = self.aparams['vinses']
|
||||
if not input_args:
|
||||
return input_args
|
||||
|
||||
@@ -618,14 +566,28 @@ class DecortAccountInfo(DecortController):
|
||||
|
||||
return mapped_args
|
||||
|
||||
def exit(self):
|
||||
self.result['facts'] = self.facts
|
||||
self.amodule.exit_json(**self.result)
|
||||
def run(self):
|
||||
self.get_info()
|
||||
self.exit()
|
||||
|
||||
def get_info(self):
|
||||
self.id, self.facts = self.account_find(
|
||||
account_name=self.aparams['name'],
|
||||
account_id=self.aparams['id'],
|
||||
audits=self.aparams['audits'],
|
||||
computes_args=self.mapped_computes_args,
|
||||
disks_args=self.mapped_disks_args,
|
||||
flip_groups_args=self.mapped_flip_groups_args,
|
||||
images_args=self.mapped_images_args,
|
||||
resource_consumption=self.aparams['resource_consumption'],
|
||||
resource_groups_args=self.mapped_rg_args,
|
||||
vinses_args=self.mapped_vinses_args,
|
||||
fail_if_not_found=True,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
decort_account_info = DecortAccountInfo()
|
||||
decort_account_info.exit()
|
||||
DecortAccountInfo().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user