Debian Codegraph @

ansible_collections/cisco/intersight/plugins/modules/intersight_multicast_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_multicast_policy_info
16 short_description: Gather information about Multicast Policies in Cisco Intersight
17 description:
18 - Gather information about Multicast Policies in L(Cisco Intersight,https://intersight.com).
19 - Information can be filtered by O(organization) and O(name).
20 - If no filters are passed, all Multicast Policies will be returned.
21 extends_documentation_fragment: intersight
22 options:
23 organization:
24 description:
25 - The name of the organization the Multicast Policy belongs to.
26 type: str
27 name:
28 description:
29 - The name of the Multicast Policy to gather information from.
30 type: str
31 author:
32 - Ron Gershburg (@rgershbu)
33 '''
34
35 EXAMPLES = r'''
36 - name: Fetch a specific Multicast Policy by name
37 cisco.intersight.intersight_multicast_policy_info:
38 api_private_key: "{{ api_private_key }}"
39 api_key_id: "{{ api_key_id }}"
40 name: "Multicast-Policy-Querier"
41
42 - name: Fetch all Multicast Policies in a specific Organization
43 cisco.intersight.intersight_multicast_policy_info:
44 api_private_key: "{{ api_private_key }}"
45 api_key_id: "{{ api_key_id }}"
46 organization: "default"
47
48 - name: Fetch all Multicast Policies
49 cisco.intersight.intersight_multicast_policy_info:
50 api_private_key: "{{ api_private_key }}"
51 api_key_id: "{{ api_key_id }}"
52 '''
53
54 RETURN = r'''
55 api_response:
56 description: The API response output returned by the specified resource.
57 returned: always
58 type: dict
59 sample:
60 "api_response": [
61 {
62 "Name": "multicast_policy_1",
63 "ObjectType": "fabric.MulticastPolicy",
64 "QuerierState": "Enabled",
65 "SnoopingState": "Enabled",
66 "QuerierIpAddress": "192.168.1.1",
67 "QuerierIpAddressPeer": "192.168.1.2",
68 "SrcIpProxy": "Enabled",
69 "Tags": [
70 {
71 "Key": "Site",
72 "Value": "DataCenter-A"
73 }
74 ]
75 },
76 {
77 "Name": "multicast_policy_2",
78 "ObjectType": "fabric.MulticastPolicy",
79 "QuerierState": "Disabled",
80 "SnoopingState": "Enabled",
81 "SrcIpProxy": "Disabled",
82 "Tags": [
83 {
84 "Key": "Environment",
85 "Value": "Production"
86 }
87 ]
88 }
89 ]
90 '''
91
92
93 from ansible.module_utils.basic import AnsibleModule
94 from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec
95
96
97 def main():
98 argument_spec = intersight_argument_spec.copy()
99 argument_spec.update(
100 organization=dict(type='str'),
101 name=dict(type='str')
102 )
103 module = AnsibleModule(
104 argument_spec,
105 supports_check_mode=True,
106 )
107
108 intersight = IntersightModule(module)
109 intersight.result['api_response'] = {}
110 intersight.result['trace_id'] = ''
111
112 # Resource path used to fetch info
113 resource_path = '/fabric/MulticastPolicies'
114
115 query_params = intersight.set_query_params()
116
117 intersight.get_resource(
118 resource_path=resource_path,
119 query_params=query_params,
120 return_list=True
121 )
122
123 module.exit_json(**intersight.result)
124
125
126 if __name__ == '__main__':
127 main()