cloudstack: use poll_job() from utils

reviewable/pr18780/r1
Rene Moser 9 years ago
parent c693be53f5
commit 8a235e4e53

@ -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):

@ -184,7 +184,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):
@ -206,7 +206,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

@ -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

@ -331,7 +331,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
@ -355,7 +355,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

@ -666,7 +666,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
@ -715,7 +715,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
@ -742,7 +742,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
@ -775,7 +775,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
@ -798,7 +798,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
@ -819,7 +819,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
@ -840,7 +840,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
@ -858,7 +858,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()
@ -879,7 +879,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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -323,7 +323,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]
@ -354,7 +354,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

@ -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

@ -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

@ -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

@ -209,7 +209,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
@ -226,7 +226,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
@ -243,7 +243,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")

Loading…
Cancel
Save