| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
The module file for sonic_qos_scheduler |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
__metaclass__ = type |
| 13 |
|
| 14 |
DOCUMENTATION = """ |
| 15 |
--- |
| 16 |
module: sonic_qos_scheduler |
| 17 |
version_added: "2.5.0" |
| 18 |
notes: |
| 19 |
- Tested against Enterprise SONiC Distribution by Dell Technologies. |
| 20 |
- Supports C(check_mode). |
| 21 |
short_description: Manage QoS scheduler configuration on SONiC |
| 22 |
description: |
| 23 |
- This module provides configuration management of QoS scheduler for devices running SONiC |
| 24 |
author: "S. Talabi (@stalabi1)" |
| 25 |
options: |
| 26 |
config: |
| 27 |
description: |
| 28 |
- QoS scheduler configuration |
| 29 |
type: list |
| 30 |
elements: dict |
| 31 |
suboptions: |
| 32 |
name: |
| 33 |
description: |
| 34 |
- Name of scheduler policy |
| 35 |
type: str |
| 36 |
required: True |
| 37 |
schedulers: |
| 38 |
description: |
| 39 |
- Schedulers configuration for the scheduler policy |
| 40 |
type: list |
| 41 |
elements: dict |
| 42 |
suboptions: |
| 43 |
sequence: |
| 44 |
description: |
| 45 |
- Sequence number of the scheduler |
| 46 |
- Range 0-7 for interface queues |
| 47 |
- Range 0-47 for CPU queues |
| 48 |
- Specify 255 for port queues |
| 49 |
type: int |
| 50 |
required: True |
| 51 |
scheduler_type: |
| 52 |
description: |
| 53 |
- Specifies the type of scheduler |
| 54 |
- Strict priority scheduling cannot be configured with weight |
| 55 |
type: str |
| 56 |
choices: |
| 57 |
- dwrr |
| 58 |
- wrr |
| 59 |
- strict |
| 60 |
weight: |
| 61 |
description: |
| 62 |
- Weight of the scheduler |
| 63 |
- Range 1-100 |
| 64 |
type: int |
| 65 |
meter_type: |
| 66 |
description: |
| 67 |
- Metering method used by the scheduler |
| 68 |
type: str |
| 69 |
choices: |
| 70 |
- packets |
| 71 |
- bytes |
| 72 |
cir: |
| 73 |
description: |
| 74 |
- Committed information rate measured in bps |
| 75 |
- Range 0-400000000000 |
| 76 |
type: int |
| 77 |
pir: |
| 78 |
description: |
| 79 |
- Peak information rate measured in bps |
| 80 |
- Range 0-400000000000, must be greater than or equal to cir |
| 81 |
type: int |
| 82 |
cbs: |
| 83 |
description: |
| 84 |
- Committed burst size measured in bytes |
| 85 |
- Range 0-125000000 |
| 86 |
type: int |
| 87 |
pbs: |
| 88 |
description: |
| 89 |
- Excess burst size measured in bytes |
| 90 |
- Range 0-125000000 |
| 91 |
type: int |
| 92 |
state: |
| 93 |
description: |
| 94 |
- The state of the configuration after module completion |
| 95 |
type: str |
| 96 |
choices: |
| 97 |
- merged |
| 98 |
- deleted |
| 99 |
- replaced |
| 100 |
- overridden |
| 101 |
default: merged |
| 102 |
""" |
| 103 |
|
| 104 |
EXAMPLES = """ |
| 105 |
# Using "merged" state |
| 106 |
# |
| 107 |
# Before state: |
| 108 |
# ------------- |
| 109 |
# |
| 110 |
# sonic# show qos scheduler-policy |
| 111 |
# (No qos scheduler-policy configuration present) |
| 112 |
|
| 113 |
- name: Merge QoS scheduler configurations |
| 114 |
dellemc.enterprise_sonic.sonic_qos_scheduler: |
| 115 |
config: |
| 116 |
- name: policy1 |
| 117 |
schedulers: |
| 118 |
- sequence: 0 |
| 119 |
scheduler_type: dwrr |
| 120 |
weight: 10 |
| 121 |
meter_type: packets |
| 122 |
cir: 32000 |
| 123 |
pir: 40000 |
| 124 |
cbs: 30000 |
| 125 |
pbs: 35000 |
| 126 |
state: merged |
| 127 |
|
| 128 |
# After state: |
| 129 |
# ------------ |
| 130 |
# |
| 131 |
# sonic# show qos scheduler-policy |
| 132 |
# Scheduler Policy: policy1 |
| 133 |
# Queue: 0 |
| 134 |
# type: dwrr |
| 135 |
# weight: 10 |
| 136 |
# meter-type: packets |
| 137 |
# cir: 32000 Pps |
| 138 |
# cbs: 30000 Packets |
| 139 |
# pir: 40000 Pps |
| 140 |
# pbs: 35000 Packets |
| 141 |
|
| 142 |
|
| 143 |
# Using "replaced" state |
| 144 |
# |
| 145 |
# Before state: |
| 146 |
# ------------- |
| 147 |
# |
| 148 |
# sonic# show qos scheduler-policy |
| 149 |
# Scheduler Policy: policy1 |
| 150 |
# Queue: 0 |
| 151 |
# type: dwrr |
| 152 |
# weight: 10 |
| 153 |
# meter-type: packets |
| 154 |
# cir: 32000 Pps |
| 155 |
# cbs: 30000 Packets |
| 156 |
# pir: 40000 Pps |
| 157 |
# pbs: 35000 Packets |
| 158 |
|
| 159 |
- name: Replace QoS scheduler configurations |
| 160 |
dellemc.enterprise_sonic.sonic_qos_scheduler: |
| 161 |
config: |
| 162 |
- name: policy1 |
| 163 |
schedulers: |
| 164 |
- sequence: 0 |
| 165 |
weight: 12 |
| 166 |
state: replaced |
| 167 |
|
| 168 |
# After state: |
| 169 |
# ------------ |
| 170 |
# |
| 171 |
# sonic# show qos scheduler-policy |
| 172 |
# Scheduler Policy: policy1 |
| 173 |
# Queue: 0 |
| 174 |
# weight: 12 |
| 175 |
|
| 176 |
|
| 177 |
# Using "overridden" state |
| 178 |
# Before state: |
| 179 |
# ------------- |
| 180 |
# |
| 181 |
# sonic# show qos scheduler-policy |
| 182 |
# Scheduler Policy: policy1 |
| 183 |
# Queue: 0 |
| 184 |
# type: dwrr |
| 185 |
# weight: 10 |
| 186 |
# meter-type: packets |
| 187 |
# cir: 32000 Pps |
| 188 |
# cbs: 30000 Packets |
| 189 |
# pir: 40000 Pps |
| 190 |
# pbs: 35000 Packets |
| 191 |
# Queue: 1 |
| 192 |
# type: dwrr |
| 193 |
# weight: 14 |
| 194 |
# meter-type: packets |
| 195 |
|
| 196 |
- name: Override QoS scheduler configurations |
| 197 |
dellemc.enterprise_sonic.sonic_qos_scheduler: |
| 198 |
config: |
| 199 |
- name: policy2 |
| 200 |
schedulers: |
| 201 |
- sequence: 0 |
| 202 |
scheduler_type: wrr |
| 203 |
weight: 5 |
| 204 |
meter_type: bytes |
| 205 |
cir: 50000 |
| 206 |
pir: 60000 |
| 207 |
cbs: 800000 |
| 208 |
pbs: 900000 |
| 209 |
state: overridden |
| 210 |
|
| 211 |
# After state: |
| 212 |
# ------------ |
| 213 |
# |
| 214 |
# sonic# show qos scheduler-policy |
| 215 |
# Scheduler Policy: policy2 |
| 216 |
# Queue: 0 |
| 217 |
# type: wrr |
| 218 |
# weight: 5 |
| 219 |
# meter-type: bytes |
| 220 |
# cir: 50 Kbps |
| 221 |
# cbs: 800000 Bytes |
| 222 |
# pir: 60 Kbps |
| 223 |
# pbs: 900000 Bytes |
| 224 |
|
| 225 |
|
| 226 |
# Using "deleted" state |
| 227 |
# |
| 228 |
# Before state: |
| 229 |
# ------------- |
| 230 |
# |
| 231 |
# sonic# show qos scheduler-policy |
| 232 |
# Scheduler Policy: policy1 |
| 233 |
# Queue: 0 |
| 234 |
# type: dwrr |
| 235 |
# weight: 10 |
| 236 |
# meter-type: packets |
| 237 |
# cir: 32000 Pps |
| 238 |
# cbs: 30000 Packets |
| 239 |
# pir: 40000 Pps |
| 240 |
# pbs: 35000 Packets |
| 241 |
# Queue: 1 |
| 242 |
# type: dwrr |
| 243 |
# weight: 14 |
| 244 |
# meter-type: packets |
| 245 |
# Scheduler Policy: policy2 |
| 246 |
# Queue: 0 |
| 247 |
# type: wrr |
| 248 |
# weight: 5 |
| 249 |
# meter-type: bytes |
| 250 |
# cir: 50 Kbps |
| 251 |
# cbs: 800000 Bytes |
| 252 |
# pir: 60 Kbps |
| 253 |
# pbs: 900000 Bytes |
| 254 |
|
| 255 |
- name: Delete QoS scheduler configurations |
| 256 |
dellemc.enterprise_sonic.sonic_qos_scheduler: |
| 257 |
config: |
| 258 |
- name: policy1 |
| 259 |
schedulers: |
| 260 |
- sequence: 0 |
| 261 |
cir: 32000 |
| 262 |
pir: 40000 |
| 263 |
cbs: 30000 |
| 264 |
pbs: 35000 |
| 265 |
- sequence: 1 |
| 266 |
- name: policy2 |
| 267 |
state: deleted |
| 268 |
|
| 269 |
# After state: |
| 270 |
# ------------- |
| 271 |
# |
| 272 |
# sonic# show qos scheduler-policy |
| 273 |
# Scheduler Policy: policy1 |
| 274 |
# Queue: 0 |
| 275 |
# type: dwrr |
| 276 |
# weight: 10 |
| 277 |
# meter-type: packets |
| 278 |
""" |
| 279 |
|
| 280 |
RETURN = """ |
| 281 |
before: |
| 282 |
description: The configuration prior to the module invocation. |
| 283 |
returned: always |
| 284 |
type: list |
| 285 |
after: |
| 286 |
description: The resulting configuration from module invocation. |
| 287 |
returned: when changed |
| 288 |
type: list |
| 289 |
after_generated: |
| 290 |
description: The generated configuration from module invocation. |
| 291 |
returned: when C(check_mode) |
| 292 |
type: list |
| 293 |
commands: |
| 294 |
description: The set of commands pushed to the remote device. |
| 295 |
returned: always |
| 296 |
type: list |
| 297 |
sample: ['command 1', 'command 2', 'command 3'] |
| 298 |
""" |
| 299 |
|
| 300 |
|
| 301 |
from ansible.module_utils.basic import AnsibleModule |
| 302 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.qos_scheduler.qos_scheduler import Qos_schedulerArgs |
| 303 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.qos_scheduler.qos_scheduler import Qos_scheduler |
| 304 |
|
| 305 |
|
| 306 |
def main(): |
| 307 |
""" |
| 308 |
Main entry point for module execution |
| 309 |
|
| 310 |
:returns: the result form module invocation |
| 311 |
""" |
| 312 |
module = AnsibleModule(argument_spec=Qos_schedulerArgs.argument_spec, |
| 313 |
supports_check_mode=True) |
| 314 |
|
| 315 |
result = Qos_scheduler(module).execute_module() |
| 316 |
module.exit_json(**result) |
| 317 |
|
| 318 |
|
| 319 |
if __name__ == '__main__': |
| 320 |
main() |