Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_managedswitch_routerstatic.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_managedswitch_routerstatic
15 short_description: Configure static routes.
16 version_added: "2.12.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 managed-switch:
29 description: Deprecated, please use "managed_switch"
30 type: str
31 managed_switch:
32 description: The parameter (managed-switch) in requested url.
33 type: str
34 switchcontroller_managedswitch_routerstatic:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 blackhole:
40 type: str
41 description: Enable/disable blackhole on this route.
42 choices: ['disable', 'enable']
43 comment:
44 type: str
45 description: Comment.
46 device:
47 type: list
48 elements: str
49 description: Gateway out interface.
50 distance:
51 type: int
52 description: Administrative distance for the route
53 dst:
54 type: list
55 elements: str
56 description: Destination ip and mask for this route.
57 dynamic_gateway:
58 aliases: ['dynamic-gateway']
59 type: str
60 description: Enable/disable dynamic gateway.
61 choices: ['disable', 'enable']
62 gateway:
63 type: str
64 description: Gateway ip for this route.
65 id:
66 type: int
67 description: Entry sequence number.
68 required: true
69 status:
70 type: str
71 description: Enable/disable route status.
72 choices: ['disable', 'enable']
73 switch_id:
74 aliases: ['switch-id']
75 type: list
76 elements: str
77 description: Switch ID.
78 vrf:
79 type: list
80 elements: str
81 description: VRF for this route.
82 '''
83
84 EXAMPLES = '''
85 - name: Example playbook (generated based on argument schema)
86 hosts: fortimanagers
87 connection: httpapi
88 gather_facts: false
89 tasks:
90 - name: Configure static routes.
91 fortinet.fortimanager.fmgr_switchcontroller_managedswitch_routerstatic:
92 # workspace_locking_adom: <global or your adom name>
93 adom: <your own value>
94 managed_switch: <your own value>
95 state: present # <value in [present, absent]>
96 switchcontroller_managedswitch_routerstatic:
97 id: 0 # Required variable, integer
98 # blackhole: <value in [disable, enable]>
99 # comment: <string>
100 # device: <list or string>
101 # distance: <integer>
102 # dst: <list or string>
103 # dynamic_gateway: <value in [disable, enable]>
104 # gateway: <string>
105 # status: <value in [disable, enable]>
106 # switch_id: <list or string>
107 # vrf: <list or string>
108 '''
109
110 RETURN = '''
111 meta:
112 description: The result of the request.
113 type: dict
114 returned: always
115 contains:
116 request_url:
117 description: The full url requested.
118 returned: always
119 type: str
120 sample: /sys/login/user
121 response_code:
122 description: The status of api request.
123 returned: always
124 type: int
125 sample: 0
126 response_data:
127 description: The api response.
128 type: list
129 returned: always
130 response_message:
131 description: The descriptive message of the api response.
132 type: str
133 returned: always
134 sample: OK.
135 system_information:
136 description: The information of the target system.
137 type: dict
138 returned: always
139 rc:
140 description: The status the request.
141 type: int
142 returned: always
143 sample: 0
144 version_check_warning:
145 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
146 type: list
147 returned: complex
148 '''
149 from ansible.module_utils.basic import AnsibleModule
150 from ansible.module_utils.connection import Connection
151 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
152 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
153
154
155 def main():
156 urls_list = [
157 '/pm/config/adom/{adom}/obj/switch-controller/managed-switch/{managed-switch}/router-static'
158 ]
159 module_arg_spec = {
160 'adom': {'required': True, 'type': 'str'},
161 'managed-switch': {'type': 'str', 'api_name': 'managed_switch'},
162 'managed_switch': {'type': 'str'},
163 'revision_note': {'type': 'str'},
164 'switchcontroller_managedswitch_routerstatic': {
165 'type': 'dict', 'v_range': [['7.6.4', '']],
166 'options': {
167 'blackhole': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
168 'comment': {'v_range': [['7.6.4', '']], 'type': 'str'},
169 'device': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'},
170 'distance': {'v_range': [['7.6.4', '']], 'type': 'int'},
171 'dst': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'},
172 'dynamic-gateway': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
173 'gateway': {'v_range': [['7.6.4', '']], 'type': 'str'},
174 'id': {'v_range': [['7.6.4', '']], 'required': True, 'type': 'int'},
175 'status': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
176 'switch-id': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'},
177 'vrf': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'}
178 }
179 }
180 }
181
182 module_option_spec = get_module_arg_spec('full crud')
183 module_arg_spec.update(module_option_spec)
184 check_galaxy_version(module_arg_spec)
185 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_managedswitch_routerstatic'),
186 supports_check_mode=True)
187 if not module._socket_path:
188 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
189 connection = Connection(module._socket_path)
190 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
191 'id', 'data', module, connection)
192 fmgr.process_crud()
193 module.exit_json(meta=module.params)
194
195
196 if __name__ == '__main__':
197 main()