cloudstack: cs_ip_address: fix vpc support (#22625)

* cloudstack: cs_ip_address: fix vpc support

* cloudstack: cs_ip_address: fix pep8
pull/22311/merge
René Moser 8 years ago committed by GitHub
parent ce56da69b2
commit a227a4ebb4

@ -132,8 +132,13 @@ domain:
sample: example domain sample: example domain
''' '''
# import cloudstack common from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.cloudstack import * from ansible.module_utils.cloudstack import (
AnsibleCloudStack,
CloudStackException,
cs_argument_spec,
cs_required_together,
)
class AnsibleCloudStackIPAddress(AnsibleCloudStack): class AnsibleCloudStackIPAddress(AnsibleCloudStack):
@ -147,8 +152,6 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
def get_ip_address(self, key=None): def get_ip_address(self, key=None):
if self.ip_address: if self.ip_address:
return self._get_by_key(key, self.ip_address) return self._get_by_key(key, self.ip_address)
ip_address = self.module.params.get('ip_address')
args = { args = {
'ipaddress': self.module.params.get('ip_address'), 'ipaddress': self.module.params.get('ip_address'),
'account': self.get_account(key='name'), 'account': self.get_account(key='name'),
@ -170,6 +173,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
'projectid': self.get_project(key='id'), 'projectid': self.get_project(key='id'),
'networkid': self.get_network(key='id'), 'networkid': self.get_network(key='id'),
'zoneid': self.get_zone(key='id'), 'zoneid': self.get_zone(key='id'),
'vpcid': self.get_vpc(key='id'),
} }
ip_address = None ip_address = None
if not self.module.check_mode: if not self.module.check_mode:
@ -203,15 +207,15 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
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=False), ip_address=dict(required=False),
state = dict(choices=['present', 'absent'], default='present'), state=dict(choices=['present', 'absent'], default='present'),
vpc = dict(default=None), vpc=dict(),
network = dict(default=None), network=dict(),
zone = dict(default=None), zone=dict(),
domain = dict(default=None), domain=dict(),
account = dict(default=None), account=dict(),
project = dict(default=None), project=dict(),
poll_async = dict(type='bool', default=True), poll_async=dict(type='bool', default=True),
)) ))
module = AnsibleModule( module = AnsibleModule(
@ -239,7 +243,6 @@ def main():
module.exit_json(**result) module.exit_json(**result)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

Loading…
Cancel
Save