dellemc.enterprise_sonic.sonic_copp 模块 – 在 SONiC 上管理 CoPP 配置

注意

此模块是 dellemc.enterprise_sonic 集合 (版本 2.5.1) 的一部分。

如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install dellemc.enterprise_sonic

要在 playbook 中使用它,请指定: dellemc.enterprise_sonic.sonic_copp

dellemc.enterprise_sonic 2.1.0 中的新增功能

概要

  • 此模块提供运行 SONiC 的设备的 CoPP 配置管理。

参数

参数

注释

config

字典

指定 CoPP 配置

copp_groups

列表 / 元素=字典

构成 CoPP 组的 CoPP 条目的列表

cbs

字符串

已提交的桶大小(以数据包或字节为单位)

cir

字符串

已提交的信息速率(以 bps 或 pps(每秒数据包数)为单位)

copp_name

字符串 / 必需

CoPP 分类器的名称

queue

整数

CoPP 队列 ID

trap_action

字符串

CoPP 陷阱操作

trap_priority

整数

CoPP 陷阱优先级

state

字符串

模块完成后的配置状态

选项

  • "merged" ← (默认)

  • "deleted"

  • "replaced"

  • "overridden"

备注

注意

  • 针对戴尔科技公司提供的企业 SONiC 发行版进行了测试。

  • 支持 check_mode

示例

# Using merged
#
# Before state:
# -------------
#
# sonic# show copp actions
# (No "copp actions" configuration present)

  - name: Merge CoPP groups configuration
    dellemc.enterprise_sonic.sonic_copp:
    config:
      copp_groups:
        - copp_name: 'copp-1'
          trap_priority: 1
          trap_action: 'DROP'
          queue: 1
          cir: '45'
          cbs: '45'
        - copp_name: 'copp-2'
          trap_priority: 2
          trap_action: 'FORWARD'
          queue: 2
          cir: '90'
          cbs: '90'
    state: merged

# After state:
# ------------
#
# sonic# show copp actions
# CoPP action group copp-1
#    trap-action drop
#    trap-priority 1
#    trap-queue 1
#    police cir 45 cbs 45
# CoPP action group copp-2
#    trap-action forward
#    trap-priority 2
#    trap-queue 2
#    police cir 90 cbs 90
#
#
# Using replaced
#
# Before state:
# -------------
#
# sonic# show copp actions
# CoPP action group copp-1
#    trap-action drop
#    trap-priority 1
#    trap-queue 1
#    police cir 45 cbs 45

  - name: Replace CoPP groups configuration
    dellemc.enterprise_sonic.sonic_copp:
    config:
      copp_groups:
        - copp_name: 'copp-1'
          trap_priority: 2
          trap_action: 'FORWARD'
          queue: 2
        - copp_name: 'copp-3'
          trap_priority: 3
          trap_action: 'DROP'
          queue: 3
          cir: '1000'
          cbs: '1000'
    state: replaced

# After state:
# ------------
#
# sonic# show copp actions
# CoPP action group copp-1
#    trap-action forward
#    trap-priority 2
#    trap-queue 2
# CoPP action group copp-3
#    trap-action drop
#    trap-priority 3
#    trap-queue 3
#    police cir 1000 cbs 1000
#
#
# Using overridden
#
# Before state:
# -------------
#
# sonic# show copp actions
# CoPP action group copp-1
#    trap-action forward
#    trap-priority 2
#    trap-queue 2
# CoPP action group copp-3
#    trap-action drop
#    trap-priority 3
#    trap-queue 3
#    police cir 1000 cbs 1000

  - name: Override CoPP groups configuration
    dellemc.enterprise_sonic.sonic_copp:
    config:
      copp_groups:
        - copp_name: 'copp-4'
          trap_priority: 4
          trap_action: 'FORWARD'
          queue: 4
          cir: 200
          cbs: 200
    state: overridden

# After state:
# ------------
#
# sonic# show copp actions
# CoPP action group copp-4
#    trap-action forward
#    trap-priority 4
#    trap-queue 4
#    police cir 200 cbs 200
#
#
# Using deleted
#
# Before state:
# -------------
#
# sonic# show copp actions
# CoPP action group copp-1
#    trap-action drop
#    trap-priority 1
#    trap-queue 1
#    police cir 45 cbs 45
# CoPP action group copp-2
#    trap-action forward
#    trap-priority 2
#    trap-queue 2
#    police cir 90 cbs 90

  - name: Delete CoPP groups configuration
    dellemc.enterprise_sonic.sonic_copp:
    config:
      copp_groups:
        - copp_name: 'copp-1'
          trap_action: 'DROP'
          cir: '45'
          cbs: '45'
        - copp_name: 'copp-2'
    state: deleted

# After state:
# ------------
#
# sonic# show copp actions
# CoPP action group copp-1
#    trap-action drop
#    police cir 45 cbs 45

返回值

常见返回值在此处记录,以下是此模块特有的字段

描述

after

列表 / 元素=字符串

模块调用后的结果配置。

返回:发生更改时

示例: ["The configuration returned will always be in the same format as the parameters above.\n"]

after(generated)

列表 / 元素=字符串

生成的配置模块调用。

返回:check_mode

示例: ["The configuration returned will always be in the same format as the parameters above.\n"]

before

列表 / 元素=字符串

模块调用之前的配置。

返回:始终返回

示例: ["The configuration returned will always be in the same format as the parameters above.\n"]

commands

列表 / 元素=字符串

推送到远程设备的命令集。

返回:始终返回

示例: ["command 1", "command 2", "command 3"]

作者

  • Shade Talabi (@stalabi1)