Debian Codegraph @

ansible_collections/cisco/intersight/plugins/modules/intersight_vhba_template_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_vhba_template_info
16 short_description: Gather information about vHBA Templates in Cisco Intersight
17 description:
18 - Retrieve comprehensive information about vHBA Templates from L(Cisco Intersight,https://intersight.com).
19 - Query templates by organization, template name, or other filters.
20 - Returns structured data with template metadata and policy associations.
21 - If no filters are provided, all vHBA Templates will be returned.
22 - vHBA Templates are used to define standardized fibre channel interface configurations for FI-Attached deployments.
23 extends_documentation_fragment: intersight
24 options:
25 organization:
26 description:
27 - The name of the organization to filter vHBA Templates by.
28 - Use 'default' for the default organization.
29 - When specified, only templates from this organization will be returned.
30 type: str
31 name:
32 description:
33 - The exact name of the vHBA Template to retrieve information from.
34 - When specified, only the matching template will be returned.
35 type: str
36 author:
37 - Ron Gershburg (@rgershbu)
38 '''
39
40 EXAMPLES = r'''
41 # Basic Usage Examples
42 - name: Fetch all vHBA Templates from all organizations
43 cisco.intersight.intersight_vhba_template_info:
44 api_private_key: "{{ api_private_key }}"
45 api_key_id: "{{ api_key_id }}"
46 register: all_vhba_templates
47
48 - name: Display all template names
49 debug:
50 msg: "Template: {{ item.Name }}"
51 loop: "{{ all_vhba_templates.api_response }}"
52 when: all_vhba_templates.api_response is iterable
53
54 # Organization-specific Examples
55 - name: Fetch all vHBA Templates from the default organization
56 cisco.intersight.intersight_vhba_template_info:
57 api_private_key: "{{ api_private_key }}"
58 api_key_id: "{{ api_key_id }}"
59 organization: "default"
60 register: default_org_templates
61
62 - name: Fetch all vHBA Templates from a custom organization
63 cisco.intersight.intersight_vhba_template_info:
64 api_private_key: "{{ api_private_key }}"
65 api_key_id: "{{ api_key_id }}"
66 organization: "Engineering"
67 register: engineering_templates
68
69 # Name-specific Example
70 - name: Fetch a specific vHBA Template
71 cisco.intersight.intersight_vhba_template_info:
72 api_private_key: "{{ api_private_key }}"
73 api_key_id: "{{ api_key_id }}"
74 organization: "default"
75 name: "production-vhba-template"
76 register: specific_template
77 '''
78
79 RETURN = r'''
80 api_response:
81 description:
82 - The API response containing vHBA Template information.
83 - Returns a dictionary when querying a single template or no templates found.
84 - Returns a list when multiple templates are found.
85 returned: always
86 type: dict
87 sample:
88 Name: "production-vhba-template"
89 ObjectType: "vnic.VhbaTemplate"
90 Moid: "12345678901234567890abcd"
91 Description: "Production vHBA template for FI-attached servers"
92 EnableOverride: false
93 Type: "fc-initiator"
94 SwitchId: "A"
95 PersistentBindings: false
96 WwpnAddressType: "POOL"
97 WwpnPool:
98 Name: "default-wwpn-pool"
99 ObjectType: "fcpool.Pool"
100 Moid: "wwpnpool12345678901234567890"
101 FcNetworkPolicy:
102 Name: "fc-network-policy"
103 ObjectType: "vnic.FcNetworkPolicy"
104 Moid: "fcnetwork12345678901234567890"
105 FcQosPolicy:
106 Name: "fc-qos-policy"
107 ObjectType: "vnic.FcQosPolicy"
108 Moid: "fcqos12345678901234567890"
109 FcAdapterPolicy:
110 Name: "fc-adapter-policy"
111 ObjectType: "vnic.FcAdapterPolicy"
112 Moid: "fcadapter12345678901234567890"
113 FcZonePolicies:
114 - Name: "fc-zone-policy-1"
115 ObjectType: "fabric.FcZonePolicy"
116 Moid: "fczone12345678901234567890"
117 Organization:
118 Name: "default"
119 ObjectType: "organization.Organization"
120 Moid: "org12345678901234567890"
121 Tags:
122 - Key: "Environment"
123 Value: "Production"
124 - Key: "Site"
125 Value: "DataCenter-A"
126 '''
127
128
129 from ansible.module_utils.basic import AnsibleModule
130 from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec
131
132
133 def main():
134 argument_spec = intersight_argument_spec.copy()
135 argument_spec.update(
136 organization=dict(type='str'),
137 name=dict(type='str')
138 )
139 module = AnsibleModule(
140 argument_spec,
141 supports_check_mode=True,
142 )
143
144 intersight = IntersightModule(module)
145 intersight.result['api_response'] = {}
146 intersight.result['trace_id'] = ''
147
148 # Resource path used to fetch vHBA Template info
149 resource_path = '/vnic/VhbaTemplates'
150
151 # Get query parameters for templates
152 query_params = intersight.set_query_params()
153
154 # Get vHBA Templates
155 intersight.get_resource(
156 resource_path=resource_path,
157 query_params=query_params,
158 return_list=True
159 )
160
161 module.exit_json(**intersight.result)
162
163
164 if __name__ == '__main__':
165 main()