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

Loading…
Cancel
Save