mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
cloudstack: remove CloudStackException dep for several modules (#26874)
* cloudstack: cs_affinitygroup: remove CloudStackException dependency * cloudstack: cs_domain: remove CloudStackException dependency * cloudstack: cs_firewall: remove CloudStackException dependency * cloudstack: cs_host: remove CloudStackException dependency * cloudstack: cs_instancegroup: remove CloudStackException dependency * cloudstack: cs_pod: remove CloudStackException dependency * cloudstack: cs_configuration: remove CloudStackException dependency, fix pep8 * cloudstack: cs_cluster: remove CloudStackException dependency * cloudstack: cs_network_acl: remove CloudStackException dependency * cloudstack: cs_network_acl_rule: remove CloudStackException dependency * cloudstack: cs_zone_facts: remove CloudStackException dependency * cloudstack: cs_zone: remove CloudStackException dependency * cloudstack: cs_vpn_gateway: remove CloudStackException dependency * cloudstack: cs_vpc: remove CloudStackException dependency * cloudstack: cs_sshkeypair: remove CloudStackException dependency * cloudstack: cs_role: remove CloudStackException dependency * cloudstack: cs_ip_address: remove CloudStackException dependency * cloudstack: cs_ip_staticnat: remove CloudStackException dependency * cloudstack: cs_resourcelimit: remove CloudStackException dependency * cloudstack: cs_region: remove CloudStackException dependency * cloudstack: cs_project: remove CloudStackException dependency * cloudstack: cs_network: remove CloudStackException dependency * cloudstack: cs_loadbalancer_rule_member: remove CloudStackException dependency * cloudstack: cs_loadbalancer_rule: remove CloudStackException dependency * cloudstack: cs_iso: remove CloudStackException dependency
This commit is contained in:
parent
e228c7d021
commit
30ad30c470
26 changed files with 333 additions and 595 deletions
|
@ -114,7 +114,6 @@ network_domain:
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.cloudstack import (
|
||||
AnsibleCloudStack,
|
||||
CloudStackException,
|
||||
cs_argument_spec,
|
||||
cs_required_together
|
||||
)
|
||||
|
@ -149,7 +148,7 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
|
|||
'listall': True
|
||||
}
|
||||
|
||||
domains = self.cs.listDomains(**args)
|
||||
domains = self.query_api('listDomains', **args)
|
||||
if domains:
|
||||
for d in domains['domain']:
|
||||
if path == d['path'].lower():
|
||||
|
@ -194,9 +193,7 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
|
|||
'networkdomain': self.module.params.get('network_domain')
|
||||
}
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.createDomain(**args)
|
||||
if 'errortext' in res:
|
||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||
res = self.query_api('createDomain', **args)
|
||||
domain = res['domain']
|
||||
return domain
|
||||
|
||||
|
@ -208,9 +205,7 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
|
|||
if self.has_changed(args, domain):
|
||||
self.result['changed'] = True
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.updateDomain(**args)
|
||||
if 'errortext' in res:
|
||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||
res = self.query_api('updateDomain', **args)
|
||||
domain = res['domain']
|
||||
return domain
|
||||
|
||||
|
@ -224,10 +219,7 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
|
|||
'id': domain['id'],
|
||||
'cleanup': self.module.params.get('clean_up')
|
||||
}
|
||||
res = self.cs.deleteDomain(**args)
|
||||
|
||||
if 'errortext' in res:
|
||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||
res = self.query_api('deleteDomain', **args)
|
||||
|
||||
poll_async = self.module.params.get('poll_async')
|
||||
if poll_async:
|
||||
|
@ -251,19 +243,15 @@ def main():
|
|||
supports_check_mode=True
|
||||
)
|
||||
|
||||
try:
|
||||
acs_dom = AnsibleCloudStackDomain(module)
|
||||
acs_dom = AnsibleCloudStackDomain(module)
|
||||
|
||||
state = module.params.get('state')
|
||||
if state in ['absent']:
|
||||
domain = acs_dom.absent_domain()
|
||||
else:
|
||||
domain = acs_dom.present_domain()
|
||||
state = module.params.get('state')
|
||||
if state in ['absent']:
|
||||
domain = acs_dom.absent_domain()
|
||||
else:
|
||||
domain = acs_dom.present_domain()
|
||||
|
||||
result = acs_dom.get_result(domain)
|
||||
|
||||
except CloudStackException as e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
result = acs_dom.get_result(domain)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue