diff --git a/models/enterprise_sonic/mirroring/deleted_example_01.txt b/models/enterprise_sonic/mirroring/deleted_example_01.txt new file mode 100644 index 00000000..c038e381 --- /dev/null +++ b/models/enterprise_sonic/mirroring/deleted_example_01.txt @@ -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 diff --git a/models/enterprise_sonic/mirroring/merged_example_01.txt b/models/enterprise_sonic/mirroring/merged_example_01.txt new file mode 100644 index 00000000..12a0ab53 --- /dev/null +++ b/models/enterprise_sonic/mirroring/merged_example_01.txt @@ -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 diff --git a/models/enterprise_sonic/mirroring/overridden_example_01.txt b/models/enterprise_sonic/mirroring/overridden_example_01.txt new file mode 100644 index 00000000..338568de --- /dev/null +++ b/models/enterprise_sonic/mirroring/overridden_example_01.txt @@ -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 diff --git a/models/enterprise_sonic/mirroring/replaced_example_01.txt b/models/enterprise_sonic/mirroring/replaced_example_01.txt new file mode 100644 index 00000000..6c451417 --- /dev/null +++ b/models/enterprise_sonic/mirroring/replaced_example_01.txt @@ -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 diff --git a/models/enterprise_sonic/mirroring/sonic_mirroring.yaml b/models/enterprise_sonic/mirroring/sonic_mirroring.yaml new file mode 100644 index 00000000..ab725de9 --- /dev/null +++ b/models/enterprise_sonic/mirroring/sonic_mirroring.yaml @@ -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