diff options
author | Matt Clay <matt@mystile.com> | 2017-01-30 20:01:03 -0800 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2017-01-30 20:17:35 -0800 |
commit | 85300883ef75e9664258f1aeba8776d628a17f7a (patch) | |
tree | ed7cce78d9e49f767d70b55a676a00210b017774 /lib/ansible | |
parent | 5f89fc4a689fed6d60a79ba23fae6860706cb82d (diff) | |
download | ansible-85300883ef75e9664258f1aeba8776d628a17f7a.tar.gz |
PEP 8 E111 cleanup.
Diffstat (limited to 'lib/ansible')
-rw-r--r-- | lib/ansible/modules/cloud/google/gcpubsub_facts.py | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/lib/ansible/modules/cloud/google/gcpubsub_facts.py b/lib/ansible/modules/cloud/google/gcpubsub_facts.py index 77c7289b85..165f8a100a 100644 --- a/lib/ansible/modules/cloud/google/gcpubsub_facts.py +++ b/lib/ansible/modules/cloud/google/gcpubsub_facts.py @@ -85,10 +85,10 @@ topics: ''' try: - from ast import literal_eval - HAS_PYTHON26 = True + from ast import literal_eval + HAS_PYTHON26 = True except ImportError: - HAS_PYTHON26 = False + HAS_PYTHON26 = False try: from google.cloud import pubsub @@ -96,52 +96,52 @@ try: except ImportError as e: HAS_GOOGLE_CLOUD_PUBSUB = False def list_func(data, member='name'): - """Used for state=list.""" - return [getattr(x, member) for x in data] + """Used for state=list.""" + return [getattr(x, member) for x in data] def main(): - module = AnsibleModule(argument_spec=dict( - view=dict(choices=['topics', 'subscriptions'], default='topics'), - topic=dict(required=False), - state=dict(choices=['list'], default='list'), - service_account_email=dict(), - credentials_file=dict(), - project_id=dict(), ),) - - if not HAS_PYTHON26: - module.fail_json( - msg="GCE module requires python's 'ast' module, python v2.6+") - - if not HAS_GOOGLE_CLOUD_PUBSUB: - module.fail_json(msg="Please install google-cloud-pubsub library.") - - CLIENT_MINIMUM_VERSION = '0.22.0' - if not check_min_pkg_version('google-cloud-pubsub', CLIENT_MINIMUM_VERSION): + module = AnsibleModule(argument_spec=dict( + view=dict(choices=['topics', 'subscriptions'], default='topics'), + topic=dict(required=False), + state=dict(choices=['list'], default='list'), + service_account_email=dict(), + credentials_file=dict(), + project_id=dict(), ),) + + if not HAS_PYTHON26: + module.fail_json( + msg="GCE module requires python's 'ast' module, python v2.6+") + + if not HAS_GOOGLE_CLOUD_PUBSUB: + module.fail_json(msg="Please install google-cloud-pubsub library.") + + CLIENT_MINIMUM_VERSION = '0.22.0' + if not check_min_pkg_version('google-cloud-pubsub', CLIENT_MINIMUM_VERSION): module.fail_json(msg="Please install google-cloud-pubsub library version %s" % CLIENT_MINIMUM_VERSION) - mod_params = {} - mod_params['state'] = module.params.get('state') - mod_params['topic'] = module.params.get('topic') - mod_params['view'] = module.params.get('view') - - creds, params = get_google_cloud_credentials(module) - pubsub_client = pubsub.Client(project=params['project_id'], credentials=creds, use_gax=False) - pubsub_client.user_agent = 'ansible-pubsub-0.1' - - json_output = {} - if mod_params['view'] == 'topics': - json_output['topics'] = list_func(pubsub_client.list_topics()) - elif mod_params['view'] == 'subscriptions': - if mod_params['topic']: - t = pubsub_client.topic(mod_params['topic']) - json_output['subscriptions'] = list_func(t.list_subscriptions()) - else: - json_output['subscriptions'] = list_func(pubsub_client.list_subscriptions()) - - json_output['changed'] = False - json_output.update(mod_params) - module.exit_json(**json_output) + mod_params = {} + mod_params['state'] = module.params.get('state') + mod_params['topic'] = module.params.get('topic') + mod_params['view'] = module.params.get('view') + + creds, params = get_google_cloud_credentials(module) + pubsub_client = pubsub.Client(project=params['project_id'], credentials=creds, use_gax=False) + pubsub_client.user_agent = 'ansible-pubsub-0.1' + + json_output = {} + if mod_params['view'] == 'topics': + json_output['topics'] = list_func(pubsub_client.list_topics()) + elif mod_params['view'] == 'subscriptions': + if mod_params['topic']: + t = pubsub_client.topic(mod_params['topic']) + json_output['subscriptions'] = list_func(t.list_subscriptions()) + else: + json_output['subscriptions'] = list_func(pubsub_client.list_subscriptions()) + + json_output['changed'] = False + json_output.update(mod_params) + module.exit_json(**json_output) # import module snippets from ansible.module_utils.basic import * |