Debian Codegraph @

ansible_collections/cisco/intersight/plugins/modules/intersight_wwn_pool_info.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import absolute_import, division, print_function
7 __metaclass__ = type
8
9 ANSIBLE_METADATA = {'metadata_version': '1.1',
10 'status': ['preview'],
11 'supported_by': 'community'}
12
13 DOCUMENTATION = r'''
14 ---
15 module: intersight_wwn_pool_info
16 short_description: Gather information about WWN Pool in Cisco Intersight
17 description:
18 - Gather information about WWNN/WWPN Pool in L(Cisco Intersight,https://intersight.com).
19 - Information can be filtered using Organization, Name and PoolPurpose. if none is passed all information regarding existing
20 WWN pools will be fetched.
21 extends_documentation_fragment: intersight
22 options:
23 organization:
24 description:
25 - The name of the organization that will have information gathered from.
26 type: str
27 name:
28 description:
29 - The name of the WWNN/WWPN Pool that will have information gathered from.
30 type: str
31 pool_purpose:
32 description:
33 - The pool type WWNN or WWPN.
34 - WWNN and WWPN pools can have the same name. if none is passed all information regardless of pool purpose will be fetched.
35 type: str
36 author:
37 - Shahar Golshani (@sgolshan)
38 '''
39
40 EXAMPLES = r'''
41 - name: Fetch wwn pool information by name
42 cisco.intersight.intersight_wwn_pool_info:
43 api_private_key: "{{ api_private_key }}"
44 api_key_id: "{{ api_key_id }}"
45 name: wwn_pool_1
46
47 - name: Fetch all wwn pool information
48 cisco.intersight.intersight_wwn_pool_info:
49 api_private_key: "{{ api_private_key }}"
50 api_key_id: "{{ api_key_id }}"
51 '''
52
53 RETURN = r'''
54 api_response:
55 description: The API response output returned by the specified resource.
56 returned: always
57 type: dict
58 sample:
59 "api_response": [
60 {
61 "Name": "wwn_pool_1",
62 "ObjectType": "fcpool.Pool",
63 "Tags": [
64 {
65 "Key": "Site",
66 "Value": "tag1"
67 }
68 ],
69 "IdBlocks": [
70 {
71 "ClassId": "fcpool.Block",
72 "From": "20:00:00:25:B5:00:00:00",
73 "ObjectType": "fcpool.Block",
74 "Size": 100,
75 "To": "20:00:00:25:B5:00:00:63"
76 }
77 ],
78 "PoolPurpose": "WWPN"
79 }
80 ]
81 '''
82
83
84 from ansible.module_utils.basic import AnsibleModule
85 from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec
86
87
88 def main():
89 argument_spec = intersight_argument_spec.copy()
90 argument_spec.update(
91 organization=dict(type='str'),
92 name=dict(type='str'),
93 pool_purpose=dict(type='str')
94 )
95 module = AnsibleModule(
96 argument_spec,
97 supports_check_mode=True,
98 )
99
100 intersight = IntersightModule(module)
101 intersight.result['api_response'] = {}
102 intersight.result['trace_id'] = ''
103
104 # Resource path used to fetch info
105 resource_path = '/fcpool/Pools'
106
107 query_params = intersight.set_query_params(filter_key="PoolPurpose", filter_value=intersight.module.params['pool_purpose'])
108 intersight.get_resource(
109 resource_path=resource_path,
110 query_params=query_params,
111 return_list=True
112 )
113
114 module.exit_json(**intersight.result)
115
116
117 if __name__ == '__main__':
118 main()