mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-03-26 21:43:02 +00:00
With "extends_documentation_fragment: ['openstack.cloud.openstack']" it is not necessary to list required Python libraries in section 'requirements' of DOCUMENTATION docstring in modules. Ansible will merge requirements from doc fragments and DOCUMENTATION docstring which previously resulted in duplicates such as in server module [0]: * openstacksdk * openstacksdk >= 0.36, < 0.99.0 * python >= 3.6 When removing the 'requirements' section from server module, then Ansible will list openstacksdk once only: * openstacksdk >= 0.36, < 0.99.0 * python >= 3.6 To see what documentation Ansible will produce for server module run: ansible-doc --type module openstack.cloud.server [0] https://docs.ansible.com/ansible/latest/collections/openstack/\ cloud/server_module.html Change-Id: Ia53c2c34436c7a72080602f5699e82d20f677b8b
88 lines
2.2 KiB
Python
88 lines
2.2 KiB
Python
#!/usr/bin/python
|
|
# Copyright: Ansible Project
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
DOCUMENTATION = '''
|
|
---
|
|
module: federation_mapping_info
|
|
short_description: Get the information about the available federation mappings
|
|
author: OpenStack Ansible SIG
|
|
description:
|
|
- Fetch a federation mapping.
|
|
options:
|
|
name:
|
|
description:
|
|
- The name of the mapping to fetch.
|
|
- If I(name) is specified, the module will return failed if the mapping
|
|
doesn't exist.
|
|
type: str
|
|
aliases: ['id']
|
|
requirements:
|
|
- "openstacksdk >= 0.44, < 0.99.0"
|
|
extends_documentation_fragment:
|
|
- openstack.cloud.openstack
|
|
'''
|
|
|
|
EXAMPLES = '''
|
|
- name: Fetch a specific mapping
|
|
openstack.cloud.federation_mapping_info:
|
|
cloud: example_cloud
|
|
name: example_mapping
|
|
|
|
- name: Fetch all mappings
|
|
openstack.cloud.federation_mapping_info:
|
|
cloud: example_cloud
|
|
'''
|
|
|
|
RETURN = '''
|
|
'''
|
|
|
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
|
|
|
|
|
class IdentityFederationMappingInfoModule(OpenStackModule):
|
|
argument_spec = dict(
|
|
name=dict(aliases=['id']),
|
|
)
|
|
module_kwargs = dict(
|
|
supports_check_mode=True
|
|
)
|
|
|
|
module_min_sdk_version = "0.44"
|
|
|
|
def normalize_mapping(self, mapping):
|
|
"""
|
|
Normalizes the mapping definitions so that the outputs are consistent with the
|
|
parameters
|
|
|
|
- "name" (parameter) == "id" (SDK)
|
|
"""
|
|
if mapping is None:
|
|
return None
|
|
|
|
_mapping = mapping.to_dict()
|
|
_mapping['name'] = mapping['id']
|
|
return _mapping
|
|
|
|
def run(self):
|
|
""" Module entry point """
|
|
name = self.params.get('name')
|
|
|
|
if name:
|
|
mapping = self.normalize_mapping(
|
|
self.conn.identity.get_mapping(name))
|
|
self.exit_json(changed=False, mappings=[mapping])
|
|
else:
|
|
mappings = list(map(
|
|
self.normalize_mapping, self.conn.identity.mappings()))
|
|
self.exit_json(changed=False, mappings=mappings)
|
|
|
|
|
|
def main():
|
|
module = IdentityFederationMappingInfoModule()
|
|
module()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|