remove wildcards and add boilerplate

* cloud/centurylink
* source_control
* cloud/google
* notification
* cloud/rackspace
* cloud/vmware
This commit is contained in:
Toshio Kuratomi 2017-07-29 08:05:38 -07:00
commit 4109a82d0a
135 changed files with 1343 additions and 2631 deletions

View file

@ -1,18 +1,10 @@
#!/usr/bin/python
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Copyright: 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.0',
'status': ['preview'],
@ -243,8 +235,12 @@ EXAMPLES = '''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.gce import gce_connect
import traceback
try:
from ast import literal_eval
HAS_PYTHON26 = True
except ImportError:
HAS_PYTHON26 = False
try:
import libcloud
@ -258,11 +254,9 @@ try:
except ImportError:
HAS_LIBCLOUD = False
try:
from ast import literal_eval
HAS_PYTHON26 = True
except ImportError:
HAS_PYTHON26 = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.gce import gce_connect
from ansible.module_utils._text import to_native
def get_info(inst):
@ -294,7 +288,6 @@ def create_instance_template(module, gce):
subnetwork_region = module.params.get('subnetwork_region')
can_ip_forward = module.params.get('can_ip_forward')
external_ip = module.params.get('external_ip')
service_account_email = module.params.get('service_account_email')
service_account_permissions = module.params.get(
'service_account_permissions')
on_host_maintenance = module.params.get('on_host_maintenance')
@ -303,7 +296,6 @@ def create_instance_template(module, gce):
tags = module.params.get('tags')
metadata = module.params.get('metadata')
description = module.params.get('description')
disks = module.params.get('disks')
disks_gce_struct = module.params.get('disks_gce_struct')
changed = False
@ -467,8 +459,9 @@ def delete_instance_template(module, gce):
try:
instance = gce.ex_get_instancetemplate(name)
current_state = "present"
except GoogleBaseError as err:
json_data = dict(msg='instance template not exists')
except GoogleBaseError as e:
json_data = dict(msg='instance template not exists: %s' % to_native(e),
exception=traceback.format_exc())
if current_state == "present":
rc = instance.destroy()
@ -519,26 +512,26 @@ def check_if_system_state_would_be_changed(module, gce):
state = module.params.get("state")
name = module.params.get("name")
instance = None
try:
instance = gce.ex_get_instancetemplate(name)
gce.ex_get_instancetemplate(name)
current_state = "present"
except GoogleBaseError as err:
module.fail_json(msg='GCE get instancetemplate problem')
except GoogleBaseError as e:
module.fail_json(msg='GCE get instancetemplate problem: %s' % to_native(e),
exception=traceback.format_exc())
if current_state != state:
changed = True
if current_state == "absent":
if changed:
output = 'instance template {} will be created'.format(name)
output = 'instance template {0} will be created'.format(name)
else:
output = 'nothing to do for instance template {} '.format(name)
output = 'nothing to do for instance template {0} '.format(name)
if current_state == "present":
if changed:
output = 'instance template {} will be destroyed'.format(name)
output = 'instance template {0} will be destroyed'.format(name)
else:
output = 'nothing to do for instance template {} '.format(name)
output = 'nothing to do for instance template {0} '.format(name)
return (changed, output)
@ -587,8 +580,8 @@ def main():
try:
gce = gce_connect(module)
except GoogleBaseError as err:
module.fail_json(msg='GCE Connexion failed')
except GoogleBaseError as e:
module.fail_json(msg='GCE Connexion failed %s' % to_native(e), exception=traceback.format_exc())
if module.check_mode:
(changed, output) = check_if_system_state_would_be_changed(module, gce)