Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_lldpprofile.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_switchcontroller_lldpprofile
15 short_description: Configure FortiSwitch LLDP profiles.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 switchcontroller_lldpprofile:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 802_1_tlvs:
34 aliases: ['802.1-tlvs']
35 type: list
36 elements: str
37 description: Transmitted IEEE 802.
38 choices: ['port-vlan-id']
39 802_3_tlvs:
40 aliases: ['802.3-tlvs']
41 type: list
42 elements: str
43 description: Transmitted IEEE 802.
44 choices: ['max-frame-size', 'power-negotiation']
45 auto_isl:
46 aliases: ['auto-isl']
47 type: str
48 description: Enable/disable auto inter-switch LAG.
49 choices: ['disable', 'enable']
50 auto_isl_hello_timer:
51 aliases: ['auto-isl-hello-timer']
52 type: int
53 description: Auto inter-switch LAG hello timer duration
54 auto_isl_port_group:
55 aliases: ['auto-isl-port-group']
56 type: int
57 description: Auto inter-switch LAG port group ID
58 auto_isl_receive_timeout:
59 aliases: ['auto-isl-receive-timeout']
60 type: int
61 description: Auto inter-switch LAG timeout if no response is received
62 custom_tlvs:
63 aliases: ['custom-tlvs']
64 type: list
65 elements: dict
66 description: Custom tlvs.
67 suboptions:
68 information_string:
69 aliases: ['information-string']
70 type: str
71 description: Organizationally defined information string
72 name:
73 type: str
74 description: TLV name
75 oui:
76 type: str
77 description: Organizationally unique identifier
78 subtype:
79 type: int
80 description: Organizationally defined subtype
81 med_network_policy:
82 aliases: ['med-network-policy']
83 type: list
84 elements: dict
85 description: Med network policy.
86 suboptions:
87 dscp:
88 type: int
89 description: Advertised Differentiated Services Code Point
90 name:
91 type: str
92 description: Policy type name.
93 priority:
94 type: int
95 description: Advertised Layer 2 priority
96 status:
97 type: str
98 description: Enable or disable this TLV.
99 choices: ['disable', 'enable']
100 vlan:
101 type: int
102 description: ID of VLAN to advertise, if configured on port
103 vlan_intf:
104 aliases: ['vlan-intf']
105 type: str
106 description: VLAN interface to advertise; if configured on port.
107 assign_vlan:
108 aliases: ['assign-vlan']
109 type: str
110 description: Enable/disable VLAN assignment when this profile is applied on managed FortiSwitch port.
111 choices: ['disable', 'enable']
112 med_tlvs:
113 aliases: ['med-tlvs']
114 type: list
115 elements: str
116 description: Transmitted LLDP-MED TLVs
117 choices: ['inventory-management', 'network-policy', 'power-management',
118 'location-identification']
119 name:
120 type: str
121 description: Profile name.
122 required: true
123 med_location_service:
124 aliases: ['med-location-service']
125 type: list
126 elements: dict
127 description: Med location service.
128 suboptions:
129 name:
130 type: str
131 description: Location service type name.
132 status:
133 type: str
134 description: Enable or disable this TLV.
135 choices: ['disable', 'enable']
136 sys_location_id:
137 aliases: ['sys-location-id']
138 type: str
139 description: Location service ID.
140 auto_mclag_icl:
141 aliases: ['auto-mclag-icl']
142 type: str
143 description: Enable/disable MCLAG inter chassis link.
144 choices: ['disable', 'enable']
145 auto_isl_auth:
146 aliases: ['auto-isl-auth']
147 type: str
148 description: Auto inter-switch LAG authentication mode.
149 choices: ['legacy', 'strict', 'relax']
150 auto_isl_auth_encrypt:
151 aliases: ['auto-isl-auth-encrypt']
152 type: str
153 description: Auto inter-switch LAG encryption mode.
154 choices: ['none', 'mixed', 'must']
155 auto_isl_auth_identity:
156 aliases: ['auto-isl-auth-identity']
157 type: str
158 description: Auto inter-switch LAG authentication identity.
159 auto_isl_auth_macsec_profile:
160 aliases: ['auto-isl-auth-macsec-profile']
161 type: str
162 description: Auto inter-switch LAG macsec profile for encryption.
163 auto_isl_auth_reauth:
164 aliases: ['auto-isl-auth-reauth']
165 type: int
166 description: Auto inter-switch LAG authentication reauth period in seconds
167 auto_isl_auth_user:
168 aliases: ['auto-isl-auth-user']
169 type: str
170 description: Auto inter-switch LAG authentication user certificate.
171 '''
172
173 EXAMPLES = '''
174 - name: Example playbook (generated based on argument schema)
175 hosts: fortimanagers
176 connection: httpapi
177 gather_facts: false
178 tasks:
179 - name: Configure FortiSwitch LLDP profiles.
180 fortinet.fortimanager.fmgr_switchcontroller_lldpprofile:
181 # workspace_locking_adom: <global or your adom name>
182 adom: <your own value>
183 state: present # <value in [present, absent]>
184 switchcontroller_lldpprofile:
185 name: "your value" # Required variable, string
186 # 802_1_tlvs: ["port-vlan-id"]
187 # 802_3_tlvs: ["max-frame-size", "power-negotiation"]
188 # auto_isl: <value in [disable, enable]>
189 # auto_isl_hello_timer: <integer>
190 # auto_isl_port_group: <integer>
191 # auto_isl_receive_timeout: <integer>
192 # custom_tlvs:
193 # - information_string: <string>
194 # name: <string>
195 # oui: <string>
196 # subtype: <integer>
197 # med_network_policy:
198 # - dscp: <integer>
199 # name: <string>
200 # priority: <integer>
201 # status: <value in [disable, enable]>
202 # vlan: <integer>
203 # vlan_intf: <string>
204 # assign_vlan: <value in [disable, enable]>
205 # med_tlvs: ["inventory-management", "network-policy", "power-management",
206 # "location-identification"]
207 # med_location_service:
208 # - name: <string>
209 # status: <value in [disable, enable]>
210 # sys_location_id: <string>
211 # auto_mclag_icl: <value in [disable, enable]>
212 # auto_isl_auth: <value in [legacy, strict, relax]>
213 # auto_isl_auth_encrypt: <value in [none, mixed, must]>
214 # auto_isl_auth_identity: <string>
215 # auto_isl_auth_macsec_profile: <string>
216 # auto_isl_auth_reauth: <integer>
217 # auto_isl_auth_user: <string>
218 '''
219
220 RETURN = '''
221 meta:
222 description: The result of the request.
223 type: dict
224 returned: always
225 contains:
226 request_url:
227 description: The full url requested.
228 returned: always
229 type: str
230 sample: /sys/login/user
231 response_code:
232 description: The status of api request.
233 returned: always
234 type: int
235 sample: 0
236 response_data:
237 description: The api response.
238 type: list
239 returned: always
240 response_message:
241 description: The descriptive message of the api response.
242 type: str
243 returned: always
244 sample: OK.
245 system_information:
246 description: The information of the target system.
247 type: dict
248 returned: always
249 rc:
250 description: The status the request.
251 type: int
252 returned: always
253 sample: 0
254 version_check_warning:
255 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
256 type: list
257 returned: complex
258 '''
259 from ansible.module_utils.basic import AnsibleModule
260 from ansible.module_utils.connection import Connection
261 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
262 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
263
264
265 def main():
266 urls_list = [
267 '/pm/config/adom/{adom}/obj/switch-controller/lldp-profile',
268 '/pm/config/global/obj/switch-controller/lldp-profile'
269 ]
270 module_arg_spec = {
271 'adom': {'required': True, 'type': 'str'},
272 'revision_note': {'type': 'str'},
273 'switchcontroller_lldpprofile': {
274 'type': 'dict', 'v_range': [['6.0.0', '']],
275 'options': {
276 '802.1-tlvs': {'type': 'list', 'choices': ['port-vlan-id'], 'elements': 'str'},
277 '802.3-tlvs': {'type': 'list', 'choices': ['max-frame-size', 'power-negotiation'], 'elements': 'str'},
278 'auto-isl': {'choices': ['disable', 'enable'], 'type': 'str'},
279 'auto-isl-hello-timer': {'type': 'int'},
280 'auto-isl-port-group': {'type': 'int'},
281 'auto-isl-receive-timeout': {'type': 'int'},
282 'custom-tlvs': {
283 'type': 'list',
284 'options': {'information-string': {'type': 'str'}, 'name': {'type': 'str'}, 'oui': {'type': 'str'}, 'subtype': {'type': 'int'}},
285 'elements': 'dict'
286 },
287 'med-network-policy': {
288 'type': 'list',
289 'options': {
290 'dscp': {'type': 'int'},
291 'name': {'type': 'str'},
292 'priority': {'type': 'int'},
293 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
294 'vlan': {'type': 'int'},
295 'vlan-intf': {'v_range': [['6.2.0', '']], 'type': 'str'},
296 'assign-vlan': {'v_range': [['6.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
297 },
298 'elements': 'dict'
299 },
300 'med-tlvs': {
301 'type': 'list',
302 'choices': ['inventory-management', 'network-policy', 'power-management', 'location-identification'],
303 'elements': 'str'
304 },
305 'name': {'required': True, 'type': 'str'},
306 'med-location-service': {
307 'v_range': [['6.2.0', '']],
308 'type': 'list',
309 'options': {
310 'name': {'v_range': [['6.2.0', '']], 'type': 'str'},
311 'status': {'v_range': [['6.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
312 'sys-location-id': {'v_range': [['6.2.0', '']], 'type': 'str'}
313 },
314 'elements': 'dict'
315 },
316 'auto-mclag-icl': {'v_range': [['6.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
317 'auto-isl-auth': {'v_range': [['7.4.1', '']], 'choices': ['legacy', 'strict', 'relax'], 'type': 'str'},
318 'auto-isl-auth-encrypt': {'v_range': [['7.4.1', '']], 'choices': ['none', 'mixed', 'must'], 'type': 'str'},
319 'auto-isl-auth-identity': {'v_range': [['7.4.1', '']], 'type': 'str'},
320 'auto-isl-auth-macsec-profile': {'v_range': [['7.4.1', '']], 'type': 'str'},
321 'auto-isl-auth-reauth': {'v_range': [['7.4.1', '']], 'type': 'int'},
322 'auto-isl-auth-user': {'v_range': [['7.4.1', '']], 'type': 'str'}
323 }
324 }
325 }
326
327 module_option_spec = get_module_arg_spec('full crud')
328 module_arg_spec.update(module_option_spec)
329 check_galaxy_version(module_arg_spec)
330 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_lldpprofile'),
331 supports_check_mode=True)
332 if not module._socket_path:
333 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
334 connection = Connection(module._socket_path)
335 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
336 'name', 'data', module, connection)
337 fmgr.process_crud()
338 module.exit_json(meta=module.params)
339
340
341 if __name__ == '__main__':
342 main()