From 8a235e4e531bf29a3387416a0258e18ce243bd7c Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 9 Jun 2016 22:39:03 +0200 Subject: [PATCH] cloudstack: use poll_job() from utils --- cloud/cloudstack/cs_account.py | 4 ++-- cloud/cloudstack/cs_affinitygroup.py | 4 ++-- cloud/cloudstack/cs_domain.py | 2 +- cloud/cloudstack/cs_firewall.py | 4 ++-- cloud/cloudstack/cs_instance.py | 18 +++++++++--------- cloud/cloudstack/cs_ip_address.py | 4 ++-- cloud/cloudstack/cs_loadbalancer_rule.py | 2 +- cloud/cloudstack/cs_network.py | 6 +++--- cloud/cloudstack/cs_portforward.py | 6 +++--- cloud/cloudstack/cs_project.py | 8 ++++---- cloud/cloudstack/cs_router.py | 8 ++++---- cloud/cloudstack/cs_securitygroup_rule.py | 4 ++-- cloud/cloudstack/cs_staticnat.py | 4 ++-- cloud/cloudstack/cs_template.py | 6 +++--- cloud/cloudstack/cs_user.py | 2 +- cloud/cloudstack/cs_vmsnapshot.py | 6 +++--- 16 files changed, 44 insertions(+), 44 deletions(-) diff --git a/cloud/cloudstack/cs_account.py b/cloud/cloudstack/cs_account.py index e8cc2920f99..d4b27dea798 100644 --- a/cloud/cloudstack/cs_account.py +++ b/cloud/cloudstack/cs_account.py @@ -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): diff --git a/cloud/cloudstack/cs_affinitygroup.py b/cloud/cloudstack/cs_affinitygroup.py index ce18c767ce7..2ffe2bace14 100644 --- a/cloud/cloudstack/cs_affinitygroup.py +++ b/cloud/cloudstack/cs_affinitygroup.py @@ -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 diff --git a/cloud/cloudstack/cs_domain.py b/cloud/cloudstack/cs_domain.py index a9b3aa085b3..556abc6ffcc 100644 --- a/cloud/cloudstack/cs_domain.py +++ b/cloud/cloudstack/cs_domain.py @@ -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 diff --git a/cloud/cloudstack/cs_firewall.py b/cloud/cloudstack/cs_firewall.py index c782c93e3b4..1a677da4dfd 100644 --- a/cloud/cloudstack/cs_firewall.py +++ b/cloud/cloudstack/cs_firewall.py @@ -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 diff --git a/cloud/cloudstack/cs_instance.py b/cloud/cloudstack/cs_instance.py index 202796f0bc2..9e1a06d1c6f 100644 --- a/cloud/cloudstack/cs_instance.py +++ b/cloud/cloudstack/cs_instance.py @@ -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 diff --git a/cloud/cloudstack/cs_ip_address.py b/cloud/cloudstack/cs_ip_address.py index bb6344de0b6..4d4eae2f787 100644 --- a/cloud/cloudstack/cs_ip_address.py +++ b/cloud/cloudstack/cs_ip_address.py @@ -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 diff --git a/cloud/cloudstack/cs_loadbalancer_rule.py b/cloud/cloudstack/cs_loadbalancer_rule.py index cc8a029d3a4..83eb8883602 100644 --- a/cloud/cloudstack/cs_loadbalancer_rule.py +++ b/cloud/cloudstack/cs_loadbalancer_rule.py @@ -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 diff --git a/cloud/cloudstack/cs_network.py b/cloud/cloudstack/cs_network.py index ee8888ff8e8..2f4a2acaca0 100644 --- a/cloud/cloudstack/cs_network.py +++ b/cloud/cloudstack/cs_network.py @@ -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 diff --git a/cloud/cloudstack/cs_portforward.py b/cloud/cloudstack/cs_portforward.py index 79c57e5502b..8a818b78745 100644 --- a/cloud/cloudstack/cs_portforward.py +++ b/cloud/cloudstack/cs_portforward.py @@ -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 diff --git a/cloud/cloudstack/cs_project.py b/cloud/cloudstack/cs_project.py index f9b40b9ecd1..3635268e6ae 100644 --- a/cloud/cloudstack/cs_project.py +++ b/cloud/cloudstack/cs_project.py @@ -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 diff --git a/cloud/cloudstack/cs_router.py b/cloud/cloudstack/cs_router.py index 29ac096c15d..73575c80010 100644 --- a/cloud/cloudstack/cs_router.py +++ b/cloud/cloudstack/cs_router.py @@ -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 diff --git a/cloud/cloudstack/cs_securitygroup_rule.py b/cloud/cloudstack/cs_securitygroup_rule.py index eee4048ed2c..5ac22960b57 100644 --- a/cloud/cloudstack/cs_securitygroup_rule.py +++ b/cloud/cloudstack/cs_securitygroup_rule.py @@ -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 diff --git a/cloud/cloudstack/cs_staticnat.py b/cloud/cloudstack/cs_staticnat.py index bf3ed171564..cf8213a8813 100644 --- a/cloud/cloudstack/cs_staticnat.py +++ b/cloud/cloudstack/cs_staticnat.py @@ -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 diff --git a/cloud/cloudstack/cs_template.py b/cloud/cloudstack/cs_template.py index 01003e7b876..3db11755184 100644 --- a/cloud/cloudstack/cs_template.py +++ b/cloud/cloudstack/cs_template.py @@ -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 diff --git a/cloud/cloudstack/cs_user.py b/cloud/cloudstack/cs_user.py index cc233cba2cf..bee4653d163 100644 --- a/cloud/cloudstack/cs_user.py +++ b/cloud/cloudstack/cs_user.py @@ -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 diff --git a/cloud/cloudstack/cs_vmsnapshot.py b/cloud/cloudstack/cs_vmsnapshot.py index 9a00cc91a5c..29d19149935 100644 --- a/cloud/cloudstack/cs_vmsnapshot.py +++ b/cloud/cloudstack/cs_vmsnapshot.py @@ -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")