[yang] Add collector_vrf to sflow yang model (#12897)

- Why I did it
Fixed sflow yang model to include collector_vrf field.

- How I did it
Added leaf for collector_vrf under sflow_collector. Additionally aligned the configuration guide

- How to verify it
Added UT to verify.
This commit is contained in:
Sudharsan Dhamal Gopalarathnam 2022-12-01 09:30:32 -08:00 committed by mssonicbld
parent 2e760823c1
commit ce8ffb6812
5 changed files with 191 additions and 58 deletions

View File

@ -3,70 +3,71 @@
Table of Contents
=================
* [Introduction](#introduction)
* [Configuration](#configuration)
* [<strong>Config Load and Save</strong>](#config-load-and-save)
* [Incremental Configuration](#incremental-configuration)
* [<strong>Redis and Json Schema</strong>](#redis-and-json-schema)
* [ACL and Mirroring](#acl-and-mirroring)
* [BGP Device Global](#bgp-device-global)
* [BGP Sessions](#bgp-sessions)
* [BUFFER_PG](#buffer_pg)
* [Buffer pool](#buffer-pool)
* [Buffer profile](#buffer-profile)
* [Buffer queue](#buffer-queue)
* [Buffer port ingress profile list](#buffer-port-ingress-profile-list)
* [Buffer port egress profile list](#buffer-port-egress-profile-list)
* [Cable length](#cable-length)
* [COPP_TABLE](#copp_table)
* [Console](#console)
* [CRM](#crm)
* [Data Plane L3 Interfaces](#data-plane-l3-interfaces)
* [DEFAULT_LOSSLESS_BUFFER_PARAMETER](#DEFAULT_LOSSLESS_BUFFER_PARAMETER)
* [Device Metadata](#device-metadata)
* [Device neighbor metada](#device-neighbor-metada)
* [DSCP_TO_TC_MAP](#dscp_to_tc_map)
* [FLEX_COUNTER_TABLE](#flex_counter_table)
* [KDUMP](#kdump)
* [Kubernetes Master](#kubernetes-master)
* [L2 Neighbors](#l2-neighbors)
* [Loopback Interface](#loopback-interface)
* [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN)
* [Management Interface](#management-interface)
* [Management port](#management-port)
* [Management VRF](#management-vrf)
* [MAP_PFC_PRIORITY_TO_QUEUE](#map_pfc_priority_to_queue)
* [MUX_CABLE](#muxcable)
* [NTP Global Configuration](#ntp-global-configuration)
* [NTP and SYSLOG servers](#ntp-and-syslog-servers)
* [Peer Switch](#peer-switch)
* [Policer](#policer)
* [Port](#port)
* [Port Channel](#port-channel)
* [Portchannel member](#portchannel-member)
* [Scheduler](#scheduler)
* [Port QoS Map](#port-qos-map)
* [Queue](#queue)
* [Restapi](#restapi)
* [SYSLOG Rate Limit](#syslog-rate-limit)
* [Tacplus Server](#tacplus-server)
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
* [Telemetry](#telemetry)
* [Versions](#versions)
* [VLAN](#vlan)
* [VLAN_MEMBER](#vlan_member)
* [VOQ Inband Interface](#voq-inband-interface)
* [VXLAN](#vxlan)
* [Introduction](#introduction)
* [Configuration](#configuration)
* [<strong>Config Load and Save</strong>](#config-load-and-save)
* [Incremental Configuration](#incremental-configuration)
* [<strong>Redis and Json Schema</strong>](#redis-and-json-schema)
* [ACL and Mirroring](#acl-and-mirroring)
* [BGP Device Global](#bgp-device-global)
* [BGP Sessions](#bgp-sessions)
* [BUFFER_PG](#buffer_pg)
* [Buffer pool](#buffer-pool)
* [Buffer profile](#buffer-profile)
* [Buffer queue](#buffer-queue)
* [Buffer port ingress profile list](#buffer-port-ingress-profile-list)
* [Buffer port egress profile list](#buffer-port-egress-profile-list)
* [Cable length](#cable-length)
* [COPP_TABLE](#copp_table)
* [Console](#console)
* [CRM](#crm)
* [Data Plane L3 Interfaces](#data-plane-l3-interfaces)
* [DEFAULT_LOSSLESS_BUFFER_PARAMETER](#DEFAULT_LOSSLESS_BUFFER_PARAMETER)
* [Device Metadata](#device-metadata)
* [Device neighbor metada](#device-neighbor-metada)
* [DSCP_TO_TC_MAP](#dscp_to_tc_map)
* [FLEX_COUNTER_TABLE](#flex_counter_table)
* [KDUMP](#kdump)
* [Kubernetes Master](#kubernetes-master)
* [L2 Neighbors](#l2-neighbors)
* [Loopback Interface](#loopback-interface)
* [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN)
* [Management Interface](#management-interface)
* [Management port](#management-port)
* [Management VRF](#management-vrf)
* [MAP_PFC_PRIORITY_TO_QUEUE](#map_pfc_priority_to_queue)
* [MUX_CABLE](#muxcable)
* [NTP Global Configuration](#ntp-global-configuration)
* [NTP and SYSLOG servers](#ntp-and-syslog-servers)
* [Peer Switch](#peer-switch)
* [Policer](#policer)
* [Port](#port)
* [Port Channel](#port-channel)
* [Portchannel member](#portchannel-member)
* [Scheduler](#scheduler)
* [Port QoS Map](#port-qos-map)
* [Queue](#queue)
* [Syslog Rate Limit](#syslog-rate-limit)
* [Sflow](#sflow)
* [Restapi](#restapi)
* [Tacplus Server](#tacplus-server)
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
* [Telemetry](#telemetry)
* [Versions](#versions)
* [VLAN](#vlan)
* [VLAN_MEMBER](#vlan_member)
* [VOQ Inband Interface](#voq-inband-interface)
* [VXLAN](#vxlan)
* [Virtual router](#virtual-router)
* [LOGGER](#logger)
* [WRED_PROFILE](#wred_profile)
* [PASSWORD_HARDENING](#password_hardening)
* [SYSTEM_DEFAULTS table](#systemdefaults-table)
* [For Developers](#for-developers)
* [For Developers](#for-developers)
* [Generating Application Config by Jinja2 Template](#generating-application-config-by-jinja2-template)
* [Incremental Configuration by Subscribing to ConfigDB](#incremental-configuration-by-subscribing-to-configdb)
# Introduction
@ -1455,6 +1456,36 @@ name as object key and member list as attribute.
}
}
```
### Sflow
The below are the tables and their schema for SFLOW feature
SFLOW
| Field | Description | Mandatory | Default | Reference |
|------------------|-----------------------------------------------------------------------------------------|-------------|-----------|-------------------------------------------|
| admin_state | Global sflow admin state | | down | |
| polling_interval | The interval within which sFlow data is collected and sent to the configured collectors | | 20 | |
| agent_id | Interface name | | | PORT:name,PORTCHANNEL:name,MGMT_PORT:name, VLAN:name |
SFLOW_SESSION
key - port
| Field | Description | Mandatory | Default | Reference |
|-------------|-------------------------------------------------------------------------------------------------------------------------|-------------|-----------|-------------|
| port | Sets sflow session table attributes for either all interfaces or a specific Ethernet interface. | | | PORT:name |
| admin_state | Per port sflow admin state | | up | |
| sample_rate | Sets the packet sampling rate. The rate is expressed as an integer N, where the intended sampling rate is 1/N packets. | | | |
SFLOW_COLLECTOR
key - name
| Field | Description | Mandatory | Default | Reference |
|----------------|-----------------------------------------------------------------------------------------|-------------|-----------|-------------|
| name | Name of the Sflow collector | | | |
| collector_ip | IPv4/IPv6 address of the Sflow collector | true | | |
| collector_port | Destination L4 port of the Sflow collector | | 6343 | |
| collector_vrf | Specify the Collector VRF. In this revision, it is either default VRF or Management VRF.| | | |
### Syslog Rate Limit

View File

@ -1273,7 +1273,8 @@
"collector_port": "6343"
},
"collector2": {
"collector_ip": "10.144.1.2"
"collector_ip": "10.144.1.2",
"collector_vrf": "mgmt"
}
},

View File

@ -14,6 +14,21 @@
"desc": "Configure collectors above the specified limit in SFLOW_COLLECTOR table.",
"eStr": ["Too many \"SFLOW_COLLECTOR_LIST\" elements"]
},
"SFLOW_TEST_WITH_COLLECTOR_DEFAULT_VRF": {
"desc": "Configure a collector in SFLOW_COLLECTOR table with default VRF."
},
"SFLOW_TEST_WITH_COLLECTOR_MGMT_VRF": {
"desc": "Configure a collector in SFLOW_COLLECTOR table with mgmt VRF."
},
"SFLOW_TEST_WITH_COLLECTOR_NON_EXISTING_MGMT_VRF": {
"desc": "Configure a collector in SFLOW_COLLECTOR table with mgmt VRF when MGMT VRF is not configured",
"eStrKey": "Must"
},
"SFLOW_TEST_WITH_COLLECTOR_INVALID_VRF": {
"desc": "Configure a collector in SFLOW_COLLECTOR table with invalid vrf",
"eStrKey": "Pattern",
"eStr": ["mgmt|default"]
},
"SFLOW_SESSION_TEST": {
"desc": "Configure a sflow session in SFLOW_SESSION table."
},

View File

@ -59,6 +59,69 @@
}
},
"SFLOW_TEST_WITH_COLLECTOR_DEFAULT_VRF": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_COLLECTOR": {
"SFLOW_COLLECTOR_LIST": [
{
"name": "collector1",
"collector_ip": "2001:1:2::23",
"collector_vrf": "default"
}
]
}
}
},
"SFLOW_TEST_WITH_COLLECTOR_MGMT_VRF": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_COLLECTOR": {
"SFLOW_COLLECTOR_LIST": [
{
"name": "collector1",
"collector_ip": "10.100.12.13",
"collector_vrf": "mgmt"
}
]
}
},
"sonic-mgmt_vrf:sonic-mgmt_vrf": {
"sonic-mgmt_vrf:MGMT_VRF_CONFIG": {
"sonic-mgmt_vrf:vrf_global": {
"mgmtVrfEnabled": "true"
}
}
}
},
"SFLOW_TEST_WITH_COLLECTOR_NON_EXISTING_MGMT_VRF": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_COLLECTOR": {
"SFLOW_COLLECTOR_LIST": [
{
"name": "collector1",
"collector_ip": "10.100.12.13",
"collector_vrf": "mgmt"
}
]
}
}
},
"SFLOW_TEST_WITH_COLLECTOR_INVALID_VRF": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_COLLECTOR": {
"SFLOW_COLLECTOR_LIST": [
{
"name": "collector1",
"collector_ip": "10.100.12.13",
"collector_vrf": "Vrf1"
}
]
}
}
},
"SFLOW_SESSION_TEST": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {

View File

@ -25,6 +25,10 @@ module sonic-sflow{
import sonic-mgmt_port {
prefix mgmt-port;
}
import sonic-mgmt_vrf {
prefix mvrf;
}
description "SFLOW yang Module for SONiC OS";
@ -43,17 +47,34 @@ module sonic-sflow{
type string {
length 1..64;
}
description "Name of the Sflow collector";
}
leaf collector_ip {
mandatory true;
type inet:ip-address;
description "IPv4/IPv6 address of the Sflow collector";
}
leaf collector_port {
type inet:port-number;
default 6343;
description "Destination L4 port of the Sflow collector";
}
leaf collector_vrf {
must "(current() != 'mgmt') or (/mvrf:sonic-mgmt_vrf/mvrf:MGMT_VRF_CONFIG/mvrf:vrf_global/mvrf:mgmtVrfEnabled = 'true')" {
error-message "Must condition not satisfied. Try enable Management VRF.";
}
type string {
pattern "mgmt|default";
}
description
"Specify the Collector VRF. In this revision, it is either
default VRF or Management VRF.";
}
} /* end of list SFLOW_COLLECTOR_LIST */
@ -78,6 +99,7 @@ module sonic-sflow{
leaf admin_state {
type stypes:admin_status;
default up;
description "Per port sflow admin state";
}
leaf sample_rate {
@ -99,6 +121,7 @@ module sonic-sflow{
leaf admin_state {
type stypes:admin_status;
default down;
description "Global sflow admin state";
}
leaf polling_interval {