mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudstack: cs_staticnat: add vpc support (#2285)
* cloudstack: cs_staticnat: add network arg, used for VPC support * cloudstack: cs_staticnat: removed unused code
This commit is contained in:
parent
28648f6434
commit
e9642a6de7
1 changed files with 10 additions and 3 deletions
|
@ -42,6 +42,12 @@ options:
|
||||||
- VM guest NIC secondary IP address for the static NAT.
|
- VM guest NIC secondary IP address for the static NAT.
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
|
network:
|
||||||
|
description:
|
||||||
|
- Network the IP address is related to.
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
|
version_added: "2.2"
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- State of the static NAT.
|
- State of the static NAT.
|
||||||
|
@ -198,6 +204,7 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
|
||||||
args['virtualmachineid'] = self.get_vm(key='id')
|
args['virtualmachineid'] = self.get_vm(key='id')
|
||||||
args['ipaddressid'] = ip_address['id']
|
args['ipaddressid'] = ip_address['id']
|
||||||
args['vmguestip'] = self.get_vm_guest_ip()
|
args['vmguestip'] = self.get_vm_guest_ip()
|
||||||
|
args['networkid'] = self.get_network(key='id')
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.cs.enableStaticNat(**args)
|
res = self.cs.enableStaticNat(**args)
|
||||||
if 'errortext' in res:
|
if 'errortext' in res:
|
||||||
|
@ -223,7 +230,7 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
|
||||||
res = self.cs.disableStaticNat(ipaddressid=ip_address['id'])
|
res = self.cs.disableStaticNat(ipaddressid=ip_address['id'])
|
||||||
if 'errortext' in res:
|
if 'errortext' in res:
|
||||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||||
res = self._poll_job(res, 'staticnat')
|
self._poll_job(res, 'staticnat')
|
||||||
res = self.cs.enableStaticNat(**args)
|
res = self.cs.enableStaticNat(**args)
|
||||||
if 'errortext' in res:
|
if 'errortext' in res:
|
||||||
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
|
||||||
|
@ -253,17 +260,17 @@ class AnsibleCloudStackStaticNat(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, 'staticnat')
|
self._poll_job(res, 'staticnat')
|
||||||
return ip_address
|
return ip_address
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = cs_argument_spec()
|
argument_spec = cs_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
ip_address = dict(required=True),
|
ip_address = dict(required=True),
|
||||||
vm = dict(default=None),
|
vm = dict(default=None),
|
||||||
vm_guest_ip = dict(default=None),
|
vm_guest_ip = dict(default=None),
|
||||||
|
network = dict(default=None),
|
||||||
state = dict(choices=['present', 'absent'], default='present'),
|
state = dict(choices=['present', 'absent'], default='present'),
|
||||||
zone = dict(default=None),
|
zone = dict(default=None),
|
||||||
domain = dict(default=None),
|
domain = dict(default=None),
|
||||||
|
|
Loading…
Reference in a new issue