sl_vm: PEP8 compliancy and documentation changes (#32657)

This PR includes:
- PEP8 compliancy changes
- Documentation changes
pull/33041/head
Dag Wieers 7 years ago committed by ansibot
parent 53c5e5bf5a
commit 3089892e59

@ -1,145 +1,121 @@
#!/usr/bin/python #!/usr/bin/python
# Copyright: Ansible Project # -*- coding: utf-8 -*-
# Copyright: (c) 2017, Ansible Project
# 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': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: sl_vm module: sl_vm
short_description: create or cancel a virtual instance in SoftLayer short_description: create or cancel a virtual instance in SoftLayer
description: description:
- Creates or cancels SoftLayer instances. When created, optionally waits for it to be 'running'. - Creates or cancels SoftLayer instances.
- When created, optionally waits for it to be 'running'.
version_added: "2.1" version_added: "2.1"
options: options:
instance_id: instance_id:
description: description:
- Instance Id of the virtual instance to perform action option - Instance Id of the virtual instance to perform action option.
required: false
default: null
hostname: hostname:
description: description:
- Hostname to be provided to a virtual instance - Hostname to be provided to a virtual instance.
required: false
default: null
domain: domain:
description: description:
- Domain name to be provided to a virtual instance - Domain name to be provided to a virtual instance.
required: false
default: null
datacenter: datacenter:
description: description:
- Datacenter for the virtual instance to be deployed - Datacenter for the virtual instance to be deployed.
required: false
default: null
tags: tags:
description: description:
- Tag or list of tags to be provided to a virtual instance - Tag or list of tags to be provided to a virtual instance.
required: false
default: null
hourly: hourly:
description: description:
- Flag to determine if the instance should be hourly billed - Flag to determine if the instance should be hourly billed.
required: false type: bool
default: true default: 'yes'
private: private:
description: description:
- Flag to determine if the instance should be private only - Flag to determine if the instance should be private only.
required: false type: bool
default: false default: 'no'
dedicated: dedicated:
description: description:
- Flag to determine if the instance should be deployed in dedicated space - Flag to determine if the instance should be deployed in dedicated space.
required: false type: bool
default: false default: 'no'
local_disk: local_disk:
description: description:
- Flag to determine if local disk should be used for the new instance - Flag to determine if local disk should be used for the new instance.
required: false type: bool
default: true default: 'yes'
cpus: cpus:
description: description:
- Count of cpus to be assigned to new virtual instance - Count of cpus to be assigned to new virtual instance.
required: true required: true
default: null
memory: memory:
description: description:
- Amount of memory to be assigned to new virtual instance - Amount of memory to be assigned to new virtual instance.
required: true required: true
default: null
disks: disks:
description: description:
- List of disk sizes to be assigned to new virtual instance - List of disk sizes to be assigned to new virtual instance.
required: true required: true
default: [ 25 ] default: [ 25 ]
os_code: os_code:
description: description:
- OS Code to be used for new virtual instance - OS Code to be used for new virtual instance.
required: false
default: null
image_id: image_id:
description: description:
- Image Template to be used for new virtual instance - Image Template to be used for new virtual instance.
required: false
default: null
nic_speed: nic_speed:
description: description:
- NIC Speed to be assigned to new virtual instance - NIC Speed to be assigned to new virtual instance.
required: false
default: 10 default: 10
public_vlan: public_vlan:
description: description:
- VLAN by its Id to be assigned to the public NIC - VLAN by its Id to be assigned to the public NIC.
required: false
default: null
private_vlan: private_vlan:
description: description:
- VLAN by its Id to be assigned to the private NIC - VLAN by its Id to be assigned to the private NIC.
required: false
default: null
ssh_keys: ssh_keys:
description: description:
- List of ssh keys by their Id to be assigned to a virtual instance - List of ssh keys by their Id to be assigned to a virtual instance.
required: false
default: null
post_uri: post_uri:
description: description:
- URL of a post provisioning script to be loaded and executed on virtual instance - URL of a post provisioning script to be loaded and executed on virtual instance.
required: false
default: null
state: state:
description: description:
- Create, or cancel a virtual instance. Specify "present" for create, "absent" to cancel. - Create, or cancel a virtual instance.
required: false - Specify C(present) for create, C(absent) to cancel.
default: 'present' choices: [ absent, present ]
default: present
wait: wait:
description: description:
- Flag used to wait for active status before returning - Flag used to wait for active status before returning.
required: false type: bool
default: true default: 'yes'
wait_time: wait_time:
description: description:
- time in seconds before wait returns - Time in seconds before wait returns.
required: false
default: 600 default: 600
requirements: requirements:
- "python >= 2.6" - python >= 2.6
- "softlayer >= 4.1.1" - softlayer >= 4.1.1
author: "Matt Colton (@mcltn)" author:
- Matt Colton (@mcltn)
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: Build instance - name: Build instance
hosts: localhost hosts: localhost
gather_facts: False gather_facts: no
tasks: tasks:
- name: Build instance request - name: Build instance request
sl_vm: sl_vm:
@ -147,19 +123,19 @@ EXAMPLES = '''
domain: anydomain.com domain: anydomain.com
datacenter: dal09 datacenter: dal09
tags: ansible-module-test tags: ansible-module-test
hourly: True hourly: yes
private: False private: no
dedicated: False dedicated: no
local_disk: True local_disk: yes
cpus: 1 cpus: 1
memory: 1024 memory: 1024
disks: [25] disks: [25]
os_code: UBUNTU_LATEST os_code: UBUNTU_LATEST
wait: False wait: no
- name: Build additional instances - name: Build additional instances
hosts: localhost hosts: localhost
gather_facts: False gather_facts: no
tasks: tasks:
- name: Build instances request - name: Build instances request
sl_vm: sl_vm:
@ -184,10 +160,10 @@ EXAMPLES = '''
tags: tags:
- ansible-module-test - ansible-module-test
- ansible-module-test-slaves - ansible-module-test-slaves
hourly: True hourly: yes
private: False private: no
dedicated: False dedicated: no
local_disk: True local_disk: yes
cpus: 1 cpus: 1
memory: 1024 memory: 1024
disks: disks:
@ -202,10 +178,10 @@ EXAMPLES = '''
tags: tags:
- ansible-module-test - ansible-module-test
- ansible-module-test-slaves - ansible-module-test-slaves
hourly: True hourly: yes
private: False private: no
dedicated: False dedicated: no
local_disk: True local_disk: yes
cpus: 1 cpus: 1
memory: 1024 memory: 1024
disks: disks:
@ -213,11 +189,11 @@ EXAMPLES = '''
- 100 - 100
os_code: UBUNTU_LATEST os_code: UBUNTU_LATEST
ssh_keys: [] ssh_keys: []
wait: True wait: yes
- name: Cancel instances - name: Cancel instances
hosts: localhost hosts: localhost
gather_facts: False gather_facts: no
tasks: tasks:
- name: Cancel by tag - name: Cancel by tag
sl_vm: sl_vm:
@ -267,7 +243,6 @@ def create_virtual_instance(module):
if instances: if instances:
return False, None return False, None
# Check if OS or Image Template is provided (Can't be both, defaults to OS) # Check if OS or Image Template is provided (Can't be both, defaults to OS)
if (module.params.get('os_code') is not None and module.params.get('os_code') != ''): if (module.params.get('os_code') is not None and module.params.get('os_code') != ''):
module.params['image_id'] = '' module.params['image_id'] = ''
@ -299,7 +274,8 @@ def create_virtual_instance(module):
private_vlan=module.params.get('private_vlan'), private_vlan=module.params.get('private_vlan'),
dedicated=module.params.get('dedicated'), dedicated=module.params.get('dedicated'),
post_uri=module.params.get('post_uri'), post_uri=module.params.get('post_uri'),
tags = tags) tags=tags,
)
if instance is not None and instance['id'] > 0: if instance is not None and instance['id'] > 0:
return True, instance return True, instance
@ -349,11 +325,11 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
instance_id=dict(), instance_id=dict(type='str'),
hostname=dict(), hostname=dict(type='str'),
domain=dict(), domain=dict(type='str'),
datacenter=dict(choices=DATACENTERS), datacenter=dict(type='str', choices=DATACENTERS),
tags=dict(), tags=dict(type='str'),
hourly=dict(type='bool', default=True), hourly=dict(type='bool', default=True),
private=dict(type='bool', default=False), private=dict(type='bool', default=False),
dedicated=dict(type='bool', default=False), dedicated=dict(type='bool', default=False),
@ -361,16 +337,16 @@ def main():
cpus=dict(type='int', choices=CPU_SIZES), cpus=dict(type='int', choices=CPU_SIZES),
memory=dict(type='int', choices=MEMORY_SIZES), memory=dict(type='int', choices=MEMORY_SIZES),
disks=dict(type='list', default=[25]), disks=dict(type='list', default=[25]),
os_code=dict(), os_code=dict(type='str'),
image_id=dict(), image_id=dict(type='str'),
nic_speed=dict(type='int', choices=NIC_SPEEDS), nic_speed=dict(type='int', choices=NIC_SPEEDS),
public_vlan=dict(), public_vlan=dict(type='str'),
private_vlan=dict(), private_vlan=dict(type='str'),
ssh_keys=dict(type='list', default=[]), ssh_keys=dict(type='list', default=[]),
post_uri=dict(), post_uri=dict(type='str'),
state=dict(default='present', choices=STATES), state=dict(type='str', default='present', choices=STATES),
wait=dict(type='bool', default=True), wait=dict(type='bool', default=True),
wait_time=dict(type='int', default=600) wait_time=dict(type='int', default=600),
) )
) )

@ -99,7 +99,6 @@ lib/ansible/modules/cloud/rackspace/rax_mon_check.py
lib/ansible/modules/cloud/rackspace/rax_mon_entity.py lib/ansible/modules/cloud/rackspace/rax_mon_entity.py
lib/ansible/modules/cloud/rackspace/rax_mon_notification.py lib/ansible/modules/cloud/rackspace/rax_mon_notification.py
lib/ansible/modules/cloud/rackspace/rax_mon_notification_plan.py lib/ansible/modules/cloud/rackspace/rax_mon_notification_plan.py
lib/ansible/modules/cloud/softlayer/sl_vm.py
lib/ansible/modules/cloud/univention/udm_dns_record.py lib/ansible/modules/cloud/univention/udm_dns_record.py
lib/ansible/modules/cloud/univention/udm_dns_zone.py lib/ansible/modules/cloud/univention/udm_dns_zone.py
lib/ansible/modules/cloud/univention/udm_group.py lib/ansible/modules/cloud/univention/udm_group.py

Loading…
Cancel
Save