gce: PEP8 compliancy Fixes (#32311)

* gce: PEP8 compliancy Fixes

* Documentation updates

* Documentation updates

* Documentation update
This commit is contained in:
Nikhil Kathole
2017-11-07 18:49:17 +05:30
committed by Dag Wieers
parent 6ddc7c8524
commit 585ecc2867
4 changed files with 196 additions and 215 deletions

View File

@@ -1,11 +1,12 @@
#!/usr/bin/python
# Copyright 2017 Google Inc.
# -*- coding: utf-8 -*-
# Copyright: (c) 2017, Google Inc.
# 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'}
@@ -14,73 +15,74 @@ DOCUMENTATION = '''
---
module: gcspanner
version_added: "2.3"
short_description: Create and Delete Instances/Databases on Spanner.
short_description: Create and Delete Instances/Databases on Spanner
description:
- Create and Delete Instances/Databases on Spanner.
See U(https://cloud.google.com/spanner/docs) for an overview.
requirements:
- "python >= 2.6"
- "google-auth >= 0.5.0"
- "google-cloud-spanner >= 0.23.0"
- python >= 2.6
- google-auth >= 0.5.0
- google-cloud-spanner >= 0.23.0
notes:
- Changing the configuration on an existing instance is not supported.
author:
- "Tom Melendez (@supertom) <tom@supertom.com>"
- Tom Melendez (@supertom) <tom@supertom.com>
options:
configuration:
description:
- Configuration the instance should use. Examples are us-central1, asia-east1 and europe-west1.
required: True
- Configuration the instance should use.
- Examples are us-central1, asia-east1 and europe-west1.
required: yes
instance_id:
description:
- GCP spanner instance name.
required: True
required: yes
database_name:
description:
- Name of database contained on the instance.
required: False
force_instance_delete:
description:
- To delete an instance, this argument must exist and be true (along with state being equal to absent).
required: False
default: False
type: bool
default: 'no'
instance_display_name:
description:
- Name of Instance to display. If not specified, instance_id will be used instead.
required: False
- Name of Instance to display.
- If not specified, instance_id will be used instead.
node_count:
description:
- Number of nodes in the instance. If not specified while creating an instance,
node_count will be set to 1.
required: False
- Number of nodes in the instance.
default: 1
state:
description: State of the instance or database (absent, present). Applies to the most granular
resource. If a database_name is specified we remove it. If only instance_id
is specified, that is what is removed.
required: False
default: "present"
description:
- State of the instance or database. Applies to the most granular resource.
- If a C(database_name) is specified we remove it.
- If only C(instance_id) is specified, that is what is removed.
choices: [ absent, present ]
default: present
'''
EXAMPLES = '''
# Create instance.
gcspanner:
instance_id: "{{ instance_id }}"
configuration: "{{ configuration }}"
state: present
node_count: 1
- name: Create instance
gcspanner:
instance_id: '{{ instance_id }}'
configuration: '{{ configuration }}'
state: present
node_count: 1
# Create database.
gcspanner:
instance_id: "{{ instance_id }}"
configuration: "{{ configuration }}"
database_name: "{{ database_name }}"
state: present
- name: Create database
gcspanner:
instance_id: '{{ instance_id }}'
configuration: '{{ configuration }}'
database_name: '{{ database_name }}'
state: present
# Delete instance (and all databases)
gcspanner:
instance_id: "{{ instance_id }}"
configuration: "{{ configuration }}"
state: absent
force_instance_delete: yes
- name: Delete instance (and all databases)
- gcspanner:
instance_id: '{{ instance_id }}'
configuration: '{{ configuration }}'
state: absent
force_instance_delete: yes
'''
RETURN = '''
@@ -136,6 +138,7 @@ CLOUD_CLIENT = 'google-cloud-spanner'
CLOUD_CLIENT_MINIMUM_VERSION = '0.23.0'
CLOUD_CLIENT_USER_AGENT = 'ansible-spanner-0.1'
def get_spanner_configuration_name(config_name, project_name):
config_name = 'projects/%s/instanceConfigs/regional-%s' % (project_name,
config_name)
@@ -177,17 +180,20 @@ def instance_update(instance):
def main():
module = AnsibleModule(argument_spec=dict(
instance_id=dict(type='str', required=True),
state=dict(choices=['absent', 'present'], default='present'),
database_name=dict(type='str', default=None),
configuration=dict(type='str', required=True),
node_count=dict(type='int'),
instance_display_name=dict(type='str', default=None),
force_instance_delete=dict(type='bool', default=False),
service_account_email=dict(),
credentials_file=dict(),
project_id=dict(), ), )
module = AnsibleModule(
argument_spec=dict(
instance_id=dict(type='str', required=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
database_name=dict(type='str'),
configuration=dict(type='str', required=True),
node_count=dict(type='int', default=1),
instance_display_name=dict(type='str'),
force_instance_delete=dict(type='bool', default=False),
service_account_email=dict(type='str'),
credentials_file=dict(type='str'),
project_id=dict(type='str'),
),
)
if not HAS_PYTHON26:
module.fail_json(