From 2318009b709467b95c9eca576077cc636321d1e4 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Mon, 10 Aug 2015 15:51:20 +0200 Subject: [PATCH 1/4] cloudstack: cs_network fix zone not in result --- cloud/cloudstack/cs_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/cloudstack/cs_network.py b/cloud/cloudstack/cs_network.py index c4fd51b7a0b..2ae731064a6 100644 --- a/cloud/cloudstack/cs_network.py +++ b/cloud/cloudstack/cs_network.py @@ -533,7 +533,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack): self.result['type'] = network['type'] if 'traffictype' in network: self.result['traffic_type'] = network['traffictype'] - if 'zone' in network: + if 'zonename' in network: self.result['zone'] = network['zonename'] if 'domain' in network: self.result['domain'] = network['domain'] From aa14dedb8f60d506e284d30356a1179966a481d5 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Mon, 10 Aug 2015 15:52:03 +0200 Subject: [PATCH 2/4] cloudstack: sync cs_facts with best practices --- cloud/cloudstack/cs_facts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloud/cloudstack/cs_facts.py b/cloud/cloudstack/cs_facts.py index e2bebf8b116..11230b4c229 100644 --- a/cloud/cloudstack/cs_facts.py +++ b/cloud/cloudstack/cs_facts.py @@ -218,4 +218,5 @@ def main(): from ansible.module_utils.basic import * from ansible.module_utils.urls import * from ansible.module_utils.facts import * -main() +if __name__ == '__main__': + main() From 713cec442366aca784f94a606a1137776750b617 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Tue, 11 Aug 2015 16:10:49 +0200 Subject: [PATCH 3/4] cloudstack: cs_instance: use mutually_exlusive of AnsibleModule --- cloud/cloudstack/cs_instance.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud/cloudstack/cs_instance.py b/cloud/cloudstack/cs_instance.py index e71a465c9aa..a5ce8a8e5e7 100644 --- a/cloud/cloudstack/cs_instance.py +++ b/cloud/cloudstack/cs_instance.py @@ -385,9 +385,6 @@ class AnsibleCloudStackInstance(AnsibleCloudStack): if not template and not iso: self.module.fail_json(msg="Template or ISO is required.") - if template and iso: - self.module.fail_json(msg="Template are ISO are mutually exclusive.") - args = {} args['account'] = self.get_account(key='name') args['domainid'] = self.get_domain(key='id') @@ -815,6 +812,9 @@ def main(): api_http_method = dict(choices=['get', 'post'], default='get'), api_timeout = dict(type='int', default=10), ), + mutually_exclusive = ( + ['template', 'iso'], + ), required_together = ( ['api_key', 'api_secret', 'api_url'], ), From 9905034d3b4052619061c9c7e53ca0c1c137d0c6 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Tue, 11 Aug 2015 17:47:00 +0200 Subject: [PATCH 4/4] cloudstack: cs_ip_address: doc style fixes --- cloud/cloudstack/cs_ip_address.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cloud/cloudstack/cs_ip_address.py b/cloud/cloudstack/cs_ip_address.py index 1dc5a18835e..3e9c0f7bf26 100644 --- a/cloud/cloudstack/cs_ip_address.py +++ b/cloud/cloudstack/cs_ip_address.py @@ -21,7 +21,7 @@ DOCUMENTATION = ''' --- module: cs_ip_address -short_description: Manages Public/Secondary IP address associations +short_description: Manages public IP address associations on Apache CloudStack based clouds. description: - Acquires and associates a public IP to an account or project. Due to API limitations this is not an idempotent call, so be sure to only @@ -31,7 +31,8 @@ author: "Darren Worrall @dazworrall" options: ip_address: description: - - Public IP address. Required if C(state=absent) + - Public IP address. + - Required if C(state=absent) required: false default: null domain: @@ -69,7 +70,7 @@ extends_documentation_fragment: cloudstack ''' EXAMPLES = ''' -# Associate an IP address +# Associate an IP address conditonally - local_action: module: cs_ip_address network: My Network @@ -149,6 +150,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack): break self.module.fail_json(msg="Network '%s' not found" % network) + #TODO: Merge changes here with parent class def get_ip_address(self, key=None): if self.ip_address: @@ -169,6 +171,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack): self.ip_address = ip_addresses['publicipaddress'][0] return self._get_by_key(key, self.ip_address) + def associate_ip_address(self): self.result['changed'] = True args = {} @@ -189,6 +192,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack): ip_address = res return ip_address + def disassociate_ip_address(self): ip_address = self.get_ip_address() if ip_address is None: @@ -206,6 +210,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack): res = self._poll_job(res, 'ipaddress') return ip_address + def get_result(self, ip_address): if ip_address: if 'zonename' in ip_address: