Debian Codegraph @

ansible_collections/cisco/intersight/plugins/modules/intersight_fibre_channel_zone_policy_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_fibre_channel_zone_policy_info
16 short_description: Gather information about Fibre Channel Zone Policies in Cisco Intersight
17 description:
18 - Retrieve comprehensive information about Fibre Channel Zone Policies from L(Cisco Intersight,https://intersight.com).
19 - Query policies by organization or policy name.
20 - FC target members are embedded in the policy object as FcTargetMembers array.
21 - If no filters are provided, all FC Zone Policies will be returned.
22 extends_documentation_fragment: intersight
23 options:
24 organization:
25 description:
26 - The name of the organization to filter FC Zone Policies by.
27 - Use 'default' for the default organization.
28 - When specified, only policies from this organization will be returned.
29 type: str
30 name:
31 description:
32 - The exact name of the FC Zone Policy to retrieve information from.
33 - When specified, only the matching policy will be returned.
34 type: str
35 author:
36 - Ron Gershburg (@rgershbu)
37 '''
38
39 EXAMPLES = r'''
40 # Basic Usage Examples
41 - name: Fetch all FC Zone Policies from all organizations
42 cisco.intersight.intersight_fibre_channel_zone_policy_info:
43 api_private_key: "{{ api_private_key }}"
44 api_key_id: "{{ api_key_id }}"
45 register: all_fc_zone_policies
46
47 - name: Display all policies
48 debug:
49 msg: "Found {{ all_fc_zone_policies.api_response | length }} FC Zone Policies"
50
51 # Organization-specific Examples
52 - name: Fetch all FC Zone Policies from the default organization
53 cisco.intersight.intersight_fibre_channel_zone_policy_info:
54 api_private_key: "{{ api_private_key }}"
55 api_key_id: "{{ api_key_id }}"
56 organization: "default"
57 register: default_org_policies
58
59 - name: Fetch all FC Zone Policies from a custom organization
60 cisco.intersight.intersight_fibre_channel_zone_policy_info:
61 api_private_key: "{{ api_private_key }}"
62 api_key_id: "{{ api_key_id }}"
63 organization: "Engineering"
64 register: engineering_policies
65
66 # Specific Policy Examples
67 - name: Fetch a specific FC Zone Policy by name
68 cisco.intersight.intersight_fibre_channel_zone_policy_info:
69 api_private_key: "{{ api_private_key }}"
70 api_key_id: "{{ api_key_id }}"
71 name: "fc-zone-policy-simt"
72 register: specific_policy
73 '''
74
75 RETURN = r'''
76 api_response:
77 description:
78 - The API response containing policy information including embedded FC target members.
79 - Returns a dictionary when querying a single policy.
80 - Returns a list when multiple policies are found.
81 returned: always
82 type: dict
83 sample:
84 Name: "fc-zone-policy-simt"
85 ObjectType: "fabric.FcZonePolicy"
86 Moid: "12345678901234567890abcd"
87 Description: "FC Zone policy with SIMT zoning"
88 FcTargetZoningType: "SIMT"
89 FcTargetMembers:
90 - Name: "target1"
91 Wwpn: "21:00:00:e0:8b:05:05:04"
92 SwitchId: "A"
93 VsanId: 100
94 - Name: "target2"
95 Wwpn: "21:00:00:e0:8b:05:05:03"
96 SwitchId: "B"
97 VsanId: 100
98 Organization:
99 Name: "default"
100 ObjectType: "organization.Organization"
101 Tags:
102 - Key: "Environment"
103 Value: "Production"
104 '''
105
106
107 from ansible.module_utils.basic import AnsibleModule
108 from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec
109
110
111 def main():
112 argument_spec = intersight_argument_spec.copy()
113 argument_spec.update(
114 organization=dict(type='str'),
115 name=dict(type='str')
116 )
117 module = AnsibleModule(
118 argument_spec,
119 supports_check_mode=True,
120 )
121 intersight = IntersightModule(module)
122
123 # Resource path used to fetch policy info
124 resource_path = '/fabric/FcZonePolicies'
125
126 # Get query parameters for policies
127 query_params = intersight.set_query_params()
128
129 # Get FC Zone policies
130 intersight.get_resource(
131 resource_path=resource_path,
132 query_params=query_params,
133 return_list=True
134 )
135
136 module.exit_json(**intersight.result)
137
138
139 if __name__ == '__main__':
140 main()