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 #!/usr/bin/python
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. # Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# 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 from __future__ import absolute_import, division, print_function
# (at your option) any later version. __metaclass__ = type
#
# 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/>.
ANSIBLE_METADATA = {'metadata_version': '1.0', ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'], 'status': ['preview'],
@ -54,14 +46,24 @@ EXAMPLES = '''
- mordred - mordred
''' '''
from ansible.module_utils.basic import AnsibleModule
try:
import os_client_config import os_client_config
from os_client_config import exceptions from os_client_config import exceptions
HAS_OS_CLIENT_CONFIG = True
except ImportError:
HAS_OS_CLIENT_CONFIG = False
def main(): def main():
module = AnsibleModule(argument_spec=dict( module = AnsibleModule(argument_spec=dict(
clouds=dict(required=False, type='list', default=[]), 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 p = module.params
try: try:
@ -75,8 +77,6 @@ def main():
except exceptions.OpenStackConfigException as e: except exceptions.OpenStackConfigException as e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
# import module snippets
from ansible.module_utils.basic import *
if __name__ == "__main__": if __name__ == "__main__":
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_record.py
lib/ansible/modules/cloud/google/gcdns_zone.py lib/ansible/modules/cloud/google/gcdns_zone.py
lib/ansible/modules/cloud/misc/serverless.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/ovirt/ovirt_disks.py
lib/ansible/modules/cloud/univention/udm_user.py lib/ansible/modules/cloud/univention/udm_user.py
lib/ansible/modules/cloud/webfaction/webfaction_app.py lib/ansible/modules/cloud/webfaction/webfaction_app.py