1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

cloudstack: use poll_job() from utils

This commit is contained in:
Rene Moser 2016-06-09 22:39:03 +02:00 committed by Matt Clay
parent 03d3baa164
commit aca98e2f8e
16 changed files with 46 additions and 53 deletions

View file

@ -261,7 +261,7 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
account = self._poll_job(account, 'account')
account = self.poll_job(account, 'account')
return account
def present_account(self):
@ -311,7 +311,7 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
self._poll_job(res, 'account')
self.poll_job(res, 'account')
return account
def get_result(self, account):

View file

@ -163,7 +163,7 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
affinity_group = self._poll_job(res, 'affinitygroup')
affinity_group = self.poll_job(res, 'affinitygroup')
return affinity_group
def remove_affinity_group(self):
@ -185,7 +185,7 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
self._poll_job(res, 'affinitygroup')
self.poll_job(res, 'affinitygroup')
return affinity_group

View file

@ -227,7 +227,7 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'domain')
res = self.poll_job(res, 'domain')
return domain

View file

@ -324,7 +324,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
firewall_rule = self._poll_job(res, 'firewallrule')
firewall_rule = self.poll_job(res, 'firewallrule')
return firewall_rule
@ -348,7 +348,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'firewallrule')
res = self.poll_job(res, 'firewallrule')
return firewall_rule

View file

@ -667,7 +667,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
return instance
@ -716,7 +716,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
# Ensure VM has stopped
instance = self.stop_instance()
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
self.instance = instance
# Change service offering
@ -743,7 +743,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
if 'errortext' in instance:
self.module.fail_json(msg="Failed: '%s'" % instance['errortext'])
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
self.instance = instance
# Start VM again if it was running before
@ -776,7 +776,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(res, 'virtualmachine')
instance = self.poll_job(res, 'virtualmachine')
return instance
@ -799,7 +799,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'virtualmachine')
res = self.poll_job(res, 'virtualmachine')
return instance
@ -820,7 +820,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
return instance
@ -841,7 +841,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
return instance
@ -859,7 +859,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
elif instance['state'].lower() in [ 'stopping', 'stopped' ]:
instance = self.start_instance()
@ -875,16 +875,9 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
self.result['changed'] = True
args = {}
args['templateid'] = self.get_template_or_iso(key='id')
args['virtualmachineid'] = instance['id']
res = self.cs.restoreVirtualMachine(**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:
instance = self._poll_job(res, 'virtualmachine')
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self.poll_job(res, 'virtualmachine')
return instance

View file

@ -202,7 +202,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'ipaddress')
res = self.poll_job(res, 'ipaddress')
ip_address = res
return ip_address
@ -221,7 +221,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
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')
self.poll_job(res, 'ipaddress')
return ip_address

View file

@ -327,7 +327,7 @@ class AnsibleCloudStackLBRule(AnsibleCloudStack):
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'loadbalancer')
res = self.poll_job(res, 'loadbalancer')
return rule

View file

@ -432,7 +432,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if network and poll_async:
network = self._poll_job(network, 'network')
network = self.poll_job(network, 'network')
return network
@ -490,7 +490,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if network and poll_async:
network = self._poll_job(network, 'network')
network = self.poll_job(network, 'network')
return network
@ -510,7 +510,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'network')
res = self.poll_job(res, 'network')
return network

View file

@ -305,7 +305,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
portforwarding_rule = self.cs.createPortForwardingRule(**args)
poll_async = self.module.params.get('poll_async')
if poll_async:
portforwarding_rule = self._poll_job(portforwarding_rule, 'portforwardingrule')
portforwarding_rule = self.poll_job(portforwarding_rule, 'portforwardingrule')
return portforwarding_rule
@ -329,7 +329,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
portforwarding_rule = self.cs.createPortForwardingRule(**args)
poll_async = self.module.params.get('poll_async')
if poll_async:
portforwarding_rule = self._poll_job(portforwarding_rule, 'portforwardingrule')
portforwarding_rule = self.poll_job(portforwarding_rule, 'portforwardingrule')
return portforwarding_rule
@ -345,7 +345,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
res = self.cs.deletePortForwardingRule(**args)
poll_async = self.module.params.get('poll_async')
if poll_async:
self._poll_job(res, 'portforwardingrule')
self.poll_job(res, 'portforwardingrule')
return portforwarding_rule

View file

@ -193,7 +193,7 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if project and poll_async:
project = self._poll_job(project, 'project')
project = self.poll_job(project, 'project')
return project
@ -214,7 +214,7 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if project and poll_async:
project = self._poll_job(project, 'project')
project = self.poll_job(project, 'project')
return project
@ -238,7 +238,7 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if project and poll_async:
project = self._poll_job(project, 'project')
project = self.poll_job(project, 'project')
return project
@ -258,7 +258,7 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'project')
res = self.poll_job(res, 'project')
return project

View file

@ -227,7 +227,7 @@ class AnsibleCloudStackRouter(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
router = self._poll_job(res, 'router')
router = self.poll_job(res, 'router')
return router
def stop_router(self):
@ -248,7 +248,7 @@ class AnsibleCloudStackRouter(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
router = self._poll_job(res, 'router')
router = self.poll_job(res, 'router')
return router
def reboot_router(self):
@ -268,7 +268,7 @@ class AnsibleCloudStackRouter(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
router = self._poll_job(res, 'router')
router = self.poll_job(res, 'router')
return router
def absent_router(self):
@ -287,7 +287,7 @@ class AnsibleCloudStackRouter(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
self._poll_job(res, 'router')
self.poll_job(res, 'router')
return router

View file

@ -322,7 +322,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
security_group = self._poll_job(res, 'securitygroup')
security_group = self.poll_job(res, 'securitygroup')
key = sg_type + "rule" # ingressrule / egressrule
if key in security_group:
rule = security_group[key][0]
@ -353,7 +353,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'securitygroup')
res = self.poll_job(res, 'securitygroup')
return rule

View file

@ -223,7 +223,7 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
res = self.cs.disableStaticNat(ipaddressid=ip_address['id'])
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
self._poll_job(res, 'staticnat')
self.poll_job(res, 'staticnat')
res = self.cs.enableStaticNat(**args)
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
@ -253,7 +253,7 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
self._poll_job(res, 'staticnat')
self.poll_job(res, 'staticnat')
return ip_address

View file

@ -476,7 +476,7 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
template = self._poll_job(template, 'template')
template = self.poll_job(template, 'template')
return template
@ -564,7 +564,7 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
template = self._poll_job(template, 'template')
template = self.poll_job(template, 'template')
return template
@ -587,7 +587,7 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'template')
res = self.poll_job(res, 'template')
return template

View file

@ -297,7 +297,7 @@ class AnsibleCloudStackUser(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
user = self._poll_job(user, 'user')
user = self.poll_job(user, 'user')
return user

View file

@ -208,7 +208,7 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
snapshot = self._poll_job(res, 'vmsnapshot')
snapshot = self.poll_job(res, 'vmsnapshot')
return snapshot
@ -225,7 +225,7 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'vmsnapshot')
res = self.poll_job(res, 'vmsnapshot')
return snapshot
@ -242,7 +242,7 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'vmsnapshot')
res = self.poll_job(res, 'vmsnapshot')
return snapshot
self.module.fail_json(msg="snapshot not found, could not revert VM")