cs_nic: PEP8 compliancy and documentation changes (#32655)

This PR includes:
- PEP8 compliancy changes
- Documentation changes
pull/32679/head
Dag Wieers 7 years ago committed by ansibot
parent 4cc7a89244
commit 56eb997bae

@ -1,101 +1,85 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# (c) 2016, René Moser <mail@renemoser.net>
# Copyright: (c) 2016, René Moser <mail@renemoser.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['deprecated'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: cs_nic
short_description: Manages NICs and secondary IPs of an instance on Apache CloudStack based clouds.
short_description: Manages NICs and secondary IPs of an instance on Apache CloudStack based clouds
description:
- Add and remove secondary IPs to and from a NIC.
version_added: "2.3"
author: "René Moser (@resmo)"
author:
- René Moser (@resmo)
deprecated: Deprecated in 2.4. Use M(cs_instance_nic_secondaryip) instead.
options:
vm:
description:
- Name of instance.
required: true
aliases: ['name']
aliases: [ name ]
network:
description:
- Name of the network.
- Required to find the NIC if instance has multiple networks assigned.
required: false
default: null
vm_guest_ip:
description:
- Secondary IP address to be added to the instance nic.
- If not set, the API always returns a new IP address and idempotency is not given.
required: false
default: null
aliases: ['secondary_ip']
aliases: [ secondary_ip ]
vpc:
description:
- Name of the VPC the C(vm) is related to.
required: false
default: null
domain:
description:
- Domain the instance is related to.
required: false
default: null
account:
description:
- Account the instance is related to.
required: false
default: null
project:
description:
- Name of the project the instance is deployed in.
required: false
default: null
zone:
description:
- Name of the zone in which the instance is deployed in.
- If not set, default zone is used.
required: false
default: null
state:
description:
- State of the ipaddress.
required: false
default: "present"
choices: [ 'present', 'absent' ]
choices: [ absent, present ]
default: present
poll_async:
description:
- Poll async jobs until job has finished.
required: false
default: true
type: bool
default: 'yes'
extends_documentation_fragment: cloudstack
'''
EXAMPLES = '''
# Assign a specific IP to the default NIC of the VM
- local_action:
- name: Assign a specific IP to the default NIC of the VM
local_action:
module: cs_nic
vm: customer_xy
vm_guest_ip: 10.10.10.10
# Assign an IP to the default NIC of the VM
# Note: If vm_guest_ip is not set, you will get a new IP address on every run.
- local_action:
- name: Assign an IP to the default NIC of the VM
local_action:
module: cs_nic
vm: customer_xy
# Remove a specific IP from the default NIC
- local_action:
- name: Remove a specific IP from the default NIC
local_action:
module: cs_nic
vm: customer_xy
vm_guest_ip: 10.10.10.10
@ -187,7 +171,7 @@ class AnsibleCloudStackNic(AnsibleCloudStack):
if nics:
self.nic = nics['nic'][0]
return self.nic
self.module.fail_json(msg="NIC for VM %s in network %s not found" %(self.get_vm(key='name'), self.get_network(key='name')))
self.module.fail_json(msg="NIC for VM %s in network %s not found" % (self.get_vm(key='name'), self.get_network(key='name')))
def get_secondary_ip(self):
nic = self.get_nic()
@ -242,7 +226,7 @@ class AnsibleCloudStackNic(AnsibleCloudStack):
self.result['network'] = self.get_network(key='name')
self.result['vm'] = self.get_vm(key='name')
self.result['vm_guest_ip'] = self.vm_guest_ip
self.result['domain'] = self.get_domain(key='path')
self.result['domain'] = self.get_domain(key='path')
self.result['account'] = self.get_account(key='name')
self.result['project'] = self.get_project(key='name')
return self.result
@ -251,15 +235,15 @@ class AnsibleCloudStackNic(AnsibleCloudStack):
def main():
argument_spec = cs_argument_spec()
argument_spec.update(dict(
vm=dict(required=True, aliases=['name']),
vm_guest_ip=dict(default=None, aliases=['secondary_ip']),
network=dict(default=None),
vpc=dict(default=None),
state=dict(choices=['present', 'absent'], default='present'),
domain=dict(default=None),
account=dict(default=None),
project=dict(default=None),
zone=dict(default=None),
vm=dict(type='str', required=True, aliases=['name']),
vm_guest_ip=dict(type='str', aliases=['secondary_ip']),
network=dict(type='str',),
vpc=dict(type='str'),
state=dict(type='str', default='present', choices=['absent', 'present']),
domain=dict(type='str'),
account=dict(type='str'),
project=dict(type='str'),
zone=dict(type='str'),
poll_async=dict(type='bool', default=True),
))

@ -56,7 +56,6 @@ lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py
lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py
lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork_facts.py
lib/ansible/modules/cloud/centurylink/clc_loadbalancer.py
lib/ansible/modules/cloud/cloudstack/_cs_nic.py
lib/ansible/modules/cloud/docker/docker_container.py
lib/ansible/modules/cloud/docker/docker_image.py
lib/ansible/modules/cloud/docker/docker_image_facts.py

Loading…
Cancel
Save