Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sonic_mirroring resource model #268

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions models/enterprise_sonic/mirroring/deleted_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Using deleted
#
# Before state:
# -------------
#sonic(config)# do show mirror-session
#ERSPAN Sessions
#-----------------------------------------------------------------------------------------------------------------------------------------
#Name Status SRC-IP DST-IP GRE DSCP TTL Queue Policer SRC-Port Direction
#-----------------------------------------------------------------------------------------------------------------------------------------
#dell-2 inactive 200.22.22.22 100.11.11.11 0 Ethernet28 both
#SPAN Sessions
#-------------------------------------------------------------------------------
#Name Status DST-Port SRC-Port Direction
#-------------------------------------------------------------------------------
#dell-1 active CPU Ethernet24 both
#dell-3 active CPU
#
# - name: Merge some configuration
# sonic_mirroring:
# config:
# span:
# - name: dell-3
# erspan:
# - name: dell-2
# state: deleted
#
# After state:
# ------------
#sonic(config)# do show mirror-session
#SPAN Sessions
#-------------------------------------------------------------------------------
#Name Status DST-Port SRC-Port Direction
#-------------------------------------------------------------------------------
#dell-1 active CPU Ethernet24 both
41 changes: 41 additions & 0 deletions models/enterprise_sonic/mirroring/merged_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Using merged
#
# Before state:
# -------------
#
#sonic(config)# do show mirror-session
#No sessions configured
#---------------------------------------------------------
#RADIUS Global Configuration
#---------------------------------------------------------
#
# - name: Merge some configuration
# sonic_mirroring:
# config:
# span:
# - name: dell-1
# dst_port: CPU
# source: Ethernet24
# direction: both
# erspan:
# - name: dell-2
# dst_ip: 100.11.11.11
# src_ip: 200.22.22.22
# source: Ethernet28
# direction: both
# queue: 0
# state: merged
#
# After state:
# ------------
#sonic(config)# do show mirror-session
#ERSPAN Sessions
#-----------------------------------------------------------------------------------------------------------------------------------------
#Name Status SRC-IP DST-IP GRE DSCP TTL Queue Policer SRC-Port Direction
#-----------------------------------------------------------------------------------------------------------------------------------------
#dell-2 inactive 200.22.22.22 100.11.11.11 0 Ethernet28 both
#SPAN Sessions
#-------------------------------------------------------------------------------
#Name Status DST-Port SRC-Port Direction
#-------------------------------------------------------------------------------
#dell-1 active CPU Ethernet24 both
57 changes: 57 additions & 0 deletions models/enterprise_sonic/mirroring/overridden_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Using overridden
#
# Before state:
# -------------
#
#sonic(config)# do show mirror-session
#ERSPAN Sessions
#-----------------------------------------------------------------------------------------------------------------------------------------
#Name Status SRC-IP DST-IP GRE DSCP TTL Queue Policer SRC-Port Direction
#-----------------------------------------------------------------------------------------------------------------------------------------
#dell-2 inactive 200.22.22.22 100.11.11.11 0 Ethernet28 both
#SPAN Sessions
#-------------------------------------------------------------------------------
#Name Status DST-Port SRC-Port Direction
#-------------------------------------------------------------------------------
#dell-1 active CPU Ethernet24 both
#dell-3 active CPU
#
# - name: Override mirrot session configuration
# sonic_mirroring:
# config:
# erspan:
# - name: dell-2
# dst_ip: 32.22.22.12
# src_ip: 31.21.21.12
# source: Ethernet28
# gre: "0x6689"
# dscp: 6
# ttl: 9
# queue: 0
# direction: rx
# - name: dell-1
# dst_ip: 22.22.22.12
# src_ip: 21.21.21.12
# source: Ethernet28
# direction: rx
# span:
# - name: dell-6
# dst_port: CPU
# source: Ethernet24
# direction: tx
# state: overridden
#
# After state:
# ------------
#sonic(config)# do show mirror-session
#ERSPAN Sessions
#-----------------------------------------------------------------------------------------------------------------------------------------
#Name Status SRC-IP DST-IP GRE DSCP TTL Queue Policer SRC-Port Direction
#-----------------------------------------------------------------------------------------------------------------------------------------
#dell-1 inactive 21.21.21.12 22.22.22.12 Ethernet28 rx
#dell-2 inactive 31.21.21.12 32.22.22.12 0x6689 6 9 0 Ethernet28 rx
#SPAN Sessions
#-------------------------------------------------------------------------------
#Name Status DST-Port SRC-Port Direction
#-------------------------------------------------------------------------------
#dell-6 active Ethertnet4 Ethernet24 tx
58 changes: 58 additions & 0 deletions models/enterprise_sonic/mirroring/replaced_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Using replaced
#
# Before state:
# -------------
#
#sonic(config)# do show mirror-session
#ERSPAN Sessions
#-----------------------------------------------------------------------------------------------------------------------------------------
#Name Status SRC-IP DST-IP GRE DSCP TTL Queue Policer SRC-Port Direction
#-----------------------------------------------------------------------------------------------------------------------------------------
#dell-2 inactive 200.22.22.22 100.11.11.11 0 Ethernet28 both
#SPAN Sessions
#-------------------------------------------------------------------------------
#Name Status DST-Port SRC-Port Direction
#-------------------------------------------------------------------------------
#dell-1 active CPU Ethernet24 both
#dell-3 active CPU
#
# - name: Replace some configuration
# sonic_mirroring:
# config:
# erspan:
# - name: dell-2
# dst_ip: 32.22.22.12
# src_ip: 31.21.21.12
# source: Ethernet28
# dscp: 6
# gre: "0x6689"
# ttl: 9
# queue: 0
# direction: rx
# - name: dell-3
# dst_ip: 22.22.22.12
# src_ip: 21.21.21.12
# source: Ethernet28
# direction: rx
# span:
# - name: dell-1
# dst_port: Ethernet4
# source: Ethernet24
# direction: tx
# state: replaced
#
# After state:
# ------------
#sonic(config)# do show mirror-session
#ERSPAN Sessions
#-----------------------------------------------------------------------------------------------------------------------------------------
#Name Status SRC-IP DST-IP GRE DSCP TTL Queue Policer SRC-Port Direction
#-----------------------------------------------------------------------------------------------------------------------------------------
#dell-2 inactive 32.22.22.22 31.11.11.11 0x6689 6 9 0 Ethernet28 rx
#dell-3 inactive 21.21.21.12 22.22.22.12 Ethernet28 rx
#SPAN Sessions
#-------------------------------------------------------------------------------
#Name Status DST-Port SRC-Port Direction
#-------------------------------------------------------------------------------
#dell-1 active Ethertnet4 Ethernet24 tx
#dell-3 active CPU
129 changes: 129 additions & 0 deletions models/enterprise_sonic/mirroring/sonic_mirroring.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
GENERATOR_VERSION: '1.0'
ANSIBLE_METADATA: |
{
'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community',
'license': 'Apache 2.0'
}
NETWORK_OS: sonic
RESOURCE: mirroring
COPYRIGHT: "© Copyright 2024 Dell Inc. or its subsidiaries. All Rights Reserved"
LICENSE: gpl-3.0.txt
DOCUMENTATION: |
module: sonic_mirroring
version_added: "3.0.0"
author: "M. Zhang (@mingjunzhang2019)"
short_description: port mirroring configuration handling for SONiC.
description:
- This module provides configuration management for mirroring on devices running SONiC.
options:
config:
description:
- Specifies port mirroring configuration.
type: dict
suboptions:
span:
description:
- SPAN mirroring sessions.
type: list
elements: dict
suboptions:
name:
description:
- SPAN mirroring session name.
required: true
type: str
dst_port:
description:
- Mirror session destination interface.
- It may be CPU or an Ethernet interface.
type: str
source:
description:
- Mirror session source interface.
- It may be an Ethernet interface or a PortChannel interface.
type: str
direction:
description:
- Mirror session direction.
type: str
choices:
- rx
- tx
- both
erspan:
description:
- ERSPAN mirroring sessions.
type: list
elements: dict
suboptions:
name:
description:
- ERSPAN mirroring session name.
required: true
type: str
dst_ip:
description:
- ERSPAN destination IP address.
type: str
src_ip:
description:
- ERSPAN source IP address.
type: str
source:
description:
- Mirror session source interface.
- It may be an Ethernet interface or a PortChannel interface.
type: str
direction:
description:
- Mirror session direction.
type: str
choices:
- rx
- tx
- both
dscp:
description:
- ERSPAN destination DSCP.
- The range of values is 0-63
type: int
gre:
description:
- ERSPAN destination GRE type.
- A Hexadecimal string which must be quoted.
type: str
ttl:
description:
- ERSPAN destination TTL.
- The range of values is 0-63.
type: int
queue:
description:
- ERSPAN destination queue number.
- The range of values is 0-63.
- Only queue 0 is supported.
type: int
state:
description:
- Specifies the operation to be performed on the mirroring configured on the device.
- In case of merged, the input configuration will be merged with the existing mirroring on the device.
- In case of deleted, the existing mirroring configuration will be removed from the device.
- In case of overridden, all existing mirroring will be deleted and the specified input configuration will be add.
- In case of replaced, the existing mirroring on the device will be replaced by the configuration for
- each mirroring.
type: str
choices:
- merged
- deleted
- replaced
- overridden
default: merged

EXAMPLES:
- deleted_example_01.txt
- merged_example_01.txt
- replaced_example_01.txt
- overridden_example_01.txt