Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_shapingprofile.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_shapingprofile
15 short_description: Configure shaping profiles.
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 firewall_shapingprofile:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Comment.
36 default_class_id:
37 aliases: ['default-class-id']
38 type: raw
39 description: (int or str) Default class ID to handle unclassified packets
40 profile_name:
41 aliases: ['profile-name']
42 type: str
43 description: Shaping profile name.
44 required: true
45 shaping_entries:
46 aliases: ['shaping-entries']
47 type: list
48 elements: dict
49 description: Shaping entries.
50 suboptions:
51 class_id:
52 aliases: ['class-id']
53 type: raw
54 description: (int or str) Class ID.
55 guaranteed_bandwidth_percentage:
56 aliases: ['guaranteed-bandwidth-percentage']
57 type: int
58 description: Guaranteed bandwith in percentage.
59 id:
60 type: int
61 description: ID number.
62 maximum_bandwidth_percentage:
63 aliases: ['maximum-bandwidth-percentage']
64 type: int
65 description: Maximum bandwith in percentage.
66 priority:
67 type: str
68 description: Priority.
69 choices: ['low', 'medium', 'high', 'critical', 'top']
70 burst_in_msec:
71 aliases: ['burst-in-msec']
72 type: int
73 description: Number of bytes that can be burst at maximum-bandwidth speed.
74 cburst_in_msec:
75 aliases: ['cburst-in-msec']
76 type: int
77 description: Number of bytes that can be burst as fast as the interface can transmit.
78 limit:
79 type: int
80 description: Hard limit on the real queue size in packets.
81 max:
82 type: int
83 description: Average queue size in packets at which RED drop probability is maximal.
84 min:
85 type: int
86 description: Average queue size in packets at which RED drop becomes a possibility.
87 red_probability:
88 aliases: ['red-probability']
89 type: int
90 description: Maximum probability
91 type:
92 type: str
93 description: Select shaping profile type
94 choices: ['policing', 'queuing']
95 npu_offloading:
96 aliases: ['npu-offloading']
97 type: str
98 description: Enable/disable NPU offloading.
99 choices: ['disable', 'enable']
100 classes:
101 type: list
102 elements: dict
103 description: Classes.
104 suboptions:
105 class_id:
106 aliases: ['class-id']
107 type: int
108 description: Class ID.
109 guaranteed_bandwidth:
110 aliases: ['guaranteed-bandwidth']
111 type: int
112 description: Guaranteed bandwith in percentage.
113 maximum_bandwidth:
114 aliases: ['maximum-bandwidth']
115 type: int
116 description: Maximum bandwith in percentage.
117 name:
118 type: str
119 description: Class Name.
120 priority:
121 type: str
122 description: Priority.
123 choices: ['top', 'critical', 'high', 'medium', 'low']
124 default_class:
125 aliases: ['default-class']
126 type: int
127 description: Default class ID to handle unclassified packets.
128 '''
129
130 EXAMPLES = '''
131 - name: Example playbook
132 hosts: fortimanagers
133 gather_facts: false
134 connection: httpapi
135 vars:
136 ansible_httpapi_use_ssl: true
137 ansible_httpapi_validate_certs: false
138 ansible_httpapi_port: 443
139 tasks:
140 - name: Configure shaping profiles.
141 fortinet.fortimanager.fmgr_firewall_shapingprofile:
142 bypass_validation: false
143 adom: ansible
144 state: present
145 firewall_shapingprofile:
146 comment: "ansible-comment"
147 profile_name: "ansible-test"
148
149 - name: Gathering fortimanager facts
150 hosts: fortimanagers
151 gather_facts: false
152 connection: httpapi
153 vars:
154 ansible_httpapi_use_ssl: true
155 ansible_httpapi_validate_certs: false
156 ansible_httpapi_port: 443
157 tasks:
158 - name: Retrieve all the shaping profiles
159 fortinet.fortimanager.fmgr_fact:
160 facts:
161 selector: "firewall_shapingprofile"
162 params:
163 adom: "ansible"
164 shaping_profile: "your_value"
165 '''
166
167 RETURN = '''
168 meta:
169 description: The result of the request.
170 type: dict
171 returned: always
172 contains:
173 request_url:
174 description: The full url requested.
175 returned: always
176 type: str
177 sample: /sys/login/user
178 response_code:
179 description: The status of api request.
180 returned: always
181 type: int
182 sample: 0
183 response_data:
184 description: The api response.
185 type: list
186 returned: always
187 response_message:
188 description: The descriptive message of the api response.
189 type: str
190 returned: always
191 sample: OK.
192 system_information:
193 description: The information of the target system.
194 type: dict
195 returned: always
196 rc:
197 description: The status the request.
198 type: int
199 returned: always
200 sample: 0
201 version_check_warning:
202 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
203 type: list
204 returned: complex
205 '''
206 from ansible.module_utils.basic import AnsibleModule
207 from ansible.module_utils.connection import Connection
208 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
209 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
210
211
212 def main():
213 urls_list = [
214 '/pm/config/adom/{adom}/obj/firewall/shaping-profile',
215 '/pm/config/global/obj/firewall/shaping-profile'
216 ]
217 module_arg_spec = {
218 'adom': {'required': True, 'type': 'str'},
219 'revision_note': {'type': 'str'},
220 'firewall_shapingprofile': {
221 'type': 'dict', 'v_range': [['6.0.0', '']],
222 'options': {
223 'comment': {'type': 'str'},
224 'default-class-id': {'type': 'raw'},
225 'profile-name': {'required': True, 'type': 'str'},
226 'shaping-entries': {
227 'type': 'list',
228 'options': {
229 'class-id': {'type': 'raw'},
230 'guaranteed-bandwidth-percentage': {'type': 'int'},
231 'id': {'type': 'int'},
232 'maximum-bandwidth-percentage': {'type': 'int'},
233 'priority': {'choices': ['low', 'medium', 'high', 'critical', 'top'], 'type': 'str'},
234 'burst-in-msec': {'v_range': [['6.2.1', '']], 'type': 'int'},
235 'cburst-in-msec': {'v_range': [['6.2.1', '']], 'type': 'int'},
236 'limit': {'v_range': [['6.2.1', '']], 'type': 'int'},
237 'max': {'v_range': [['6.2.1', '']], 'type': 'int'},
238 'min': {'v_range': [['6.2.1', '']], 'type': 'int'},
239 'red-probability': {'v_range': [['6.2.1', '']], 'type': 'int'}
240 },
241 'elements': 'dict'
242 },
243 'type': {'v_range': [['6.2.1', '']], 'choices': ['policing', 'queuing'], 'type': 'str'},
244 'npu-offloading': {'v_range': [['7.2.6', '7.2.12'], ['7.4.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
245 'classes': {
246 'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']],
247 'type': 'list',
248 'options': {
249 'class-id': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
250 'guaranteed-bandwidth': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
251 'maximum-bandwidth': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
252 'name': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
253 'priority': {
254 'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']],
255 'choices': ['top', 'critical', 'high', 'medium', 'low'],
256 'type': 'str'
257 }
258 },
259 'elements': 'dict'
260 },
261 'default-class': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'}
262 }
263 }
264 }
265
266 module_option_spec = get_module_arg_spec('full crud')
267 module_arg_spec.update(module_option_spec)
268 check_galaxy_version(module_arg_spec)
269 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_shapingprofile'),
270 supports_check_mode=True)
271 if not module._socket_path:
272 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
273 connection = Connection(module._socket_path)
274 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
275 'profile-name', 'data', module, connection)
276 fmgr.process_crud()
277 module.exit_json(meta=module.params)
278
279
280 if __name__ == '__main__':
281 main()