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

cloudstack: cs_ip_address: add vpc support (#2283)

* cloudstack: cs_ip_address: add vpc support

* cloudstack: cs_ip_address: remove unused/unreachable code
This commit is contained in:
René Moser 2016-05-27 21:02:29 +02:00 committed by Matt Clay
parent e9642a6de7
commit 4f09e2caab

View file

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
#
# (c) 2015, Darren Worrall <darren@iweb.co.uk>
# (c) 2015, René Moser <mail@renemoser.net>
#
# This file is part of Ansible
#
@ -27,7 +28,9 @@ description:
limitations this is not an idempotent call, so be sure to only
conditionally call this when C(state=present)
version_added: '2.0'
author: "Darren Worrall @dazworrall"
author:
- "Darren Worrall (@dazworrall)"
- "René Moser (@resmo)"
options:
ip_address:
description:
@ -45,6 +48,12 @@ options:
- Network the IP address is related to.
required: false
default: null
vpc:
description:
- VPC the IP address is related to.
required: false
default: null
version_added: "2.2"
account:
description:
- Account the IP address is related to.
@ -159,7 +168,6 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
for n in networks['network']:
if network in [ n['displaytext'], n['name'], n['id'] ]:
return self._get_by_key(key, n)
break
self.module.fail_json(msg="Network '%s' not found" % network)
@ -177,6 +185,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
args['account'] = self.get_account(key='name')
args['domainid'] = self.get_domain(key='id')
args['projectid'] = self.get_project(key='id')
args['vpcid'] = self.get_vpc(key='id')
ip_addresses = self.cs.listPublicIpAddresses(**args)
if ip_addresses:
@ -219,7 +228,7 @@ class AnsibleCloudStackIPAddress(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, 'ipaddress')
self._poll_job(res, 'ipaddress')
return ip_address
@ -228,10 +237,11 @@ def main():
argument_spec.update(dict(
ip_address = dict(required=False),
state = dict(choices=['present', 'absent'], default='present'),
vpc = dict(default=None),
network = dict(default=None),
zone = dict(default=None),
domain = dict(default=None),
account = dict(default=None),
network = dict(default=None),
project = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
))