Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_ippool6_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_ippool6_dynamicmapping
15 short_description: Configure IPv6 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 ippool6:
29 description: The parameter (ippool6) in requested url.
30 type: str
31 required: true
32 firewall_ippool6_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 comments:
49 type: str
50 description: Comments.
51 endip:
52 type: str
53 description: Endip.
54 startip:
55 type: str
56 description: Startip.
57 add_nat46_route:
58 aliases: ['add-nat46-route']
59 type: str
60 description: Enable/disable adding NAT46 route.
61 choices: ['disable', 'enable']
62 nat46:
63 type: str
64 description: Enable/disable NAT46.
65 choices: ['disable', 'enable']
66 external_prefix:
67 aliases: ['external-prefix']
68 type: str
69 description:
70 - Support meta variable
71 - External NPTv6 prefix length
72 internal_prefix:
73 aliases: ['internal-prefix']
74 type: str
75 description:
76 - Support meta variable
77 - Internal NPTv6 prefix length
78 type:
79 type: str
80 description: Configure IPv6 pool type
81 choices: ['overload', 'nptv6']
82 '''
83
84 EXAMPLES = '''
85 - name: Example playbook
86 hosts: fortimanagers
87 gather_facts: false
88 connection: httpapi
89 vars:
90 ansible_httpapi_use_ssl: true
91 ansible_httpapi_validate_certs: false
92 ansible_httpapi_port: 443
93 tasks:
94 - name: Configure dynamic mappings of IPv6 IP pool
95 fortinet.fortimanager.fmgr_firewall_ippool6_dynamicmapping:
96 bypass_validation: true
97 adom: ansible
98 ippool6: "ansible-test"
99 state: present
100 firewall_ippool6_dynamicmapping:
101 _scope:
102 - name: FGT_AWS # need a valid device name
103 vdom: root # need a valid vdom name under the device
104 comments: "ansible-test"
105 endip: "2001::101"
106 startip: "2001::0"
107
108 - name: Gathering fortimanager facts
109 hosts: fortimanagers
110 gather_facts: false
111 connection: httpapi
112 vars:
113 ansible_httpapi_use_ssl: true
114 ansible_httpapi_validate_certs: false
115 ansible_httpapi_port: 443
116 tasks:
117 - name: Retrieve all the dynamic mappings of IPv6 IP pool
118 fortinet.fortimanager.fmgr_fact:
119 facts:
120 selector: "firewall_ippool6_dynamicmapping"
121 params:
122 adom: "ansible"
123 ippool6: "ansible-test" # name
124 dynamic_mapping: "your_value"
125 '''
126
127 RETURN = '''
128 meta:
129 description: The result of the request.
130 type: dict
131 returned: always
132 contains:
133 request_url:
134 description: The full url requested.
135 returned: always
136 type: str
137 sample: /sys/login/user
138 response_code:
139 description: The status of api request.
140 returned: always
141 type: int
142 sample: 0
143 response_data:
144 description: The api response.
145 type: list
146 returned: always
147 response_message:
148 description: The descriptive message of the api response.
149 type: str
150 returned: always
151 sample: OK.
152 system_information:
153 description: The information of the target system.
154 type: dict
155 returned: always
156 rc:
157 description: The status the request.
158 type: int
159 returned: always
160 sample: 0
161 version_check_warning:
162 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
163 type: list
164 returned: complex
165 '''
166 from ansible.module_utils.basic import AnsibleModule
167 from ansible.module_utils.connection import Connection
168 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
169 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
170
171
172 def main():
173 urls_list = [
174 '/pm/config/adom/{adom}/obj/firewall/ippool6/{ippool6}/dynamic_mapping',
175 '/pm/config/global/obj/firewall/ippool6/{ippool6}/dynamic_mapping'
176 ]
177 module_arg_spec = {
178 'adom': {'required': True, 'type': 'str'},
179 'ippool6': {'required': True, 'type': 'str'},
180 'revision_note': {'type': 'str'},
181 'firewall_ippool6_dynamicmapping': {
182 'type': 'dict', 'v_range': [['6.0.0', '']],
183 'options': {
184 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
185 'comments': {'type': 'str'},
186 'endip': {'type': 'str'},
187 'startip': {'type': 'str'},
188 'add-nat46-route': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
189 'nat46': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
190 'external-prefix': {'v_range': [['7.6.0', '']], 'type': 'str'},
191 'internal-prefix': {'v_range': [['7.6.0', '']], 'type': 'str'},
192 'type': {'v_range': [['7.6.0', '']], 'choices': ['overload', 'nptv6'], 'type': 'str'}
193 }
194 }
195 }
196
197 module_option_spec = get_module_arg_spec('full crud')
198 module_arg_spec.update(module_option_spec)
199 check_galaxy_version(module_arg_spec)
200 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_ippool6_dynamicmapping'),
201 supports_check_mode=True)
202 if not module._socket_path:
203 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
204 connection = Connection(module._socket_path)
205 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
206 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
207 fmgr.process_crud()
208 module.exit_json(meta=module.params)
209
210
211 if __name__ == '__main__':
212 main()