mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -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
|
@ -326,7 +326,6 @@ network_offering:
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.cloudstack import (
|
||||
AnsibleCloudStack,
|
||||
CloudStackException,
|
||||
cs_argument_spec,
|
||||
cs_required_together,
|
||||
)
|
||||
|
@ -363,7 +362,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
|||
'zoneid': self.get_zone(key='id')
|
||||
}
|
||||
|
||||
network_offerings = self.cs.listNetworkOfferings(**args)
|
||||
network_offerings = self.query_api('listNetworkOfferings', **args)
|
||||
if network_offerings:
|
||||
for no in network_offerings['networkoffering']:
|
||||
if network_offering in [no['name'], no['displaytext'], no['id']]:
|
||||
|
@ -388,7 +387,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
|||
'account': self.get_account(key='name'),
|
||||
'domainid': self.get_domain(key='id')
|
||||
}
|
||||
networks = self.cs.listNetworks(**args)
|
||||
networks = self.query_api('listNetworks', **args)
|
||||
if networks:
|
||||
for n in networks['network']:
|
||||
if network in [n['name'], n['displaytext'], n['id']]:
|
||||
|
@ -411,10 +410,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
|||
if self.has_changed(args, network):
|
||||
self.result['changed'] = True
|
||||
if not self.module.check_mode:
|
||||
network = self.cs.updateNetwork(**args)
|
||||
|
||||
if 'errortext' in network:
|
||||
self.module.fail_json(msg="Failed: '%s'" % network['errortext'])
|
||||
network = self.query_api('updateNetwork', **args)
|
||||
|
||||
poll_async = self.module.params.get('poll_async')
|
||||
if network and poll_async:
|
||||
|
@ -446,10 +442,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
|||
})
|
||||
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.createNetwork(**args)
|
||||
|
||||
if 'errortext' in res:
|
||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||
res = self.query_api('createNetwork', **args)
|
||||
|
||||
network = res['network']
|
||||
return network
|
||||
|
@ -470,10 +463,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
|||
}
|
||||
|
||||
if not self.module.check_mode:
|
||||
network = self.cs.restartNetwork(**args)
|
||||
|
||||
if 'errortext' in network:
|
||||
self.module.fail_json(msg="Failed: '%s'" % network['errortext'])
|
||||
network = self.query_api('restartNetwork', **args)
|
||||
|
||||
poll_async = self.module.params.get('poll_async')
|
||||
if network and poll_async:
|
||||
|
@ -490,14 +480,11 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
|||
}
|
||||
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.deleteNetwork(**args)
|
||||
|
||||
if 'errortext' in res:
|
||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||
res = self.query_api('deleteNetwork', **args)
|
||||
|
||||
poll_async = self.module.params.get('poll_async')
|
||||
if res and poll_async:
|
||||
res = self.poll_job(res, 'network')
|
||||
self.poll_job(res, 'network')
|
||||
return network
|
||||
|
||||
|
||||
|
@ -539,24 +526,19 @@ def main():
|
|||
supports_check_mode=True
|
||||
)
|
||||
|
||||
try:
|
||||
acs_network = AnsibleCloudStackNetwork(module)
|
||||
acs_network = AnsibleCloudStackNetwork(module)
|
||||
|
||||
state = module.params.get('state')
|
||||
if state in ['absent']:
|
||||
network = acs_network.absent_network()
|
||||
state = module.params.get('state')
|
||||
if state in ['absent']:
|
||||
network = acs_network.absent_network()
|
||||
|
||||
elif state in ['restarted']:
|
||||
network = acs_network.restart_network()
|
||||
elif state in ['restarted']:
|
||||
network = acs_network.restart_network()
|
||||
|
||||
else:
|
||||
network = acs_network.present_network()
|
||||
|
||||
result = acs_network.get_result(network)
|
||||
|
||||
except CloudStackException as e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
else:
|
||||
network = acs_network.present_network()
|
||||
|
||||
result = acs_network.get_result(network)
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue