Merge pull request #828 from resmo/for-ansible

cloudstack: fixes, docs, imrovements
reviewable/pr18780/r1
Brian Coca 9 years ago
commit 1e067a96ea

@ -218,4 +218,5 @@ def main():
from ansible.module_utils.basic import * from ansible.module_utils.basic import *
from ansible.module_utils.urls import * from ansible.module_utils.urls import *
from ansible.module_utils.facts import * from ansible.module_utils.facts import *
main() if __name__ == '__main__':
main()

@ -402,9 +402,6 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
if not template and not iso: if not template and not iso:
self.module.fail_json(msg="Template or ISO is required.") 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 = {}
args['account'] = self.get_account(key='name') args['account'] = self.get_account(key='name')
args['domainid'] = self.get_domain(key='id') args['domainid'] = self.get_domain(key='id')
@ -853,6 +850,9 @@ def main():
api_http_method = dict(choices=['get', 'post'], default='get'), api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10), api_timeout = dict(type='int', default=10),
), ),
mutually_exclusive = (
['template', 'iso'],
),
required_together = ( required_together = (
['api_key', 'api_secret', 'api_url'], ['api_key', 'api_secret', 'api_url'],
), ),

@ -21,7 +21,7 @@
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: cs_ip_address 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: description:
- Acquires and associates a public IP to an account or project. Due to API - 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 limitations this is not an idempotent call, so be sure to only
@ -31,7 +31,8 @@ author: "Darren Worrall @dazworrall"
options: options:
ip_address: ip_address:
description: description:
- Public IP address. Required if C(state=absent) - Public IP address.
- Required if C(state=absent)
required: false required: false
default: null default: null
domain: domain:
@ -69,7 +70,7 @@ extends_documentation_fragment: cloudstack
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Associate an IP address # Associate an IP address conditonally
- local_action: - local_action:
module: cs_ip_address module: cs_ip_address
network: My Network network: My Network
@ -149,6 +150,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
break break
self.module.fail_json(msg="Network '%s' not found" % network) self.module.fail_json(msg="Network '%s' not found" % network)
#TODO: Merge changes here with parent class #TODO: Merge changes here with parent class
def get_ip_address(self, key=None): def get_ip_address(self, key=None):
if self.ip_address: if self.ip_address:
@ -169,6 +171,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
self.ip_address = ip_addresses['publicipaddress'][0] self.ip_address = ip_addresses['publicipaddress'][0]
return self._get_by_key(key, self.ip_address) return self._get_by_key(key, self.ip_address)
def associate_ip_address(self): def associate_ip_address(self):
self.result['changed'] = True self.result['changed'] = True
args = {} args = {}
@ -189,6 +192,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
ip_address = res ip_address = res
return ip_address return ip_address
def disassociate_ip_address(self): def disassociate_ip_address(self):
ip_address = self.get_ip_address() ip_address = self.get_ip_address()
if ip_address is None: if ip_address is None:
@ -206,6 +210,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
res = self._poll_job(res, 'ipaddress') res = self._poll_job(res, 'ipaddress')
return ip_address return ip_address
def get_result(self, ip_address): def get_result(self, ip_address):
if ip_address: if ip_address:
if 'zonename' in ip_address: if 'zonename' in ip_address:

@ -533,7 +533,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
self.result['type'] = network['type'] self.result['type'] = network['type']
if 'traffictype' in network: if 'traffictype' in network:
self.result['traffic_type'] = network['traffictype'] self.result['traffic_type'] = network['traffictype']
if 'zone' in network: if 'zonename' in network:
self.result['zone'] = network['zonename'] self.result['zone'] = network['zonename']
if 'domain' in network: if 'domain' in network:
self.result['domain'] = network['domain'] self.result['domain'] = network['domain']

Loading…
Cancel
Save