mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
cs_nic: PEP8 compliancy and documentation changes (#32655)
This PR includes: - PEP8 compliancy changes - Documentation changes
This commit is contained in:
parent
4cc7a89244
commit
56eb997bae
2 changed files with 28 additions and 45 deletions
|
@ -1,101 +1,85 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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)
|
# 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
|
from __future__ import absolute_import, division, print_function
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'status': ['deprecated'],
|
'status': ['deprecated'],
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: cs_nic
|
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:
|
description:
|
||||||
- Add and remove secondary IPs to and from a NIC.
|
- Add and remove secondary IPs to and from a NIC.
|
||||||
version_added: "2.3"
|
version_added: "2.3"
|
||||||
author: "René Moser (@resmo)"
|
author:
|
||||||
|
- René Moser (@resmo)
|
||||||
deprecated: Deprecated in 2.4. Use M(cs_instance_nic_secondaryip) instead.
|
deprecated: Deprecated in 2.4. Use M(cs_instance_nic_secondaryip) instead.
|
||||||
options:
|
options:
|
||||||
vm:
|
vm:
|
||||||
description:
|
description:
|
||||||
- Name of instance.
|
- Name of instance.
|
||||||
required: true
|
required: true
|
||||||
aliases: ['name']
|
aliases: [ name ]
|
||||||
network:
|
network:
|
||||||
description:
|
description:
|
||||||
- Name of the network.
|
- Name of the network.
|
||||||
- Required to find the NIC if instance has multiple networks assigned.
|
- Required to find the NIC if instance has multiple networks assigned.
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
vm_guest_ip:
|
vm_guest_ip:
|
||||||
description:
|
description:
|
||||||
- Secondary IP address to be added to the instance nic.
|
- 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.
|
- If not set, the API always returns a new IP address and idempotency is not given.
|
||||||
required: false
|
aliases: [ secondary_ip ]
|
||||||
default: null
|
|
||||||
aliases: ['secondary_ip']
|
|
||||||
vpc:
|
vpc:
|
||||||
description:
|
description:
|
||||||
- Name of the VPC the C(vm) is related to.
|
- Name of the VPC the C(vm) is related to.
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
domain:
|
domain:
|
||||||
description:
|
description:
|
||||||
- Domain the instance is related to.
|
- Domain the instance is related to.
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
account:
|
account:
|
||||||
description:
|
description:
|
||||||
- Account the instance is related to.
|
- Account the instance is related to.
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
project:
|
project:
|
||||||
description:
|
description:
|
||||||
- Name of the project the instance is deployed in.
|
- Name of the project the instance is deployed in.
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
zone:
|
zone:
|
||||||
description:
|
description:
|
||||||
- Name of the zone in which the instance is deployed in.
|
- Name of the zone in which the instance is deployed in.
|
||||||
- If not set, default zone is used.
|
- If not set, default zone is used.
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- State of the ipaddress.
|
- State of the ipaddress.
|
||||||
required: false
|
choices: [ absent, present ]
|
||||||
default: "present"
|
default: present
|
||||||
choices: [ 'present', 'absent' ]
|
|
||||||
poll_async:
|
poll_async:
|
||||||
description:
|
description:
|
||||||
- Poll async jobs until job has finished.
|
- Poll async jobs until job has finished.
|
||||||
required: false
|
type: bool
|
||||||
default: true
|
default: 'yes'
|
||||||
extends_documentation_fragment: cloudstack
|
extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
# Assign a specific IP to the default NIC of the VM
|
- name: Assign a specific IP to the default NIC of the VM
|
||||||
- local_action:
|
local_action:
|
||||||
module: cs_nic
|
module: cs_nic
|
||||||
vm: customer_xy
|
vm: customer_xy
|
||||||
vm_guest_ip: 10.10.10.10
|
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.
|
# 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
|
module: cs_nic
|
||||||
vm: customer_xy
|
vm: customer_xy
|
||||||
|
|
||||||
# Remove a specific IP from the default NIC
|
- name: Remove a specific IP from the default NIC
|
||||||
- local_action:
|
local_action:
|
||||||
module: cs_nic
|
module: cs_nic
|
||||||
vm: customer_xy
|
vm: customer_xy
|
||||||
vm_guest_ip: 10.10.10.10
|
vm_guest_ip: 10.10.10.10
|
||||||
|
@ -187,7 +171,7 @@ class AnsibleCloudStackNic(AnsibleCloudStack):
|
||||||
if nics:
|
if nics:
|
||||||
self.nic = nics['nic'][0]
|
self.nic = nics['nic'][0]
|
||||||
return self.nic
|
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):
|
def get_secondary_ip(self):
|
||||||
nic = self.get_nic()
|
nic = self.get_nic()
|
||||||
|
@ -242,7 +226,7 @@ class AnsibleCloudStackNic(AnsibleCloudStack):
|
||||||
self.result['network'] = self.get_network(key='name')
|
self.result['network'] = self.get_network(key='name')
|
||||||
self.result['vm'] = self.get_vm(key='name')
|
self.result['vm'] = self.get_vm(key='name')
|
||||||
self.result['vm_guest_ip'] = self.vm_guest_ip
|
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['account'] = self.get_account(key='name')
|
||||||
self.result['project'] = self.get_project(key='name')
|
self.result['project'] = self.get_project(key='name')
|
||||||
return self.result
|
return self.result
|
||||||
|
@ -251,15 +235,15 @@ class AnsibleCloudStackNic(AnsibleCloudStack):
|
||||||
def main():
|
def main():
|
||||||
argument_spec = cs_argument_spec()
|
argument_spec = cs_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
vm=dict(required=True, aliases=['name']),
|
vm=dict(type='str', required=True, aliases=['name']),
|
||||||
vm_guest_ip=dict(default=None, aliases=['secondary_ip']),
|
vm_guest_ip=dict(type='str', aliases=['secondary_ip']),
|
||||||
network=dict(default=None),
|
network=dict(type='str',),
|
||||||
vpc=dict(default=None),
|
vpc=dict(type='str'),
|
||||||
state=dict(choices=['present', 'absent'], default='present'),
|
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||||
domain=dict(default=None),
|
domain=dict(type='str'),
|
||||||
account=dict(default=None),
|
account=dict(type='str'),
|
||||||
project=dict(default=None),
|
project=dict(type='str'),
|
||||||
zone=dict(default=None),
|
zone=dict(type='str'),
|
||||||
poll_async=dict(type='bool', default=True),
|
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.py
|
||||||
lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork_facts.py
|
lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork_facts.py
|
||||||
lib/ansible/modules/cloud/centurylink/clc_loadbalancer.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_container.py
|
||||||
lib/ansible/modules/cloud/docker/docker_image.py
|
lib/ansible/modules/cloud/docker/docker_image.py
|
||||||
lib/ansible/modules/cloud/docker/docker_image_facts.py
|
lib/ansible/modules/cloud/docker/docker_image_facts.py
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue