Skip to content

Commit

Permalink
[yang] Add collector_vrf to sflow yang model (sonic-net#12897) (sonic…
Browse files Browse the repository at this point in the history
…-net#13025)

- 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.
  • Loading branch information
dgsudharsan authored Dec 13, 2022
1 parent 557283a commit f48706d
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 2 deletions.
65 changes: 64 additions & 1 deletion src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Table of Contents
* [Scheduler](#scheduler)
* [Port QoS Map](#port-qos-map)
* [Queue](#queue)
* [Sflow](#sflow)
* [Tacplus Server](#tacplus-server)
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
Expand All @@ -57,7 +58,7 @@ Table of Contents
* [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
Expand Down Expand Up @@ -1331,6 +1332,68 @@ 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

Host side configuration:

```
{
"SYSLOG_CONFIG": {
"GLOBAL": {
"rate_limit_interval": "300",
"rate_limit_burst": "20000"
}
}
}
```

Container side configuration:

```
{
"SYSLOG_CONFIG_FEATURE": {
"bgp": {
"rate_limit_interval": "300",
"rate_limit_burst": "20000"
},
"pmon": {
"rate_limit_interval": "300",
"rate_limit_burst": "20000"
}
}
}
```

### Tacplus Server

Expand Down
3 changes: 2 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,8 @@
"collector_port": "6343"
},
"collector2": {
"collector_ip": "10.144.1.2"
"collector_ip": "10.144.1.2",
"collector_vrf": "mgmt"
}
},

Expand Down
15 changes: 15 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
23 changes: 23 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-sflow.yang
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 */
Expand All @@ -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 {
Expand All @@ -99,6 +121,7 @@ module sonic-sflow{
leaf admin_state {
type stypes:admin_status;
default down;
description "Global sflow admin state";
}

leaf polling_interval {
Expand Down

0 comments on commit f48706d

Please sign in to comment.