Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vip64_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_vip64_dynamicmapping
15 short_description: Configure IPv6 to IPv4 virtual IPs.
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 vip64:
29 description: The parameter (vip64) in requested url.
30 type: str
31 required: true
32 firewall_vip64_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_reply:
49 aliases: ['arp-reply']
50 type: str
51 description: Arp reply.
52 choices: ['disable', 'enable']
53 color:
54 type: int
55 description: Color.
56 comment:
57 type: str
58 description: Comment.
59 extip:
60 type: str
61 description: Extip.
62 extport:
63 type: str
64 description: Extport.
65 id:
66 type: int
67 description: Id.
68 ldb_method:
69 aliases: ['ldb-method']
70 type: str
71 description: Ldb method.
72 choices: ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt',
73 'first-alive']
74 mappedip:
75 type: str
76 description: Mappedip.
77 mappedport:
78 type: str
79 description: Mappedport.
80 monitor:
81 type: raw
82 description: (list or str) Monitor.
83 portforward:
84 type: str
85 description: Portforward.
86 choices: ['disable', 'enable']
87 protocol:
88 type: str
89 description: Protocol.
90 choices: ['tcp', 'udp']
91 server_type:
92 aliases: ['server-type']
93 type: str
94 description: Server type.
95 choices: ['http', 'tcp', 'udp', 'ip']
96 src_filter:
97 aliases: ['src-filter']
98 type: raw
99 description: (list) Src filter.
100 type:
101 type: str
102 description: Type.
103 choices: ['static-nat', 'server-load-balance']
104 uuid:
105 type: str
106 description: Uuid.
107 '''
108
109 EXAMPLES = '''
110 - name: Example playbook
111 hosts: fortimanagers
112 gather_facts: false
113 connection: httpapi
114 vars:
115 ansible_httpapi_use_ssl: true
116 ansible_httpapi_validate_certs: false
117 ansible_httpapi_port: 443
118 tasks:
119 - name: Configure dynamic mappings of IPv6 to IPv4 virtual IPs
120 fortinet.fortimanager.fmgr_firewall_vip64_dynamicmapping:
121 bypass_validation: false
122 adom: ansible
123 vip64: "ansible-test-vip64" # name
124 state: present
125 firewall_vip64_dynamicmapping:
126 _scope:
127 - name: FGT_AWS # need a valid device name
128 vdom: root # need a valid vdom name under the device
129 arp_reply: enable
130 color: 1
131 comment: "ansible-comment1"
132 id: 1
133
134 - name: Gathering fortimanager facts
135 hosts: fortimanagers
136 gather_facts: false
137 connection: httpapi
138 vars:
139 ansible_httpapi_use_ssl: true
140 ansible_httpapi_validate_certs: false
141 ansible_httpapi_port: 443
142 tasks:
143 - name: Retrieve all the dynamic mappings of IPv6 to IPv4 virtual IPs
144 fortinet.fortimanager.fmgr_fact:
145 facts:
146 selector: "firewall_vip64_dynamicmapping"
147 params:
148 adom: "ansible"
149 vip64: "ansible-test-vip64" # name
150 dynamic_mapping: "your_value"
151 '''
152
153 RETURN = '''
154 meta:
155 description: The result of the request.
156 type: dict
157 returned: always
158 contains:
159 request_url:
160 description: The full url requested.
161 returned: always
162 type: str
163 sample: /sys/login/user
164 response_code:
165 description: The status of api request.
166 returned: always
167 type: int
168 sample: 0
169 response_data:
170 description: The api response.
171 type: list
172 returned: always
173 response_message:
174 description: The descriptive message of the api response.
175 type: str
176 returned: always
177 sample: OK.
178 system_information:
179 description: The information of the target system.
180 type: dict
181 returned: always
182 rc:
183 description: The status the request.
184 type: int
185 returned: always
186 sample: 0
187 version_check_warning:
188 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
189 type: list
190 returned: complex
191 '''
192 from ansible.module_utils.basic import AnsibleModule
193 from ansible.module_utils.connection import Connection
194 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
195 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
196
197
198 def main():
199 urls_list = [
200 '/pm/config/adom/{adom}/obj/firewall/vip64/{vip64}/dynamic_mapping',
201 '/pm/config/global/obj/firewall/vip64/{vip64}/dynamic_mapping'
202 ]
203 module_arg_spec = {
204 'adom': {'required': True, 'type': 'str'},
205 'vip64': {'required': True, 'type': 'str'},
206 'revision_note': {'type': 'str'},
207 'firewall_vip64_dynamicmapping': {
208 'type': 'dict', 'v_range': [['6.0.0', '']],
209 'options': {
210 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
211 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
212 'color': {'type': 'int'},
213 'comment': {'type': 'str'},
214 'extip': {'type': 'str'},
215 'extport': {'type': 'str'},
216 'id': {'type': 'int'},
217 'ldb-method': {'choices': ['static', 'round-robin', 'weighted', 'least-session', 'least-rtt', 'first-alive'], 'type': 'str'},
218 'mappedip': {'type': 'str'},
219 'mappedport': {'type': 'str'},
220 'monitor': {'type': 'raw'},
221 'portforward': {'choices': ['disable', 'enable'], 'type': 'str'},
222 'protocol': {'choices': ['tcp', 'udp'], 'type': 'str'},
223 'server-type': {'choices': ['http', 'tcp', 'udp', 'ip'], 'type': 'str'},
224 'src-filter': {'type': 'raw'},
225 'type': {'choices': ['static-nat', 'server-load-balance'], 'type': 'str'},
226 'uuid': {'type': 'str'}
227 }
228 }
229 }
230
231 module_option_spec = get_module_arg_spec('full crud')
232 module_arg_spec.update(module_option_spec)
233 check_galaxy_version(module_arg_spec)
234 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vip64_dynamicmapping'),
235 supports_check_mode=True)
236 if not module._socket_path:
237 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
238 connection = Connection(module._socket_path)
239 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
240 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
241 fmgr.process_crud()
242 module.exit_json(meta=module.params)
243
244
245 if __name__ == '__main__':
246 main()