From feff6abd72dd0fb00e625c101b4698694450cecd Mon Sep 17 00:00:00 2001 From: Pilou Date: Sat, 12 Aug 2017 19:07:49 +0200 Subject: [PATCH] os_client_config: fix broken import (#26839) * os_client_config: fix broken import * remove wildcards and add boilerplate --- .../cloud/openstack/os_client_config.py | 34 +++++++++---------- test/sanity/import/skip.txt | 1 - 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_client_config.py b/lib/ansible/modules/cloud/openstack/os_client_config.py index d1374386184..6ad250fa4f1 100644 --- a/lib/ansible/modules/cloud/openstack/os_client_config.py +++ b/lib/ansible/modules/cloud/openstack/os_client_config.py @@ -1,19 +1,11 @@ #!/usr/bin/python # Copyright (c) 2015 Hewlett-Packard Development Company, L.P. -# -# This module 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. -# -# This software 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 this software. If not, see . +# 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'], @@ -54,14 +46,24 @@ EXAMPLES = ''' - mordred ''' -import os_client_config -from os_client_config import exceptions +from ansible.module_utils.basic import AnsibleModule + +try: + import os_client_config + from os_client_config import exceptions + HAS_OS_CLIENT_CONFIG = True +except ImportError: + HAS_OS_CLIENT_CONFIG = False def main(): module = AnsibleModule(argument_spec=dict( clouds=dict(required=False, type='list', default=[]), )) + + if not HAS_OS_CLIENT_CONFIG: + module.fail_json(msg='os-client-config is required for this module') + p = module.params try: @@ -75,8 +77,6 @@ def main(): except exceptions.OpenStackConfigException as e: module.fail_json(msg=str(e)) -# import module snippets -from ansible.module_utils.basic import * if __name__ == "__main__": main() diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 4bfb02f7f19..f5a4ae42f98 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -44,7 +44,6 @@ lib/ansible/modules/cloud/google/gc_storage.py lib/ansible/modules/cloud/google/gcdns_record.py lib/ansible/modules/cloud/google/gcdns_zone.py lib/ansible/modules/cloud/misc/serverless.py -lib/ansible/modules/cloud/openstack/os_client_config.py lib/ansible/modules/cloud/ovirt/ovirt_disks.py lib/ansible/modules/cloud/univention/udm_user.py lib/ansible/modules/cloud/webfaction/webfaction_app.py