From 4f09e2caab00eafa88637021d3b898d75e051e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Fri, 27 May 2016 21:02:29 +0200 Subject: [PATCH] cloudstack: cs_ip_address: add vpc support (#2283) * cloudstack: cs_ip_address: add vpc support * cloudstack: cs_ip_address: remove unused/unreachable code --- .../extras/cloud/cloudstack/cs_ip_address.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py index a5932b42b3b..1aa0ac00457 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # # (c) 2015, Darren Worrall +# (c) 2015, René Moser # # 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), ))