Debian Codegraph @

ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_facts.py

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
4 # GNU General Public License v3.0+
5 # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6 """
7 The module file for sonic_facts
8 """
9
10 from __future__ import absolute_import, division, print_function
11 __metaclass__ = type
12
13 DOCUMENTATION = """
14 ---
15 module: sonic_facts
16 version_added: 1.0.0
17 notes:
18 - Tested against Enterprise SONiC Distribution by Dell Technologies.
19 - Supports C(check_mode).
20 short_description: Collects facts on devices running Enterprise SONiC
21 description:
22 - Collects facts from devices running Enterprise SONiC Distribution by
23 Dell Technologies. This module places the facts gathered in the fact tree
24 keyed by the respective resource name. The facts module always collects
25 a base set of facts from the device and can enable or disable collection
26 of additional facts.
27 author:
28 - Mohamed Javeed (@javeedf)
29 - Abirami N (@abirami-n)
30 options:
31 gather_subset:
32 description:
33 - When supplied, this argument restricts the facts collected
34 to a given subset. Possible values for this argument include
35 all, min, hardware, config, legacy, and interfaces. Can specify a
36 list of values to include a larger subset. Values can also be used
37 with an initial '!' to specify that a specific subset should
38 not be collected.
39 required: false
40 type: list
41 elements: str
42 default: '!config'
43 gather_network_resources:
44 description:
45 - When supplied, this argument restricts the facts collected
46 to a given subset. Possible values for this argument include
47 all and the resources like 'all', 'interfaces', 'vlans', 'lag_interfaces', 'l2_interfaces', 'l3_interfaces'.
48 Can specify a list of values to include a larger subset. Values
49 can also be used with an initial '!' to specify that a
50 specific subset should not be collected.
51 required: false
52 type: list
53 elements: str
54 choices:
55 - all
56 - vlans
57 - interfaces
58 - l2_interfaces
59 - l3_interfaces
60 - ipv6_router_advertisement
61 - lag_interfaces
62 - bgp
63 - bgp_af
64 - bgp_neighbors
65 - bgp_neighbors_af
66 - bgp_as_paths
67 - bgp_communities
68 - bgp_ext_communities
69 - ospfv2_interfaces
70 - ospfv2
71 - ospfv3
72 - ospfv3_area
73 - ospfv3_interfaces
74 - mclag
75 - prefix_lists
76 - vlan_mapping
77 - vrfs
78 - vrrp
79 - vxlans
80 - users
81 - system
82 - port_breakout
83 - pms
84 - aaa
85 - ldap
86 - tacacs_server
87 - radius_server
88 - static_routes
89 - ntp
90 - logging
91 - pki
92 - ip_neighbor
93 - ip_neighbor_interfaces
94 - port_group
95 - dhcp_relay
96 - acl_interfaces
97 - l2_acls
98 - l3_acls
99 - lldp_global
100 - ptp_default_ds
101 - mac
102 - bfd
103 - copp
104 - route_maps
105 - lldp_interfaces
106 - stp
107 - poe
108 - dhcp_snooping
109 - sflow
110 - fips
111 - roce
112 - qos_buffer
113 - qos_pfc
114 - qos_maps
115 - qos_scheduler
116 - qos_wred
117 - qos_interfaces
118 - pim_global
119 - pim_interfaces
120 - login_lockout
121 - mgmt_servers
122 - ospf_area
123 - ssh
124 - lst
125 - ptp_port_ds
126 - fbs_classifiers
127 - fbs_groups
128 - fbs_policies
129 - ars
130 - network_policy
131 - br_l2pt
132 - dcbx
133 - mirroring
134 - mfa
135 - drop_counter
136 - evpn_esi_multihome
137 - ssh_server
138 - ecmp_load_share
139 - fbs_interfaces
140 """
141
142 EXAMPLES = """
143 - name: Gather all facts
144 dellemc.enterprise_sonic.sonic_facts:
145 gather_subset: all
146 gather_network_resources: all
147 - name: Collects VLAN and interfaces facts
148 dellemc.enterprise_sonic.sonic_facts:
149 gather_subset:
150 - min
151 gather_network_resources:
152 - vlans
153 - interfaces
154 - name: Do not collects VLAN and interfaces facts
155 dellemc.enterprise_sonic.sonic_facts:
156 gather_network_resources:
157 - "!vlans"
158 - "!interfaces"
159 - name: Collects VLAN and minimal default facts
160 dellemc.enterprise_sonic.sonic_facts:
161 gather_subset: min
162 gather_network_resources: vlans
163 - name: Collect lag_interfaces and minimal default facts
164 dellemc.enterprise_sonic.sonic_facts:
165 gather_subset: min
166 gather_network_resources: lag_interfaces
167 """
168
169 RETURN = """
170 """
171
172 from ansible.module_utils.basic import AnsibleModule
173 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.facts.facts import FactsArgs
174 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.facts.facts import Facts
175
176
177 def main():
178 """
179 Main entry point for module execution
180 :returns: ansible_facts
181 """
182 module = AnsibleModule(argument_spec=FactsArgs.argument_spec,
183 supports_check_mode=True)
184 warnings = ['default value for `gather_subset` '
185 'will be changed to `min` from `!config` v2.11 onwards']
186
187 result = Facts(module).get_facts()
188
189 ansible_facts, additional_warnings = result
190 warnings.extend(additional_warnings)
191
192 module.exit_json(ansible_facts=ansible_facts, warnings=warnings)
193
194
195 if __name__ == '__main__':
196 main()