mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -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
|
@ -135,7 +135,6 @@ domain:
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.cloudstack import (
|
||||
AnsibleCloudStack,
|
||||
CloudStackException,
|
||||
cs_argument_spec,
|
||||
cs_required_together,
|
||||
)
|
||||
|
@ -178,8 +177,6 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
|
|||
ip_address = None
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.associateIpAddress(**args)
|
||||
if 'errortext' in res:
|
||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||
|
||||
poll_async = self.module.params.get('poll_async')
|
||||
if poll_async:
|
||||
|
@ -196,8 +193,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
|
|||
self.result['changed'] = True
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.disassociateIpAddress(id=ip_address['id'])
|
||||
if 'errortext' in res:
|
||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||
|
||||
poll_async = self.module.params.get('poll_async')
|
||||
if poll_async:
|
||||
self.poll_job(res, 'ipaddress')
|
||||
|
@ -227,20 +223,15 @@ def main():
|
|||
supports_check_mode=True
|
||||
)
|
||||
|
||||
try:
|
||||
acs_ip_address = AnsibleCloudStackIPAddress(module)
|
||||
acs_ip_address = AnsibleCloudStackIPAddress(module)
|
||||
|
||||
state = module.params.get('state')
|
||||
if state in ['absent']:
|
||||
ip_address = acs_ip_address.disassociate_ip_address()
|
||||
else:
|
||||
ip_address = acs_ip_address.associate_ip_address()
|
||||
|
||||
result = acs_ip_address.get_result(ip_address)
|
||||
|
||||
except CloudStackException as e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
state = module.params.get('state')
|
||||
if state in ['absent']:
|
||||
ip_address = acs_ip_address.disassociate_ip_address()
|
||||
else:
|
||||
ip_address = acs_ip_address.associate_ip_address()
|
||||
|
||||
result = acs_ip_address.get_result(ip_address)
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue