Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_qos_queuepolicy.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_switchcontroller_qos_queuepolicy
15 short_description: Configure FortiSwitch QoS egress queue policy.
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 switchcontroller_qos_queuepolicy:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 cos_queue:
34 aliases: ['cos-queue']
35 type: list
36 elements: dict
37 description: Cos queue.
38 suboptions:
39 description:
40 type: str
41 description: Description of the COS queue.
42 drop_policy:
43 aliases: ['drop-policy']
44 type: str
45 description: COS queue drop policy.
46 choices: ['taildrop', 'weighted-random-early-detection']
47 max_rate:
48 aliases: ['max-rate']
49 type: int
50 description: Maximum rate
51 min_rate:
52 aliases: ['min-rate']
53 type: int
54 description: Minimum rate
55 name:
56 type: str
57 description: Cos queue ID.
58 weight:
59 type: int
60 description: Weight of weighted round robin scheduling.
61 max_rate_percent:
62 aliases: ['max-rate-percent']
63 type: int
64 description: Maximum rate
65 min_rate_percent:
66 aliases: ['min-rate-percent']
67 type: int
68 description: Minimum rate
69 ecn:
70 type: str
71 description: Enable/disable ECN packet marking to drop eligible packets.
72 choices: ['disable', 'enable']
73 name:
74 type: str
75 description: QoS policy name
76 required: true
77 schedule:
78 type: str
79 description: COS queue scheduling.
80 choices: ['strict', 'round-robin', 'weighted']
81 rate_by:
82 aliases: ['rate-by']
83 type: str
84 description: COS queue rate by kbps or percent.
85 choices: ['kbps', 'percent']
86 '''
87
88 EXAMPLES = '''
89 - name: Example playbook (generated based on argument schema)
90 hosts: fortimanagers
91 connection: httpapi
92 gather_facts: false
93 tasks:
94 - name: Configure FortiSwitch QoS egress queue policy.
95 fortinet.fortimanager.fmgr_switchcontroller_qos_queuepolicy:
96 # workspace_locking_adom: <global or your adom name>
97 adom: <your own value>
98 state: present # <value in [present, absent]>
99 switchcontroller_qos_queuepolicy:
100 name: "your value" # Required variable, string
101 # cos_queue:
102 # - description: <string>
103 # drop_policy: <value in [taildrop, weighted-random-early-detection]>
104 # max_rate: <integer>
105 # min_rate: <integer>
106 # name: <string>
107 # weight: <integer>
108 # max_rate_percent: <integer>
109 # min_rate_percent: <integer>
110 # ecn: <value in [disable, enable]>
111 # schedule: <value in [strict, round-robin, weighted]>
112 # rate_by: <value in [kbps, percent]>
113 '''
114
115 RETURN = '''
116 meta:
117 description: The result of the request.
118 type: dict
119 returned: always
120 contains:
121 request_url:
122 description: The full url requested.
123 returned: always
124 type: str
125 sample: /sys/login/user
126 response_code:
127 description: The status of api request.
128 returned: always
129 type: int
130 sample: 0
131 response_data:
132 description: The api response.
133 type: list
134 returned: always
135 response_message:
136 description: The descriptive message of the api response.
137 type: str
138 returned: always
139 sample: OK.
140 system_information:
141 description: The information of the target system.
142 type: dict
143 returned: always
144 rc:
145 description: The status the request.
146 type: int
147 returned: always
148 sample: 0
149 version_check_warning:
150 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
151 type: list
152 returned: complex
153 '''
154 from ansible.module_utils.basic import AnsibleModule
155 from ansible.module_utils.connection import Connection
156 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
157 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
158
159
160 def main():
161 urls_list = [
162 '/pm/config/adom/{adom}/obj/switch-controller/qos/queue-policy',
163 '/pm/config/global/obj/switch-controller/qos/queue-policy'
164 ]
165 module_arg_spec = {
166 'adom': {'required': True, 'type': 'str'},
167 'revision_note': {'type': 'str'},
168 'switchcontroller_qos_queuepolicy': {
169 'type': 'dict', 'v_range': [['6.0.0', '']],
170 'options': {
171 'cos-queue': {
172 'type': 'list',
173 'options': {
174 'description': {'type': 'str'},
175 'drop-policy': {'choices': ['taildrop', 'weighted-random-early-detection'], 'type': 'str'},
176 'max-rate': {'type': 'int'},
177 'min-rate': {'type': 'int'},
178 'name': {'type': 'str'},
179 'weight': {'type': 'int'},
180 'max-rate-percent': {'v_range': [['6.2.0', '']], 'type': 'int'},
181 'min-rate-percent': {'v_range': [['6.2.0', '']], 'type': 'int'},
182 'ecn': {'v_range': [['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
183 },
184 'elements': 'dict'
185 },
186 'name': {'required': True, 'type': 'str'},
187 'schedule': {'choices': ['strict', 'round-robin', 'weighted'], 'type': 'str'},
188 'rate-by': {'v_range': [['6.2.0', '']], 'choices': ['kbps', 'percent'], 'type': 'str'}
189 }
190 }
191 }
192
193 module_option_spec = get_module_arg_spec('full crud')
194 module_arg_spec.update(module_option_spec)
195 check_galaxy_version(module_arg_spec)
196 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_qos_queuepolicy'),
197 supports_check_mode=True)
198 if not module._socket_path:
199 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
200 connection = Connection(module._socket_path)
201 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
202 'name', 'data', module, connection)
203 fmgr.process_crud()
204 module.exit_json(meta=module.params)
205
206
207 if __name__ == '__main__':
208 main()