os_client_config: fix broken import (#26839)

* os_client_config: fix broken import
* remove wildcards and add boilerplate
This commit is contained in:
Pilou 2017-08-12 19:07:49 +02:00 committed by Toshio Kuratomi
parent f52a022022
commit feff6abd72
2 changed files with 17 additions and 18 deletions

View file

@ -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 <http://www.gnu.org/licenses/>.
# 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()

View file

@ -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