| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
The module file for sonic_qos_pfc |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
__metaclass__ = type |
| 13 |
|
| 14 |
DOCUMENTATION = """ |
| 15 |
--- |
| 16 |
module: sonic_qos_pfc |
| 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 PFC configuration on SONiC |
| 22 |
description: |
| 23 |
- This module provides configuration management of QoS PFC for devices running SONiC |
| 24 |
author: "S. Talabi (@stalabi1)" |
| 25 |
options: |
| 26 |
config: |
| 27 |
description: |
| 28 |
- QoS PFC configuration |
| 29 |
type: dict |
| 30 |
suboptions: |
| 31 |
counter_poll: |
| 32 |
description: |
| 33 |
- Enable or disable use of flex-counters for PFC watchdog |
| 34 |
type: bool |
| 35 |
default: True |
| 36 |
poll_interval: |
| 37 |
description: |
| 38 |
- Polling interval for PFC watchdog |
| 39 |
- Range 100-3000 |
| 40 |
type: int |
| 41 |
state: |
| 42 |
description: |
| 43 |
- The state of the configuration after module completion. |
| 44 |
type: str |
| 45 |
choices: |
| 46 |
- merged |
| 47 |
- deleted |
| 48 |
- overridden |
| 49 |
- replaced |
| 50 |
default: merged |
| 51 |
""" |
| 52 |
|
| 53 |
EXAMPLES = """ |
| 54 |
# Using "merged" state |
| 55 |
# |
| 56 |
# Before state: |
| 57 |
# ------------- |
| 58 |
# |
| 59 |
# sonic# show priority-flow-control watchdog |
| 60 |
# |
| 61 |
# Watchdog Summary |
| 62 |
# ---------------- |
| 63 |
# Polling Interval: : Not Available |
| 64 |
# Flex Counters: : enabled |
| 65 |
|
| 66 |
- name: Merge QoS PFC configurations |
| 67 |
dellemc.enterprise_sonic.sonic_qos_pfc: |
| 68 |
config: |
| 69 |
counter_poll: true |
| 70 |
poll_interval: 150 |
| 71 |
state: merged |
| 72 |
|
| 73 |
# After state: |
| 74 |
# ------------ |
| 75 |
# |
| 76 |
# sonic# show priority-flow-control watchdog |
| 77 |
# |
| 78 |
# Watchdog Summary |
| 79 |
# ---------------- |
| 80 |
# Polling Interval: : 150 |
| 81 |
# Flex Counters: : enabled |
| 82 |
# |
| 83 |
# |
| 84 |
# Using "replaced" state |
| 85 |
# |
| 86 |
# Before state: |
| 87 |
# ------------- |
| 88 |
# |
| 89 |
# sonic# show priority-flow-control watchdog |
| 90 |
# |
| 91 |
# Watchdog Summary |
| 92 |
# ---------------- |
| 93 |
# Polling Interval: : 150 |
| 94 |
# Flex Counters: : enabled |
| 95 |
|
| 96 |
- name: Replace QoS PFC configurations |
| 97 |
dellemc.enterprise_sonic.sonic_qos_pfc: |
| 98 |
config: |
| 99 |
poll_interval: 365 |
| 100 |
state: replaced |
| 101 |
|
| 102 |
# After state: |
| 103 |
# ------------ |
| 104 |
# |
| 105 |
# sonic# show priority-flow-control watchdog |
| 106 |
# |
| 107 |
# Watchdog Summary |
| 108 |
# ---------------- |
| 109 |
# Polling Interval: : 365 |
| 110 |
# Flex Counters: : enabled |
| 111 |
# |
| 112 |
# |
| 113 |
# Using "overridden" state |
| 114 |
# Before state: |
| 115 |
# ------------- |
| 116 |
# |
| 117 |
# sonic# show priority-flow-control watchdog |
| 118 |
# |
| 119 |
# Watchdog Summary |
| 120 |
# ---------------- |
| 121 |
# Polling Interval: : 365 |
| 122 |
# Flex Counters: : enabled |
| 123 |
|
| 124 |
- name: Override QoS PFC configurations |
| 125 |
dellemc.enterprise_sonic.sonic_qos_pfc: |
| 126 |
config: |
| 127 |
counter_poll: false |
| 128 |
poll_interval: 400 |
| 129 |
state: overridden |
| 130 |
|
| 131 |
# After state: |
| 132 |
# ------------ |
| 133 |
# |
| 134 |
# sonic# show priority-flow-control watchdog |
| 135 |
# |
| 136 |
# Watchdog Summary |
| 137 |
# ---------------- |
| 138 |
# Polling Interval: : 400 |
| 139 |
# Flex Counters: : disabled |
| 140 |
# |
| 141 |
# |
| 142 |
# Using "deleted" state |
| 143 |
# |
| 144 |
# Before state: |
| 145 |
# ------------- |
| 146 |
# |
| 147 |
# sonic# show priority-flow-control watchdog |
| 148 |
# |
| 149 |
# Watchdog Summary |
| 150 |
# ---------------- |
| 151 |
# Polling Interval: : 400 |
| 152 |
# Flex Counters: : disabled |
| 153 |
|
| 154 |
- name: Delete QoS PFC configurations |
| 155 |
dellemc.enterprise_sonic.sonic_qos_pfc: |
| 156 |
config: |
| 157 |
counter_poll: false |
| 158 |
poll_interval: 400 |
| 159 |
state: deleted |
| 160 |
|
| 161 |
# After state: |
| 162 |
# ------------ |
| 163 |
# |
| 164 |
# sonic# show priority-flow-control watchdog |
| 165 |
# |
| 166 |
# Watchdog Summary |
| 167 |
# ---------------- |
| 168 |
# Polling Interval: : Not Available |
| 169 |
# Flex Counters: : enabled |
| 170 |
""" |
| 171 |
|
| 172 |
RETURN = """ |
| 173 |
before: |
| 174 |
description: The configuration prior to the module invocation. |
| 175 |
returned: always |
| 176 |
type: list |
| 177 |
sample: > |
| 178 |
The configuration returned will always be in the same format |
| 179 |
as the parameters above. |
| 180 |
after: |
| 181 |
description: The resulting configuration module invocation. |
| 182 |
returned: when changed |
| 183 |
type: list |
| 184 |
sample: > |
| 185 |
The configuration returned will always be in the same format |
| 186 |
as the parameters above. |
| 187 |
after_generated: |
| 188 |
description: The generated configuration module invocation. |
| 189 |
returned: when C(check_mode) |
| 190 |
type: list |
| 191 |
sample: > |
| 192 |
The configuration returned will always be in the same format |
| 193 |
as the parameters above. |
| 194 |
commands: |
| 195 |
description: The set of commands pushed to the remote device. |
| 196 |
returned: always |
| 197 |
type: list |
| 198 |
sample: ['command 1', 'command 2', 'command 3'] |
| 199 |
""" |
| 200 |
|
| 201 |
|
| 202 |
from ansible.module_utils.basic import AnsibleModule |
| 203 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.qos_pfc.qos_pfc import Qos_pfcArgs |
| 204 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.qos_pfc.qos_pfc import Qos_pfc |
| 205 |
|
| 206 |
|
| 207 |
def main(): |
| 208 |
""" |
| 209 |
Main entry point for module execution |
| 210 |
|
| 211 |
:returns: the result form module invocation |
| 212 |
""" |
| 213 |
module = AnsibleModule(argument_spec=Qos_pfcArgs.argument_spec, |
| 214 |
supports_check_mode=True) |
| 215 |
|
| 216 |
result = Qos_pfc(module).execute_module() |
| 217 |
module.exit_json(**result) |
| 218 |
|
| 219 |
|
| 220 |
if __name__ == '__main__': |
| 221 |
main() |