Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_router_routemap_rule.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_router_routemap_rule
15 short_description: Rule.
16 version_added: "2.1.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 route-map:
29 description: Deprecated, please use "route_map"
30 type: str
31 route_map:
32 description: The parameter (route-map) in requested url.
33 type: str
34 router_routemap_rule:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 action:
40 type: str
41 description: Action.
42 choices: ['permit', 'deny']
43 id:
44 type: int
45 description: Rule ID.
46 required: true
47 match_as_path:
48 aliases: ['match-as-path']
49 type: str
50 description: Match BGP AS path list.
51 match_community:
52 aliases: ['match-community']
53 type: str
54 description: Match BGP community list.
55 match_community_exact:
56 aliases: ['match-community-exact']
57 type: str
58 description: Enable/disable exact matching of communities.
59 choices: ['disable', 'enable']
60 match_flags:
61 aliases: ['match-flags']
62 type: int
63 description: Match flags.
64 match_interface:
65 aliases: ['match-interface']
66 type: str
67 description: Match interface configuration.
68 match_ip_address:
69 aliases: ['match-ip-address']
70 type: str
71 description: Match IP address permitted by access-list or prefix-list.
72 match_ip_nexthop:
73 aliases: ['match-ip-nexthop']
74 type: str
75 description: Match next hop IP address passed by access-list or prefix-list.
76 match_ip6_address:
77 aliases: ['match-ip6-address']
78 type: str
79 description: Match IPv6 address permitted by access-list6 or prefix-list6.
80 match_ip6_nexthop:
81 aliases: ['match-ip6-nexthop']
82 type: str
83 description: Match next hop IPv6 address passed by access-list6 or prefix-list6.
84 match_metric:
85 aliases: ['match-metric']
86 type: str
87 description: Match metric for redistribute routes.
88 match_origin:
89 aliases: ['match-origin']
90 type: str
91 description: Match BGP origin code.
92 choices: ['none', 'egp', 'igp', 'incomplete']
93 match_route_type:
94 aliases: ['match-route-type']
95 type: str
96 description: Match route type.
97 choices: ['1', '2', 'none', 'external-type1', 'external-type2']
98 match_tag:
99 aliases: ['match-tag']
100 type: str
101 description: Match tag.
102 match_vrf:
103 aliases: ['match-vrf']
104 type: int
105 description: Match VRF ID.
106 set_aggregator_as:
107 aliases: ['set-aggregator-as']
108 type: int
109 description: BGP aggregator AS.
110 set_aggregator_ip:
111 aliases: ['set-aggregator-ip']
112 type: str
113 description: BGP aggregator IP.
114 set_aspath:
115 aliases: ['set-aspath']
116 type: raw
117 description: (list) Prepend BGP AS path attribute.
118 set_aspath_action:
119 aliases: ['set-aspath-action']
120 type: str
121 description: Specify preferred action of set-aspath.
122 choices: ['prepend', 'replace']
123 set_atomic_aggregate:
124 aliases: ['set-atomic-aggregate']
125 type: str
126 description: Enable/disable BGP atomic aggregate attribute.
127 choices: ['disable', 'enable']
128 set_community:
129 aliases: ['set-community']
130 type: raw
131 description: (list) BGP community attribute.
132 set_community_additive:
133 aliases: ['set-community-additive']
134 type: str
135 description: Enable/disable adding set-community to existing community.
136 choices: ['disable', 'enable']
137 set_community_delete:
138 aliases: ['set-community-delete']
139 type: str
140 description: Delete communities matching community list.
141 set_dampening_max_suppress:
142 aliases: ['set-dampening-max-suppress']
143 type: int
144 description: Maximum duration to suppress a route
145 set_dampening_reachability_half_life:
146 aliases: ['set-dampening-reachability-half-life']
147 type: int
148 description: Reachability half-life time for the penalty
149 set_dampening_reuse:
150 aliases: ['set-dampening-reuse']
151 type: int
152 description: Value to start reusing a route
153 set_dampening_suppress:
154 aliases: ['set-dampening-suppress']
155 type: int
156 description: Value to start suppressing a route
157 set_dampening_unreachability_half_life:
158 aliases: ['set-dampening-unreachability-half-life']
159 type: int
160 description: Unreachability Half-life time for the penalty
161 set_extcommunity_rt:
162 aliases: ['set-extcommunity-rt']
163 type: raw
164 description: (list) Route Target extended community.
165 set_extcommunity_soo:
166 aliases: ['set-extcommunity-soo']
167 type: raw
168 description: (list) Site-of-Origin extended community.
169 set_flags:
170 aliases: ['set-flags']
171 type: int
172 description: Set flags.
173 set_ip_nexthop:
174 aliases: ['set-ip-nexthop']
175 type: str
176 description: IP address of next hop.
177 set_ip6_nexthop:
178 aliases: ['set-ip6-nexthop']
179 type: str
180 description: IPv6 global address of next hop.
181 set_ip6_nexthop_local:
182 aliases: ['set-ip6-nexthop-local']
183 type: str
184 description: IPv6 local address of next hop.
185 set_local_preference:
186 aliases: ['set-local-preference']
187 type: str
188 description: BGP local preference path attribute.
189 set_metric:
190 aliases: ['set-metric']
191 type: str
192 description: Metric value.
193 set_metric_type:
194 aliases: ['set-metric-type']
195 type: str
196 description: Metric type.
197 choices: ['1', '2', 'none', 'external-type1', 'external-type2']
198 set_origin:
199 aliases: ['set-origin']
200 type: str
201 description: BGP origin code.
202 choices: ['none', 'egp', 'igp', 'incomplete']
203 set_originator_id:
204 aliases: ['set-originator-id']
205 type: str
206 description: BGP originator ID attribute.
207 set_priority:
208 aliases: ['set-priority']
209 type: int
210 description: Priority for routing table.
211 set_route_tag:
212 aliases: ['set-route-tag']
213 type: str
214 description: Route tag for routing table.
215 set_tag:
216 aliases: ['set-tag']
217 type: str
218 description: Tag value.
219 set_weight:
220 aliases: ['set-weight']
221 type: str
222 description: BGP weight for routing table.
223 match_extcommunity:
224 aliases: ['match-extcommunity']
225 type: str
226 description: Match BGP extended community list.
227 match_extcommunity_exact:
228 aliases: ['match-extcommunity-exact']
229 type: str
230 description: Enable/disable exact matching of extended communities.
231 choices: ['disable', 'enable']
232 set_ip_prefsrc:
233 aliases: ['set-ip-prefsrc']
234 type: str
235 description: IP address of preferred source.
236 set_vpnv4_nexthop:
237 aliases: ['set-vpnv4-nexthop']
238 type: str
239 description: IP address of VPNv4 next-hop.
240 set_vpnv6_nexthop:
241 aliases: ['set-vpnv6-nexthop']
242 type: str
243 description: IPv6 global address of VPNv6 next-hop.
244 set_vpnv6_nexthop_local:
245 aliases: ['set-vpnv6-nexthop-local']
246 type: str
247 description: IPv6 link-local address of VPNv6 next-hop.
248 match_suppress:
249 aliases: ['match-suppress']
250 type: str
251 description: Enable/disable matching of suppressed original neighbor.
252 choices: ['disable', 'enable']
253 '''
254
255 EXAMPLES = '''
256 - name: Example playbook (generated based on argument schema)
257 hosts: fortimanagers
258 connection: httpapi
259 gather_facts: false
260 tasks:
261 - name: Rule.
262 fortinet.fortimanager.fmgr_router_routemap_rule:
263 # workspace_locking_adom: <global or your adom name>
264 adom: <your own value>
265 route_map: <your own value>
266 state: present # <value in [present, absent]>
267 router_routemap_rule:
268 id: 0 # Required variable, integer
269 # action: <value in [permit, deny]>
270 # match_as_path: <string>
271 # match_community: <string>
272 # match_community_exact: <value in [disable, enable]>
273 # match_flags: <integer>
274 # match_interface: <string>
275 # match_ip_address: <string>
276 # match_ip_nexthop: <string>
277 # match_ip6_address: <string>
278 # match_ip6_nexthop: <string>
279 # match_metric: <string>
280 # match_origin: <value in [none, egp, igp, ...]>
281 # match_route_type: <value in [1, 2, none, ...]>
282 # match_tag: <string>
283 # match_vrf: <integer>
284 # set_aggregator_as: <integer>
285 # set_aggregator_ip: <string>
286 # set_aspath: <list or string>
287 # set_aspath_action: <value in [prepend, replace]>
288 # set_atomic_aggregate: <value in [disable, enable]>
289 # set_community: <list or string>
290 # set_community_additive: <value in [disable, enable]>
291 # set_community_delete: <string>
292 # set_dampening_max_suppress: <integer>
293 # set_dampening_reachability_half_life: <integer>
294 # set_dampening_reuse: <integer>
295 # set_dampening_suppress: <integer>
296 # set_dampening_unreachability_half_life: <integer>
297 # set_extcommunity_rt: <list or string>
298 # set_extcommunity_soo: <list or string>
299 # set_flags: <integer>
300 # set_ip_nexthop: <string>
301 # set_ip6_nexthop: <string>
302 # set_ip6_nexthop_local: <string>
303 # set_local_preference: <string>
304 # set_metric: <string>
305 # set_metric_type: <value in [1, 2, none, ...]>
306 # set_origin: <value in [none, egp, igp, ...]>
307 # set_originator_id: <string>
308 # set_priority: <integer>
309 # set_route_tag: <string>
310 # set_tag: <string>
311 # set_weight: <string>
312 # match_extcommunity: <string>
313 # match_extcommunity_exact: <value in [disable, enable]>
314 # set_ip_prefsrc: <string>
315 # set_vpnv4_nexthop: <string>
316 # set_vpnv6_nexthop: <string>
317 # set_vpnv6_nexthop_local: <string>
318 # match_suppress: <value in [disable, enable]>
319 '''
320
321 RETURN = '''
322 meta:
323 description: The result of the request.
324 type: dict
325 returned: always
326 contains:
327 request_url:
328 description: The full url requested.
329 returned: always
330 type: str
331 sample: /sys/login/user
332 response_code:
333 description: The status of api request.
334 returned: always
335 type: int
336 sample: 0
337 response_data:
338 description: The api response.
339 type: list
340 returned: always
341 response_message:
342 description: The descriptive message of the api response.
343 type: str
344 returned: always
345 sample: OK.
346 system_information:
347 description: The information of the target system.
348 type: dict
349 returned: always
350 rc:
351 description: The status the request.
352 type: int
353 returned: always
354 sample: 0
355 version_check_warning:
356 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
357 type: list
358 returned: complex
359 '''
360 from ansible.module_utils.basic import AnsibleModule
361 from ansible.module_utils.connection import Connection
362 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
363 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
364
365
366 def main():
367 urls_list = [
368 '/pm/config/adom/{adom}/obj/router/route-map/{route-map}/rule',
369 '/pm/config/global/obj/router/route-map/{route-map}/rule'
370 ]
371 module_arg_spec = {
372 'adom': {'required': True, 'type': 'str'},
373 'route-map': {'type': 'str', 'api_name': 'route_map'},
374 'route_map': {'type': 'str'},
375 'revision_note': {'type': 'str'},
376 'router_routemap_rule': {
377 'type': 'dict', 'v_range': [['7.0.2', '']],
378 'options': {
379 'action': {'v_range': [['7.0.2', '']], 'choices': ['permit', 'deny'], 'type': 'str'},
380 'id': {'v_range': [['7.0.2', '']], 'required': True, 'type': 'int'},
381 'match-as-path': {'v_range': [['7.0.2', '']], 'type': 'str'},
382 'match-community': {'v_range': [['7.0.2', '']], 'type': 'str'},
383 'match-community-exact': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
384 'match-flags': {'v_range': [['7.0.2', '']], 'type': 'int'},
385 'match-interface': {'v_range': [['7.0.2', '']], 'type': 'str'},
386 'match-ip-address': {'v_range': [['7.0.2', '']], 'type': 'str'},
387 'match-ip-nexthop': {'v_range': [['7.0.2', '']], 'type': 'str'},
388 'match-ip6-address': {'v_range': [['7.0.2', '']], 'type': 'str'},
389 'match-ip6-nexthop': {'v_range': [['7.0.2', '']], 'type': 'str'},
390 'match-metric': {'v_range': [['7.0.2', '']], 'type': 'str'},
391 'match-origin': {'v_range': [['7.0.2', '']], 'choices': ['none', 'egp', 'igp', 'incomplete'], 'type': 'str'},
392 'match-route-type': {'v_range': [['7.0.2', '']], 'choices': ['1', '2', 'none', 'external-type1', 'external-type2'], 'type': 'str'},
393 'match-tag': {'v_range': [['7.0.2', '']], 'type': 'str'},
394 'match-vrf': {'v_range': [['7.0.2', '']], 'type': 'int'},
395 'set-aggregator-as': {'v_range': [['7.0.2', '']], 'type': 'int'},
396 'set-aggregator-ip': {'v_range': [['7.0.2', '']], 'type': 'str'},
397 'set-aspath': {'v_range': [['7.0.2', '']], 'type': 'raw'},
398 'set-aspath-action': {'v_range': [['7.0.2', '']], 'choices': ['prepend', 'replace'], 'type': 'str'},
399 'set-atomic-aggregate': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
400 'set-community': {'v_range': [['7.0.2', '']], 'type': 'raw'},
401 'set-community-additive': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
402 'set-community-delete': {'v_range': [['7.0.2', '']], 'type': 'str'},
403 'set-dampening-max-suppress': {'v_range': [['7.0.2', '']], 'type': 'int'},
404 'set-dampening-reachability-half-life': {'v_range': [['7.0.2', '']], 'type': 'int'},
405 'set-dampening-reuse': {'v_range': [['7.0.2', '']], 'type': 'int'},
406 'set-dampening-suppress': {'v_range': [['7.0.2', '']], 'type': 'int'},
407 'set-dampening-unreachability-half-life': {'v_range': [['7.0.2', '']], 'type': 'int'},
408 'set-extcommunity-rt': {'v_range': [['7.0.2', '']], 'type': 'raw'},
409 'set-extcommunity-soo': {'v_range': [['7.0.2', '']], 'type': 'raw'},
410 'set-flags': {'v_range': [['7.0.2', '']], 'type': 'int'},
411 'set-ip-nexthop': {'v_range': [['7.0.2', '']], 'type': 'str'},
412 'set-ip6-nexthop': {'v_range': [['7.0.2', '']], 'type': 'str'},
413 'set-ip6-nexthop-local': {'v_range': [['7.0.2', '']], 'type': 'str'},
414 'set-local-preference': {'v_range': [['7.0.2', '']], 'type': 'str'},
415 'set-metric': {'v_range': [['7.0.2', '']], 'type': 'str'},
416 'set-metric-type': {'v_range': [['7.0.2', '']], 'choices': ['1', '2', 'none', 'external-type1', 'external-type2'], 'type': 'str'},
417 'set-origin': {'v_range': [['7.0.2', '']], 'choices': ['none', 'egp', 'igp', 'incomplete'], 'type': 'str'},
418 'set-originator-id': {'v_range': [['7.0.2', '']], 'type': 'str'},
419 'set-priority': {'v_range': [['7.2.0', '']], 'type': 'int'},
420 'set-route-tag': {'v_range': [['7.0.2', '']], 'type': 'str'},
421 'set-tag': {'v_range': [['7.0.2', '']], 'type': 'str'},
422 'set-weight': {'v_range': [['7.0.2', '']], 'type': 'str'},
423 'match-extcommunity': {'v_range': [['7.2.2', '']], 'type': 'str'},
424 'match-extcommunity-exact': {'v_range': [['7.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
425 'set-ip-prefsrc': {'v_range': [['7.4.0', '']], 'type': 'str'},
426 'set-vpnv4-nexthop': {'v_range': [['7.4.1', '']], 'type': 'str'},
427 'set-vpnv6-nexthop': {'v_range': [['7.4.2', '']], 'type': 'str'},
428 'set-vpnv6-nexthop-local': {'v_range': [['7.4.2', '']], 'type': 'str'},
429 'match-suppress': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
430 }
431 }
432 }
433
434 module_option_spec = get_module_arg_spec('full crud')
435 module_arg_spec.update(module_option_spec)
436 check_galaxy_version(module_arg_spec)
437 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'router_routemap_rule'),
438 supports_check_mode=True)
439 if not module._socket_path:
440 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
441 connection = Connection(module._socket_path)
442 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
443 'id', 'data', module, connection)
444 fmgr.process_crud()
445 module.exit_json(meta=module.params)
446
447
448 if __name__ == '__main__':
449 main()