Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_shaper_trafficshaper.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_shaper_trafficshaper
15 short_description: Configure shared traffic shaper.
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_shaper_trafficshaper:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 bandwidth_unit:
34 aliases: ['bandwidth-unit']
35 type: str
36 description: Unit of measurement for guaranteed and maximum bandwidth for this shaper
37 choices: ['kbps', 'mbps', 'gbps']
38 diffserv:
39 type: str
40 description: Enable/disable changing the DiffServ setting applied to traffic accepted by this shaper.
41 choices: ['disable', 'enable']
42 diffservcode:
43 type: str
44 description: DiffServ setting to be applied to traffic accepted by this shaper.
45 guaranteed_bandwidth:
46 aliases: ['guaranteed-bandwidth']
47 type: int
48 description: Amount of bandwidth guaranteed for this shaper
49 maximum_bandwidth:
50 aliases: ['maximum-bandwidth']
51 type: int
52 description: Upper bandwidth limit enforced by this shaper
53 name:
54 type: str
55 description: Traffic shaper name.
56 required: true
57 per_policy:
58 aliases: ['per-policy']
59 type: str
60 description: Enable/disable applying a separate shaper for each policy.
61 choices: ['disable', 'enable']
62 priority:
63 type: str
64 description: Higher priority traffic is more likely to be forwarded without delays and without compromising the guaranteed bandwidth.
65 choices: ['high', 'medium', 'low']
66 dscp_marking_method:
67 aliases: ['dscp-marking-method']
68 type: str
69 description: Select DSCP marking method.
70 choices: ['multi-stage', 'static']
71 exceed_bandwidth:
72 aliases: ['exceed-bandwidth']
73 type: int
74 description: Exceed bandwidth used for DSCP multi-stage marking.
75 exceed_class_id:
76 aliases: ['exceed-class-id']
77 type: int
78 description: Class ID for traffic in [guaranteed-bandwidth, maximum-bandwidth].
79 exceed_dscp:
80 aliases: ['exceed-dscp']
81 type: str
82 description: DSCP mark for traffic in [guaranteed-bandwidth, exceed-bandwidth].
83 maximum_dscp:
84 aliases: ['maximum-dscp']
85 type: str
86 description: DSCP mark for traffic in [exceed-bandwidth, maximum-bandwidth].
87 overhead:
88 type: int
89 description: Per-packet size overhead used in rate computations.
90 cos:
91 type: str
92 description: VLAN CoS mark.
93 cos_marking:
94 aliases: ['cos-marking']
95 type: str
96 description: Enable/disable VLAN CoS marking.
97 choices: ['disable', 'enable']
98 cos_marking_method:
99 aliases: ['cos-marking-method']
100 type: str
101 description: Select VLAN CoS marking method.
102 choices: ['multi-stage', 'static']
103 exceed_cos:
104 aliases: ['exceed-cos']
105 type: str
106 description: VLAN CoS mark for traffic in [guaranteed-bandwidth, exceed-bandwidth].
107 maximum_cos:
108 aliases: ['maximum-cos']
109 type: str
110 description: VLAN CoS mark for traffic in [exceed-bandwidth, maximum-bandwidth].
111 '''
112
113 EXAMPLES = '''
114 - name: Example playbook
115 hosts: fortimanagers
116 gather_facts: false
117 connection: httpapi
118 vars:
119 ansible_httpapi_use_ssl: true
120 ansible_httpapi_validate_certs: false
121 ansible_httpapi_port: 443
122 tasks:
123 - name: Configure shared traffic shaper.
124 fortinet.fortimanager.fmgr_firewall_shaper_trafficshaper:
125 bypass_validation: false
126 adom: ansible
127 state: present
128 firewall_shaper_trafficshaper:
129 bandwidth_unit: mbps # <value in [kbps, mbps, gbps]>
130 diffserv: disable
131 name: "ansible"
132 per_policy: disable
133 priority: medium # <value in [high, medium, low]>
134
135 - name: Gathering fortimanager facts
136 hosts: fortimanagers
137 gather_facts: false
138 connection: httpapi
139 vars:
140 ansible_httpapi_use_ssl: true
141 ansible_httpapi_validate_certs: false
142 ansible_httpapi_port: 443
143 tasks:
144 - name: Retrieve all the shared traffic shapers
145 fortinet.fortimanager.fmgr_fact:
146 facts:
147 selector: "firewall_shaper_trafficshaper"
148 params:
149 adom: "ansible"
150 traffic_shaper: "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/shaper/traffic-shaper',
201 '/pm/config/global/obj/firewall/shaper/traffic-shaper'
202 ]
203 module_arg_spec = {
204 'adom': {'required': True, 'type': 'str'},
205 'revision_note': {'type': 'str'},
206 'firewall_shaper_trafficshaper': {
207 'type': 'dict', 'v_range': [['6.0.0', '']],
208 'options': {
209 'bandwidth-unit': {'choices': ['kbps', 'mbps', 'gbps'], 'type': 'str'},
210 'diffserv': {'choices': ['disable', 'enable'], 'type': 'str'},
211 'diffservcode': {'type': 'str'},
212 'guaranteed-bandwidth': {'type': 'int'},
213 'maximum-bandwidth': {'type': 'int'},
214 'name': {'required': True, 'type': 'str'},
215 'per-policy': {'choices': ['disable', 'enable'], 'type': 'str'},
216 'priority': {'choices': ['high', 'medium', 'low'], 'type': 'str'},
217 'dscp-marking-method': {'v_range': [['6.2.1', '']], 'choices': ['multi-stage', 'static'], 'type': 'str'},
218 'exceed-bandwidth': {'v_range': [['6.2.1', '']], 'type': 'int'},
219 'exceed-class-id': {'v_range': [['6.2.1', '']], 'type': 'int'},
220 'exceed-dscp': {'v_range': [['6.2.1', '']], 'type': 'str'},
221 'maximum-dscp': {'v_range': [['6.2.1', '']], 'type': 'str'},
222 'overhead': {'v_range': [['6.2.1', '']], 'type': 'int'},
223 'cos': {'v_range': [['7.4.0', '']], 'type': 'str'},
224 'cos-marking': {'v_range': [['7.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
225 'cos-marking-method': {'v_range': [['7.4.0', '']], 'choices': ['multi-stage', 'static'], 'type': 'str'},
226 'exceed-cos': {'v_range': [['7.4.0', '']], 'type': 'str'},
227 'maximum-cos': {'v_range': [['7.4.0', '']], 'type': 'str'}
228 }
229 }
230 }
231
232 module_option_spec = get_module_arg_spec('full crud')
233 module_arg_spec.update(module_option_spec)
234 check_galaxy_version(module_arg_spec)
235 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_shaper_trafficshaper'),
236 supports_check_mode=True)
237 if not module._socket_path:
238 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
239 connection = Connection(module._socket_path)
240 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
241 'name', 'data', module, connection)
242 fmgr.process_crud()
243 module.exit_json(meta=module.params)
244
245
246 if __name__ == '__main__':
247 main()