| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
The module file for sonic_ars |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
__metaclass__ = type |
| 13 |
|
| 14 |
DOCUMENTATION = """ |
| 15 |
--- |
| 16 |
module: sonic_ars |
| 17 |
version_added: "3.1.0" |
| 18 |
notes: |
| 19 |
- Tested against Enterprise SONiC Distribution by Dell Technologies. |
| 20 |
- Supports C(check_mode). |
| 21 |
short_description: Manage adaptive routing and switching (ARS) configuration on SONiC |
| 22 |
description: |
| 23 |
- This module provides configuration management of ARS for devices running SONiC |
| 24 |
author: "S. Talabi (@stalabi1)" |
| 25 |
options: |
| 26 |
config: |
| 27 |
description: |
| 28 |
- ARS configuration |
| 29 |
type: dict |
| 30 |
suboptions: |
| 31 |
profiles: |
| 32 |
description: |
| 33 |
- List of ARS profiles configuration |
| 34 |
type: list |
| 35 |
elements: dict |
| 36 |
suboptions: |
| 37 |
name: |
| 38 |
description: |
| 39 |
- Name of profile |
| 40 |
type: str |
| 41 |
required: true |
| 42 |
algorithm: |
| 43 |
description: |
| 44 |
- ARS algorithm used for quality computation |
| 45 |
- C(EWMA) - Exponential Weighted Moving Average |
| 46 |
type: str |
| 47 |
choices: [EWMA] |
| 48 |
load_current_max_val: |
| 49 |
description: |
| 50 |
- Maximum current load threshold value for the quantization process |
| 51 |
- Range 0-133169151 |
| 52 |
type: int |
| 53 |
load_current_min_val: |
| 54 |
description: |
| 55 |
- Minimum current load threshold value for the quantization process |
| 56 |
- Range 0-133169151 |
| 57 |
type: int |
| 58 |
load_future_max_val: |
| 59 |
description: |
| 60 |
- Maximum future load threshold value for the quantization process |
| 61 |
- Range 0-266338303 |
| 62 |
type: int |
| 63 |
load_future_min_val: |
| 64 |
description: |
| 65 |
- Minimum future load threshold value for the quantization process |
| 66 |
- Range 0-266338303 |
| 67 |
type: int |
| 68 |
load_past_max_val: |
| 69 |
description: |
| 70 |
- Maximum past load threshold value for the quantization process |
| 71 |
- Range 0-10000 |
| 72 |
type: int |
| 73 |
load_past_min_val: |
| 74 |
description: |
| 75 |
- Minimum past load threshold value for the quantization process |
| 76 |
- Range 0-10000 |
| 77 |
type: int |
| 78 |
port_load_current: |
| 79 |
description: |
| 80 |
- Set port load to current sampled value when sampled value is less than the average |
| 81 |
type: bool |
| 82 |
port_load_exponent: |
| 83 |
description: |
| 84 |
- EWMA exponent used in port loading computation |
| 85 |
- Range 1-16 |
| 86 |
type: int |
| 87 |
port_load_future: |
| 88 |
description: |
| 89 |
- Enable/disable future port load, the average queued bytes measured on a port |
| 90 |
type: bool |
| 91 |
port_load_future_weight: |
| 92 |
description: |
| 93 |
- Weight of future port load used in EWMA calculations |
| 94 |
- Range 1-16 |
| 95 |
type: int |
| 96 |
port_load_past: |
| 97 |
description: |
| 98 |
- Enable/disable past port load, the average egress bytes measured on a port |
| 99 |
type: bool |
| 100 |
port_load_past_weight: |
| 101 |
description: |
| 102 |
- Weight of past port load used in EWMA calculations |
| 103 |
- Range 1-16 |
| 104 |
type: int |
| 105 |
random_seed: |
| 106 |
description: |
| 107 |
- Random seed value |
| 108 |
- Range 0-16777214 |
| 109 |
type: int |
| 110 |
sampling_interval: |
| 111 |
description: |
| 112 |
- Sampling interval in microseconds |
| 113 |
- Range 1-255 |
| 114 |
type: int |
| 115 |
port_profiles: |
| 116 |
description: |
| 117 |
- List of ARS port profiles configuration |
| 118 |
type: list |
| 119 |
elements: dict |
| 120 |
suboptions: |
| 121 |
name: |
| 122 |
description: |
| 123 |
- Name of port profile |
| 124 |
type: str |
| 125 |
required: true |
| 126 |
enable: |
| 127 |
description: |
| 128 |
- Enable/disable ARS for the port |
| 129 |
type: bool |
| 130 |
load_future_weight: |
| 131 |
description: |
| 132 |
- Weight of future port load used in EWMA calculations |
| 133 |
- Range 1-16 |
| 134 |
type: int |
| 135 |
load_past_weight: |
| 136 |
description: |
| 137 |
- Weight as a percentage of the past port load |
| 138 |
- Range 0-100 |
| 139 |
type: int |
| 140 |
load_scaling_factor: |
| 141 |
description: |
| 142 |
- Port load scaling factor |
| 143 |
type: float |
| 144 |
choices: [0, 1, 2.5, 4, 5, 10, 20, 40, 80] |
| 145 |
port_bindings: |
| 146 |
description: |
| 147 |
- List of ARS port bindings configuration |
| 148 |
type: list |
| 149 |
elements: dict |
| 150 |
suboptions: |
| 151 |
name: |
| 152 |
description: |
| 153 |
- Name of port |
| 154 |
type: str |
| 155 |
required: true |
| 156 |
profile: |
| 157 |
description: |
| 158 |
- ARS port profile to bind to port |
| 159 |
- Required for modifcation |
| 160 |
type: str |
| 161 |
switch_binding: |
| 162 |
description: |
| 163 |
- ARS switch binding configuration |
| 164 |
type: dict |
| 165 |
suboptions: |
| 166 |
profile: |
| 167 |
description: |
| 168 |
- ARS profile to bind to switch |
| 169 |
type: str |
| 170 |
ars_objects: |
| 171 |
description: |
| 172 |
- List of ARS next-hop group objects configuration |
| 173 |
type: list |
| 174 |
elements: dict |
| 175 |
suboptions: |
| 176 |
name: |
| 177 |
description: |
| 178 |
- Name of next-hop group object |
| 179 |
type: str |
| 180 |
required: true |
| 181 |
idle_time: |
| 182 |
description: |
| 183 |
- Idle time in microseconds |
| 184 |
- Range 16-32767 |
| 185 |
type: int |
| 186 |
max_flows: |
| 187 |
description: |
| 188 |
- Maximum number of flows that can be maintained by the ARS object |
| 189 |
type: int |
| 190 |
choices: [256, 512, 1024, 2048, 4096, 8192, 16384, 32768] |
| 191 |
mode: |
| 192 |
description: |
| 193 |
- ARS path reassignment mode |
| 194 |
type: str |
| 195 |
choices: [fixed, flowlet-quality, flowlet-random, packet-quality, packet-random] |
| 196 |
state: |
| 197 |
description: |
| 198 |
- The state of the configuration after module completion |
| 199 |
type: str |
| 200 |
choices: [merged, deleted, replaced, overridden] |
| 201 |
default: merged |
| 202 |
""" |
| 203 |
|
| 204 |
EXAMPLES = """ |
| 205 |
# Using "merged" state |
| 206 |
# |
| 207 |
# Before state: |
| 208 |
# ------------- |
| 209 |
# |
| 210 |
# sonic# show running-configuration ars |
| 211 |
# (No ARS configuration present) |
| 212 |
|
| 213 |
- name: Merge ARS configuration |
| 214 |
dellemc.enterprise_sonic.sonic_ars: |
| 215 |
config: |
| 216 |
ars_objects: |
| 217 |
- name: obj1 |
| 218 |
idle_time: 100 |
| 219 |
max_flows: 1024 |
| 220 |
mode: flowlet-quality |
| 221 |
port_profiles: |
| 222 |
- name: pp1 |
| 223 |
enable: true |
| 224 |
load_future_weight: 9 |
| 225 |
load_past_weight: 20 |
| 226 |
load_scaling_factor: 0 |
| 227 |
profiles: |
| 228 |
- name: p1 |
| 229 |
algorithm: EWMA |
| 230 |
load_current_max_val: 10000 |
| 231 |
load_current_min_val: 100 |
| 232 |
load_future_max_val: 20000 |
| 233 |
load_future_min_val: 200 |
| 234 |
load_past_max_val: 500 |
| 235 |
load_past_min_val: 50 |
| 236 |
port_load_current: true |
| 237 |
port_load_exponent: 7 |
| 238 |
port_load_future: true |
| 239 |
port_load_future_weight: 9 |
| 240 |
port_load_past: true |
| 241 |
port_load_past_weight: 11 |
| 242 |
random_seed: 800000 |
| 243 |
sampling_interval: 140 |
| 244 |
port_bindings: |
| 245 |
- name: Ethernet20 |
| 246 |
profile: pp1 |
| 247 |
switch_binding: |
| 248 |
profile: p1 |
| 249 |
state: merged |
| 250 |
|
| 251 |
# After state: |
| 252 |
# ------------ |
| 253 |
# |
| 254 |
# sonic# show running-configuration ars |
| 255 |
# ars profile p1 |
| 256 |
# sampling-interval 140 |
| 257 |
# random-seed 800000 |
| 258 |
# port-load-past-weight 11 |
| 259 |
# port-load-future-weight 9 |
| 260 |
# port-load-current |
| 261 |
# port-load-exponent 7 |
| 262 |
# load-past-min-val 50 |
| 263 |
# load-past-max-val 500 |
| 264 |
# load-future-min-val 200 |
| 265 |
# load-future-max-val 20000 |
| 266 |
# load-current-min-val 100 |
| 267 |
# load-current-max-val 10000 |
| 268 |
# ! |
| 269 |
# ars port-profile pp1 |
| 270 |
# enable |
| 271 |
# load-past-weight 20 |
| 272 |
# load-future-weight 9 |
| 273 |
# ! |
| 274 |
# ars object obj1 |
| 275 |
# idle-time 100 |
| 276 |
# max-flows 1024 |
| 277 |
# ! |
| 278 |
# interface Ethernet20 |
| 279 |
# mtu 9100 |
| 280 |
# speed 400000 |
| 281 |
# fec RS |
| 282 |
# unreliable-los auto |
| 283 |
# shutdown |
| 284 |
# ars bind pp1 |
| 285 |
# ! |
| 286 |
# ars bind profile p1 |
| 287 |
|
| 288 |
|
| 289 |
# Using "replaced" state |
| 290 |
# |
| 291 |
# Before state: |
| 292 |
# ------------- |
| 293 |
# |
| 294 |
# sonic# show running-configuration ars |
| 295 |
# ars profile p1 |
| 296 |
# sampling-interval 140 |
| 297 |
# random-seed 800000 |
| 298 |
# port-load-past-weight 11 |
| 299 |
# port-load-future-weight 9 |
| 300 |
# port-load-current |
| 301 |
# port-load-exponent 7 |
| 302 |
# load-past-min-val 50 |
| 303 |
# load-past-max-val 500 |
| 304 |
# load-future-min-val 200 |
| 305 |
# load-future-max-val 20000 |
| 306 |
# load-current-min-val 100 |
| 307 |
# load-current-max-val 10000 |
| 308 |
# ! |
| 309 |
# ars port-profile pp1 |
| 310 |
# enable |
| 311 |
# load-past-weight 20 |
| 312 |
# load-future-weight 9 |
| 313 |
# ! |
| 314 |
# ars object obj1 |
| 315 |
# idle-time 100 |
| 316 |
# max-flows 1024 |
| 317 |
# ! |
| 318 |
# interface Ethernet20 |
| 319 |
# mtu 9100 |
| 320 |
# speed 400000 |
| 321 |
# fec RS |
| 322 |
# unreliable-los auto |
| 323 |
# shutdown |
| 324 |
# ars bind pp1 |
| 325 |
# ! |
| 326 |
# ars bind profile p1 |
| 327 |
|
| 328 |
- name: Replace ARS configuration |
| 329 |
dellemc.enterprise_sonic.sonic_ars: |
| 330 |
config: |
| 331 |
port_profiles: |
| 332 |
- name: pp2 |
| 333 |
enable: true |
| 334 |
load_future_weight: 8 |
| 335 |
load_past_weight: 15 |
| 336 |
port_bindings: |
| 337 |
- name: Ethernet20 |
| 338 |
profile: pp2 |
| 339 |
state: replaced |
| 340 |
|
| 341 |
# After state: |
| 342 |
# ------------ |
| 343 |
# |
| 344 |
# sonic# show running-configuration ars |
| 345 |
# ars profile p1 |
| 346 |
# sampling-interval 140 |
| 347 |
# random-seed 800000 |
| 348 |
# port-load-past-weight 11 |
| 349 |
# port-load-future-weight 9 |
| 350 |
# port-load-current |
| 351 |
# port-load-exponent 7 |
| 352 |
# load-past-min-val 50 |
| 353 |
# load-past-max-val 500 |
| 354 |
# load-future-min-val 200 |
| 355 |
# load-future-max-val 20000 |
| 356 |
# load-current-min-val 100 |
| 357 |
# load-current-max-val 10000 |
| 358 |
# ! |
| 359 |
# ars port-profile pp2 |
| 360 |
# enable |
| 361 |
# load-past-weight 15 |
| 362 |
# load-future-weight 8 |
| 363 |
# ! |
| 364 |
# ars object obj1 |
| 365 |
# idle-time 100 |
| 366 |
# max-flows 1024 |
| 367 |
# ! |
| 368 |
# interface Ethernet20 |
| 369 |
# mtu 9100 |
| 370 |
# speed 400000 |
| 371 |
# fec RS |
| 372 |
# unreliable-los auto |
| 373 |
# shutdown |
| 374 |
# ars bind pp2 |
| 375 |
# ! |
| 376 |
# ars bind profile p1 |
| 377 |
|
| 378 |
|
| 379 |
# Using "overridden" state |
| 380 |
# |
| 381 |
# Before state: |
| 382 |
# ------------- |
| 383 |
# |
| 384 |
# sonic# show running-configuration ars |
| 385 |
# ars profile p1 |
| 386 |
# sampling-interval 140 |
| 387 |
# random-seed 800000 |
| 388 |
# port-load-past-weight 11 |
| 389 |
# port-load-future-weight 9 |
| 390 |
# port-load-current |
| 391 |
# port-load-exponent 7 |
| 392 |
# load-past-min-val 50 |
| 393 |
# load-past-max-val 500 |
| 394 |
# load-future-min-val 200 |
| 395 |
# load-future-max-val 20000 |
| 396 |
# load-current-min-val 100 |
| 397 |
# load-current-max-val 10000 |
| 398 |
# ! |
| 399 |
# ars port-profile pp2 |
| 400 |
# enable |
| 401 |
# load-past-weight 15 |
| 402 |
# load-future-weight 8 |
| 403 |
# ! |
| 404 |
# ars object obj1 |
| 405 |
# idle-time 100 |
| 406 |
# max-flows 1024 |
| 407 |
# ! |
| 408 |
# interface Ethernet20 |
| 409 |
# mtu 9100 |
| 410 |
# speed 400000 |
| 411 |
# fec RS |
| 412 |
# unreliable-los auto |
| 413 |
# shutdown |
| 414 |
# ars bind pp1 |
| 415 |
# ! |
| 416 |
# ars bind profile p1 |
| 417 |
|
| 418 |
- name: Override ARS configuration |
| 419 |
dellemc.enterprise_sonic.sonic_ars: |
| 420 |
config: |
| 421 |
ars_objects: |
| 422 |
- name: obj4 |
| 423 |
idle_time: 65 |
| 424 |
max_flows: 4096 |
| 425 |
mode: flowlet-quality |
| 426 |
state: overridden |
| 427 |
|
| 428 |
# After state: |
| 429 |
# ------------ |
| 430 |
# |
| 431 |
# sonic# show running-configuration ars |
| 432 |
# ars object obj4 |
| 433 |
# idle-time 65 |
| 434 |
# max-flows 4096 |
| 435 |
|
| 436 |
|
| 437 |
# Using "deleted" state |
| 438 |
# |
| 439 |
# Before state: |
| 440 |
# ------------- |
| 441 |
# |
| 442 |
# sonic# show running-configuration ars |
| 443 |
# ars profile p1 |
| 444 |
# sampling-interval 140 |
| 445 |
# random-seed 800000 |
| 446 |
# port-load-past-weight 11 |
| 447 |
# port-load-future-weight 9 |
| 448 |
# port-load-current |
| 449 |
# port-load-exponent 7 |
| 450 |
# load-past-min-val 50 |
| 451 |
# load-past-max-val 500 |
| 452 |
# load-future-min-val 200 |
| 453 |
# load-future-max-val 20000 |
| 454 |
# load-current-min-val 100 |
| 455 |
# load-current-max-val 10000 |
| 456 |
# ! |
| 457 |
# ars port-profile pp2 |
| 458 |
# enable |
| 459 |
# load-past-weight 15 |
| 460 |
# load-future-weight 8 |
| 461 |
|
| 462 |
- name: Delete specified ARS configuration |
| 463 |
dellemc.enterprise_sonic.sonic_ars: |
| 464 |
config: |
| 465 |
port_profiles: |
| 466 |
- name: pp2 |
| 467 |
profiles: |
| 468 |
- name: p1 |
| 469 |
load_current_max_val: 10000 |
| 470 |
load_future_max_val: 20000 |
| 471 |
load_past_max_val: 500 |
| 472 |
random_seed: 800000 |
| 473 |
sampling_interval: 140 |
| 474 |
state: deleted |
| 475 |
|
| 476 |
# After state: |
| 477 |
# ------------ |
| 478 |
# |
| 479 |
# sonic# show running-configuration ars |
| 480 |
# ars profile p1 |
| 481 |
# port-load-past-weight 11 |
| 482 |
# port-load-future-weight 9 |
| 483 |
# port-load-current |
| 484 |
# port-load-exponent 7 |
| 485 |
# load-past-min-val 50 |
| 486 |
# load-future-min-val 200 |
| 487 |
# load-current-min-val 100 |
| 488 |
|
| 489 |
|
| 490 |
# Using "deleted" state |
| 491 |
# |
| 492 |
# Before state: |
| 493 |
# ------------- |
| 494 |
# |
| 495 |
# sonic# show running-configuration ars |
| 496 |
# ars profile p1 |
| 497 |
# sampling-interval 140 |
| 498 |
# random-seed 800000 |
| 499 |
# port-load-past-weight 11 |
| 500 |
# port-load-future-weight 9 |
| 501 |
# port-load-current |
| 502 |
# port-load-exponent 7 |
| 503 |
# load-past-min-val 50 |
| 504 |
# load-past-max-val 500 |
| 505 |
# load-future-min-val 200 |
| 506 |
# load-future-max-val 20000 |
| 507 |
# load-current-min-val 100 |
| 508 |
# load-current-max-val 10000 |
| 509 |
# ! |
| 510 |
# ars port-profile pp1 |
| 511 |
# enable |
| 512 |
# load-past-weight 20 |
| 513 |
# load-future-weight 9 |
| 514 |
# ! |
| 515 |
# ars object obj1 |
| 516 |
# idle-time 100 |
| 517 |
# max-flows 1024 |
| 518 |
# ! |
| 519 |
# interface Ethernet20 |
| 520 |
# mtu 9100 |
| 521 |
# speed 400000 |
| 522 |
# fec RS |
| 523 |
# unreliable-los auto |
| 524 |
# shutdown |
| 525 |
# ars bind pp1 |
| 526 |
# ! |
| 527 |
# ars bind profile p1 |
| 528 |
|
| 529 |
- name: Delete all ARS configuration |
| 530 |
dellemc.enterprise_sonic.sonic_ars: |
| 531 |
config: |
| 532 |
state: deleted |
| 533 |
|
| 534 |
# After state: |
| 535 |
# ------------ |
| 536 |
# |
| 537 |
# sonic# show running-configuration ars |
| 538 |
# (No ARS configuration present) |
| 539 |
""" |
| 540 |
RETURN = """ |
| 541 |
before: |
| 542 |
description: The configuration prior to the module invocation. |
| 543 |
returned: always |
| 544 |
type: dict |
| 545 |
after: |
| 546 |
description: The configuration resulting from module invocation. |
| 547 |
returned: when changed |
| 548 |
type: dict |
| 549 |
after_generated: |
| 550 |
description: The generated configuration from module invocation. |
| 551 |
returned: when C(check_mode) |
| 552 |
type: dict |
| 553 |
commands: |
| 554 |
description: The set of commands pushed to the remote device. |
| 555 |
returned: always |
| 556 |
type: list |
| 557 |
sample: ['command 1', 'command 2', 'command 3'] |
| 558 |
""" |
| 559 |
|
| 560 |
|
| 561 |
from ansible.module_utils.basic import AnsibleModule |
| 562 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.ars.ars import ArsArgs |
| 563 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.ars.ars import Ars |
| 564 |
|
| 565 |
|
| 566 |
def main(): |
| 567 |
""" |
| 568 |
Main entry point for module execution |
| 569 |
|
| 570 |
:returns: the result form module invocation |
| 571 |
""" |
| 572 |
module = AnsibleModule(argument_spec=ArsArgs.argument_spec, |
| 573 |
supports_check_mode=True) |
| 574 |
|
| 575 |
result = Ars(module).execute_module() |
| 576 |
module.exit_json(**result) |
| 577 |
|
| 578 |
|
| 579 |
if __name__ == '__main__': |
| 580 |
main() |