| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
The module file for sonic_qos_buffer |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
__metaclass__ = type |
| 13 |
|
| 14 |
DOCUMENTATION = """ |
| 15 |
--- |
| 16 |
module: sonic_qos_buffer |
| 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 buffer configuration on SONiC |
| 22 |
description: |
| 23 |
- This module provides configuration management of QoS buffer for devices running SONiC |
| 24 |
author: "S. Talabi (@stalabi1)" |
| 25 |
options: |
| 26 |
config: |
| 27 |
description: |
| 28 |
- QoS buffer configuration |
| 29 |
type: dict |
| 30 |
suboptions: |
| 31 |
buffer_init: |
| 32 |
description: |
| 33 |
- Initialize QoS buffer based on system defaults |
| 34 |
- Buffer must be initialized to configure I(buffer_pools) and I(buffer_profiles) |
| 35 |
type: bool |
| 36 |
version_added: 3.0.0 |
| 37 |
buffer_pools: |
| 38 |
description: |
| 39 |
- Buffer pools configuration |
| 40 |
type: list |
| 41 |
elements: dict |
| 42 |
suboptions: |
| 43 |
name: |
| 44 |
description: |
| 45 |
- Name of buffer pool |
| 46 |
type: str |
| 47 |
choices: |
| 48 |
- ingress_lossless_pool |
| 49 |
required: True |
| 50 |
xoff: |
| 51 |
description: |
| 52 |
- Amount of shared buffer space in bytes, must be less than pool size |
| 53 |
- Required non-key attribute |
| 54 |
type: int |
| 55 |
buffer_profiles: |
| 56 |
description: |
| 57 |
- Buffer profiles configuration |
| 58 |
- I(static_threshold) and I(dynamic_threshold) are mutually exclusive required non-key attributes |
| 59 |
type: list |
| 60 |
elements: dict |
| 61 |
suboptions: |
| 62 |
name: |
| 63 |
description: |
| 64 |
- Name of buffer profile |
| 65 |
type: str |
| 66 |
required: True |
| 67 |
pool: |
| 68 |
description: |
| 69 |
- Name of buffer pool |
| 70 |
- Required non-key attribute |
| 71 |
type: str |
| 72 |
choices: |
| 73 |
- ingress_lossless_pool |
| 74 |
- egress_lossless_pool |
| 75 |
- egress_lossy_pool |
| 76 |
size: |
| 77 |
description: |
| 78 |
- Size of reserved buffer in bytes |
| 79 |
- Required non-key attribute |
| 80 |
type: int |
| 81 |
static_threshold: |
| 82 |
description: |
| 83 |
- Static threshold for the shared usage in bytes |
| 84 |
type: int |
| 85 |
dynamic_threshold: |
| 86 |
description: |
| 87 |
- Dynamic threshold value |
| 88 |
- Range -6-3 |
| 89 |
type: int |
| 90 |
pause_threshold: |
| 91 |
description: |
| 92 |
- Threshold value at which to stop traffic from peer |
| 93 |
- Range 46080-8388608 |
| 94 |
- Configurable for ingress lossless pool |
| 95 |
type: int |
| 96 |
state: |
| 97 |
description: |
| 98 |
- The state of the configuration after module completion |
| 99 |
- Replaced and overridden states are not supported for this module due to configuration constraints |
| 100 |
type: str |
| 101 |
choices: |
| 102 |
- merged |
| 103 |
- deleted |
| 104 |
default: merged |
| 105 |
""" |
| 106 |
|
| 107 |
EXAMPLES = """ |
| 108 |
# Using "merged" state |
| 109 |
# |
| 110 |
# Before state: |
| 111 |
# ------------- |
| 112 |
# |
| 113 |
# sonic# show running-configuration | grep buffer |
| 114 |
# buffer init lossless |
| 115 |
# buffer pool ingress_lossless_pool shared-headroom-size 1000000 |
| 116 |
|
| 117 |
- name: Merge QoS buffer configuration |
| 118 |
dellemc.enterprise_sonic.sonic_qos_buffer: |
| 119 |
config: |
| 120 |
buffer_init: true |
| 121 |
buffer_pools: |
| 122 |
- name: ingress_lossless_pool |
| 123 |
xoff: 3500000 |
| 124 |
buffer_profiles: |
| 125 |
- name: profile1 |
| 126 |
pool: ingress_lossless_pool |
| 127 |
size: 45 |
| 128 |
static_threshold: 25 |
| 129 |
pause_threshold: 55000 |
| 130 |
- name: profile2 |
| 131 |
pool: egress_lossless_pool |
| 132 |
size: 85 |
| 133 |
dynamic_threshold: -2 |
| 134 |
- name: profile3 |
| 135 |
pool: egress_lossy_pool |
| 136 |
size: 90 |
| 137 |
static_threshold: 30 |
| 138 |
state: merged |
| 139 |
|
| 140 |
# After state: |
| 141 |
# ------------ |
| 142 |
# |
| 143 |
# sonic# show running-configuration | grep buffer |
| 144 |
# buffer init lossless |
| 145 |
# buffer pool ingress_lossless_pool shared-headroom-size 3500000 |
| 146 |
# buffer profile profile1 ingress_lossless_pool 45 static-threshold 25 pause pause-threshold 55000 |
| 147 |
# buffer profile profile2 egress_lossy_pool 85 dynamic-threshold -2 |
| 148 |
# buffer profile profile3 egress_lossless_pool 90 static-threshold 30 |
| 149 |
# |
| 150 |
# |
| 151 |
# Using "deleted" state |
| 152 |
# |
| 153 |
# Before state: |
| 154 |
# ------------- |
| 155 |
# |
| 156 |
# sonic# show running-configuration | grep buffer |
| 157 |
# buffer init lossless |
| 158 |
# buffer pool ingress_lossless_pool shared-headroom-size 3500000 |
| 159 |
# buffer profile profile1 ingress_lossless_pool 45 static-threshold 25 pause pause-threshold 55000 |
| 160 |
# buffer profile profile2 egress_lossy_pool 85 dynamic-threshold -2 |
| 161 |
# buffer profile profile3 egress_lossless_pool 90 static-threshold 30 |
| 162 |
|
| 163 |
- name: Delete QoS buffer profile configuration |
| 164 |
dellemc.enterprise_sonic.sonic_qos_buffer: |
| 165 |
config: |
| 166 |
buffer_profiles: |
| 167 |
- name: profile1 |
| 168 |
static_threshold: 25 |
| 169 |
pause_threshold: 55000 |
| 170 |
- name: profile2 |
| 171 |
dynamic_threshold: -2 |
| 172 |
- name: profile3 |
| 173 |
state: deleted |
| 174 |
|
| 175 |
# After state: |
| 176 |
# ------------ |
| 177 |
# |
| 178 |
# sonic# show running-configuration | grep buffer |
| 179 |
# buffer init lossless |
| 180 |
# buffer pool ingress_lossless_pool shared-headroom-size 3500000 |
| 181 |
# buffer profile profile1 ingress_lossless_pool 45 |
| 182 |
# buffer profile profile2 egress_lossy_pool 85 |
| 183 |
""" |
| 184 |
|
| 185 |
RETURN = """ |
| 186 |
before: |
| 187 |
description: The configuration prior to the model invocation. |
| 188 |
returned: always |
| 189 |
type: list |
| 190 |
sample: > |
| 191 |
The configuration returned will always be in the same format |
| 192 |
of the parameters above. |
| 193 |
after: |
| 194 |
description: The resulting configuration model invocation. |
| 195 |
returned: when changed |
| 196 |
type: list |
| 197 |
sample: > |
| 198 |
The configuration returned will always be in the same format |
| 199 |
of the parameters above. |
| 200 |
after_generated: |
| 201 |
description: The generated configuration model invocation. |
| 202 |
returned: when C(check_mode) |
| 203 |
type: list |
| 204 |
sample: > |
| 205 |
The configuration returned will always be in the same format |
| 206 |
of the parameters above. |
| 207 |
commands: |
| 208 |
description: The set of commands pushed to the remote device. |
| 209 |
returned: always |
| 210 |
type: list |
| 211 |
sample: ['command 1', 'command 2', 'command 3'] |
| 212 |
""" |
| 213 |
|
| 214 |
|
| 215 |
from ansible.module_utils.basic import AnsibleModule |
| 216 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.qos_buffer.qos_buffer import Qos_bufferArgs |
| 217 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.qos_buffer.qos_buffer import Qos_buffer |
| 218 |
|
| 219 |
|
| 220 |
def main(): |
| 221 |
""" |
| 222 |
Main entry point for module execution |
| 223 |
|
| 224 |
:returns: the result form module invocation |
| 225 |
""" |
| 226 |
module = AnsibleModule(argument_spec=Qos_bufferArgs.argument_spec, |
| 227 |
supports_check_mode=True) |
| 228 |
|
| 229 |
result = Qos_buffer(module).execute_module() |
| 230 |
module.exit_json(**result) |
| 231 |
|
| 232 |
|
| 233 |
if __name__ == '__main__': |
| 234 |
main() |