Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_ippool_dynamicmapping.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_firewall_ippool_dynamicmapping
15 short_description: Configure IPv4 IP pools.
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 ippool:
29 description: The parameter (ippool) in requested url.
30 type: str
31 required: true
32 firewall_ippool_dynamicmapping:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 _scope:
38 type: list
39 elements: dict
40 description: Scope.
41 suboptions:
42 name:
43 type: str
44 description: Name.
45 vdom:
46 type: str
47 description: Vdom.
48 arp_intf:
49 aliases: ['arp-intf']
50 type: str
51 description: Arp intf.
52 arp_reply:
53 aliases: ['arp-reply']
54 type: str
55 description: Arp reply.
56 choices: ['disable', 'enable']
57 associated_interface:
58 aliases: ['associated-interface']
59 type: str
60 description: Associated interface.
61 block_size:
62 aliases: ['block-size']
63 type: int
64 description: Block size.
65 comments:
66 type: str
67 description: Comments.
68 endip:
69 type: str
70 description: Endip.
71 num_blocks_per_user:
72 aliases: ['num-blocks-per-user']
73 type: int
74 description: Num blocks per user.
75 pba_timeout:
76 aliases: ['pba-timeout']
77 type: int
78 description: Pba timeout.
79 permit_any_host:
80 aliases: ['permit-any-host']
81 type: str
82 description: Permit any host.
83 choices: ['disable', 'enable']
84 source_endip:
85 aliases: ['source-endip']
86 type: str
87 description: Source endip.
88 source_startip:
89 aliases: ['source-startip']
90 type: str
91 description: Source startip.
92 startip:
93 type: str
94 description: Startip.
95 type:
96 type: str
97 description: Type.
98 choices: ['overload', 'one-to-one', 'fixed-port-range', 'port-block-allocation',
99 'cgn-resource-allocation']
100 cgn_block_size:
101 aliases: ['cgn-block-size']
102 type: int
103 description: Cgn block size.
104 cgn_client_endip:
105 aliases: ['cgn-client-endip']
106 type: str
107 description: Cgn client endip.
108 cgn_client_startip:
109 aliases: ['cgn-client-startip']
110 type: str
111 description: Cgn client startip.
112 cgn_fixedalloc:
113 aliases: ['cgn-fixedalloc']
114 type: str
115 description: Cgn fixedalloc.
116 choices: ['disable', 'enable']
117 cgn_overload:
118 aliases: ['cgn-overload']
119 type: str
120 description: Cgn overload.
121 choices: ['disable', 'enable']
122 cgn_port_end:
123 aliases: ['cgn-port-end']
124 type: int
125 description: Cgn port end.
126 cgn_port_start:
127 aliases: ['cgn-port-start']
128 type: int
129 description: Cgn port start.
130 cgn_spa:
131 aliases: ['cgn-spa']
132 type: str
133 description: Cgn spa.
134 choices: ['disable', 'enable']
135 utilization_alarm_clear:
136 aliases: ['utilization-alarm-clear']
137 type: int
138 description: Utilization alarm clear.
139 utilization_alarm_raise:
140 aliases: ['utilization-alarm-raise']
141 type: int
142 description: Utilization alarm raise.
143 endport:
144 type: int
145 description: Final port number
146 port_per_user:
147 aliases: ['port-per-user']
148 type: int
149 description: Number of port for each user
150 startport:
151 type: int
152 description: First port number
153 add_nat64_route:
154 aliases: ['add-nat64-route']
155 type: str
156 description: Enable/disable adding NAT64 route.
157 choices: ['disable', 'enable']
158 cgn_client_ipv6shift:
159 aliases: ['cgn-client-ipv6shift']
160 type: int
161 description: IPv6 shift for fixed-allocation.
162 nat64:
163 type: str
164 description: Enable/disable NAT64.
165 choices: ['disable', 'enable']
166 subnet_broadcast_in_ippool:
167 aliases: ['subnet-broadcast-in-ippool']
168 type: str
169 description: Enable/disable inclusion of the subnetwork address and broadcast IP address in the NAT64 IP pool.
170 choices: ['disable', 'enable']
171 exclude_ip:
172 aliases: ['exclude-ip']
173 type: raw
174 description: (list) Exclude IPs x.
175 pba_interim_log:
176 aliases: ['pba-interim-log']
177 type: int
178 description: Port block allocation interim logging interval
179 client_prefix_length:
180 aliases: ['client-prefix-length']
181 type: int
182 description: Subnet length of a single deterministic NAT64 client
183 icmp_session_quota:
184 aliases: ['icmp-session-quota']
185 type: int
186 description: Maximum number of concurrent ICMP sessions allowed per client
187 privileged_port_use_pba:
188 aliases: ['privileged-port-use-pba']
189 type: str
190 description: Enable/disable selection of the external port from the port block allocation for NATing privileged ports
191 choices: ['disable', 'enable']
192 source_prefix6:
193 aliases: ['source-prefix6']
194 type: str
195 description: Source IPv6 network to be translated
196 tcp_session_quota:
197 aliases: ['tcp-session-quota']
198 type: int
199 description: Maximum number of concurrent TCP sessions allowed per client
200 udp_session_quota:
201 aliases: ['udp-session-quota']
202 type: int
203 description: Maximum number of concurrent UDP sessions allowed per client
204 '''
205
206 EXAMPLES = '''
207 - name: Example playbook
208 hosts: fortimanagers
209 gather_facts: false
210 connection: httpapi
211 vars:
212 ansible_httpapi_use_ssl: true
213 ansible_httpapi_validate_certs: false
214 ansible_httpapi_port: 443
215 tasks:
216 - name: Configure dynamic mappings of IPv4 IP pool
217 fortinet.fortimanager.fmgr_firewall_ippool_dynamicmapping:
218 bypass_validation: false
219 adom: ansible
220 ippool: "ansible-test" # name
221 state: present
222 firewall_ippool_dynamicmapping:
223 _scope:
224 - name: FGT_AWS # need a valid device name
225 vdom: root # need a valid vdom name under the device
226 comments: "ansible-comment"
227 endip: "222.222.222.253"
228 startip: "222.222.222.0"
229 type: overload # <value in [overload, one-to-one, fixed-port-range, ...]>
230
231 - name: Gathering fortimanager facts
232 hosts: fortimanagers
233 gather_facts: false
234 connection: httpapi
235 vars:
236 ansible_httpapi_use_ssl: true
237 ansible_httpapi_validate_certs: false
238 ansible_httpapi_port: 443
239 tasks:
240 - name: Retrieve all the dynamic mappings of IPv4 IP pool
241 fortinet.fortimanager.fmgr_fact:
242 facts:
243 selector: "firewall_ippool_dynamicmapping"
244 params:
245 adom: "ansible"
246 ippool: "ansible-test" # name
247 dynamic_mapping: "your_value"
248 '''
249
250 RETURN = '''
251 meta:
252 description: The result of the request.
253 type: dict
254 returned: always
255 contains:
256 request_url:
257 description: The full url requested.
258 returned: always
259 type: str
260 sample: /sys/login/user
261 response_code:
262 description: The status of api request.
263 returned: always
264 type: int
265 sample: 0
266 response_data:
267 description: The api response.
268 type: list
269 returned: always
270 response_message:
271 description: The descriptive message of the api response.
272 type: str
273 returned: always
274 sample: OK.
275 system_information:
276 description: The information of the target system.
277 type: dict
278 returned: always
279 rc:
280 description: The status the request.
281 type: int
282 returned: always
283 sample: 0
284 version_check_warning:
285 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
286 type: list
287 returned: complex
288 '''
289 from ansible.module_utils.basic import AnsibleModule
290 from ansible.module_utils.connection import Connection
291 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
292 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
293
294
295 def main():
296 urls_list = [
297 '/pm/config/adom/{adom}/obj/firewall/ippool/{ippool}/dynamic_mapping',
298 '/pm/config/global/obj/firewall/ippool/{ippool}/dynamic_mapping'
299 ]
300 module_arg_spec = {
301 'adom': {'required': True, 'type': 'str'},
302 'ippool': {'required': True, 'type': 'str'},
303 'revision_note': {'type': 'str'},
304 'firewall_ippool_dynamicmapping': {
305 'type': 'dict', 'v_range': [['6.0.0', '']],
306 'options': {
307 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
308 'arp-intf': {'type': 'str'},
309 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
310 'associated-interface': {'type': 'str'},
311 'block-size': {'type': 'int'},
312 'comments': {'type': 'str'},
313 'endip': {'type': 'str'},
314 'num-blocks-per-user': {'type': 'int'},
315 'pba-timeout': {'type': 'int'},
316 'permit-any-host': {'choices': ['disable', 'enable'], 'type': 'str'},
317 'source-endip': {'type': 'str'},
318 'source-startip': {'type': 'str'},
319 'startip': {'type': 'str'},
320 'type': {'choices': ['overload', 'one-to-one', 'fixed-port-range', 'port-block-allocation', 'cgn-resource-allocation'], 'type': 'str'},
321 'cgn-block-size': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
322 'cgn-client-endip': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
323 'cgn-client-startip': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
324 'cgn-fixedalloc': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
325 'cgn-overload': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
326 'cgn-port-end': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
327 'cgn-port-start': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
328 'cgn-spa': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
329 'utilization-alarm-clear': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
330 'utilization-alarm-raise': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
331 'endport': {'v_range': [['7.0.0', '']], 'type': 'int'},
332 'port-per-user': {'v_range': [['7.0.0', '']], 'type': 'int'},
333 'startport': {'v_range': [['7.0.0', '']], 'type': 'int'},
334 'add-nat64-route': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
335 'cgn-client-ipv6shift': {'v_range': [['6.2.9', '6.2.13'], ['6.4.7', '6.4.15'], ['7.0.2', '']], 'type': 'int'},
336 'nat64': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
337 'subnet-broadcast-in-ippool': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
338 'exclude-ip': {'v_range': [['7.2.2', '']], 'type': 'raw'},
339 'pba-interim-log': {'v_range': [['7.4.3', '']], 'type': 'int'},
340 'client-prefix-length': {'v_range': [['7.6.0', '']], 'type': 'int'},
341 'icmp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'},
342 'privileged-port-use-pba': {'v_range': [['7.6.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
343 'source-prefix6': {'v_range': [['7.6.0', '']], 'type': 'str'},
344 'tcp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'},
345 'udp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'}
346 }
347 }
348 }
349
350 module_option_spec = get_module_arg_spec('full crud')
351 module_arg_spec.update(module_option_spec)
352 check_galaxy_version(module_arg_spec)
353 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_ippool_dynamicmapping'),
354 supports_check_mode=True)
355 if not module._socket_path:
356 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
357 connection = Connection(module._socket_path)
358 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
359 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
360 fmgr.process_crud()
361 module.exit_json(meta=module.params)
362
363
364 if __name__ == '__main__':
365 main()