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