2 # Copyright (c) 2017 Intel Corporation
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 short_description: directly access shade
21 - directly access shade API
25 kwargs: dict of kwargs
26 fact_name: name of ansible fact to store result
38 module = AnsibleModule(
40 'method': {'required': True, 'type': 'str'},
41 'args': {'required': False, 'type': 'list', 'default': []},
42 'kwargs': {'required': False, 'type': 'dict', 'default': {}},
43 'os_auth': {'required': False, 'type': 'dict', 'default': {}},
44 'fact_name': {'required': True, 'type': 'str'},
49 module.fail_json(msg="shade not found")
50 shade.simple_logging(debug=True)
51 params = module.params
52 method = params['method']
54 kwargs = params['kwargs']
55 os_auth = params['os_auth']
56 fact_name = params['fact_name']
58 os.environ.update(os_auth)
60 c = shade.openstack_cloud()
63 ret = getattr(c, method)(*args, **kwargs)
66 # convert to regular dict, might not be necessary
68 except AttributeError:
75 module.exit_json(ansible_facts=ansible_facts)
78 # <<INCLUDE_ANSIBLE_MODULE_COMMON>>
79 from ansible.module_utils.basic import * # noqa
81 if __name__ == '__main__':