Skip to content

Commit

Permalink
SONiC Yang model for sFlow feature (sonic-net#7473)
Browse files Browse the repository at this point in the history
* SONiC YANG model support for sFlow feature.
Signed-off-by: Arthi Sivanantham <arthi_sivanantham@dell.com>
  • Loading branch information
ArthiSivanantham authored and Carl Keene committed Aug 7, 2021
1 parent 1f8e725 commit a89087b
Show file tree
Hide file tree
Showing 5 changed files with 445 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
'./yang-models/sonic-route-common.yang',
'./yang-models/sonic-route-map.yang',
'./yang-models/sonic-routing-policy-sets.yang',
'./yang-models/sonic-sflow.yang',
'./yang-models/sonic-system-aaa.yang',
'./yang-models/sonic-system-tacacs.yang',
'./yang-models/sonic-types.yang',
Expand Down
31 changes: 31 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,36 @@
"polling_interval": "0"
}
},

"SFLOW_COLLECTOR": {
"collector1": {
"collector_ip": "10.100.12.13",
"collector_port": "6343"
},
"collector2": {
"collector_ip": "10.144.1.2"
}
},

"SFLOW_SESSION": {
"Ethernet0": {
"admin_state": "down",
"sample_rate": "40000"
},
"Ethernet16": {
"admin_state": "up",
"sample_rate": "32768"
}
},

"SFLOW" : {
"global": {
"admin_state": "up",
"polling_interval": "20",
"agent_id": "Ethernet0"
}
},

"AAA": {
"authentication": {
"login": "local"
Expand Down Expand Up @@ -1012,6 +1042,7 @@
"trap_group": "queue1_group1"
}
}

},

"SAMPLE_CONFIG_DB_UNKNOWN": {
Expand Down
47 changes: 47 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"SFLOW_COLLECTOR_TEST": {
"desc": "Configure a collector in SFLOW_COLLECTOR table."
},
"SFLOW_COLLECTOR_WRONG_NAME_TEST": {
"desc": "Configure a collector with incorrect name in SFLOW_COLLECTOR table.",
"eStr" : ["not", "satisfy", "the", "constraint", "1..64"]
},
"SFLOW_TEST_WITHOUT_COLLECTOR_IP": {
"desc": "Configure a collector without collector IP attribute in SFLOW_COLLECTOR table.",
"eStrKey" : "Mandatory"
},
"SFLOW_TEST_EXCEEDING_MAX_ELEMENTS": {
"desc": "Configure collectors above the specified limit in SFLOW_COLLECTOR table.",
"eStr": ["Too many \"SFLOW_COLLECTOR_LIST\" elements"]
},
"SFLOW_SESSION_TEST": {
"desc": "Configure a sflow session in SFLOW_SESSION table."
},
"SFLOW_SESSION_TEST_WITH_NON_EXIST_PORT": {
"desc": "Configure Port in SFLOW_SESSION table which does not exist in PORT table.",
"eStrKey": "InvalidValue"
},
"SFLOW_SESSION_TEST_WITH_INCORRECT_PORT_NAME_PATTERN": {
"desc": "Configure SFLOW_SESSION table with incorrect pattern in port name attribute.",
"eStrKey": "InvalidValue"
},
"SFLOW_SESSION_TEST_WITH_INCORRECT_SAMPLE_RATE": {
"desc": "Configure sflow session in SFLOW_SESSION table with an out of range sample rate.",
"eStr": ["sFlow sample rate must be [256-8388608]"]
},
"SFLOW_SESSION_TEST_WITH_INCORRECT_PORT_TYPE_IN_SAMPLE_RATE": {
"desc": "Configure sflow session in SFLOW_SESSION table with an incorrect port type in sample rate.",
"eStrKey": "Must"
},
"SFLOW_TEST": {
"desc": "Configure sflow global entry in SFLOW table."
},
"SFLOW_TEST_WITH_NON_EXIST_PORT": {
"desc": "Configure Port in SFLOW table which does not exist in PORT table.",
"eStrKey": "InvalidValue"
},
"SFLOW_TEST_WITH_INCORRECT_POLLING_INTERVAL": {
"desc": "Configure SFLOW table with an out of range polling interval.",
"eStr": ["sFlow polling interval must be [0, 5-300]"]
}
}
225 changes: 225 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
{
"SFLOW_COLLECTOR_TEST": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_COLLECTOR": {
"SFLOW_COLLECTOR_LIST": [
{
"name": "collector1",
"collector_ip": "10.100.12.13",
"collector_port": "6343"
}
]
}
}
},

"SFLOW_COLLECTOR_WRONG_NAME_TEST": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_COLLECTOR": {
"SFLOW_COLLECTOR_LIST": [
{
"name": "collector1111111111111111111111111111111111111111111111111111111111111111",
"collector_ip": "10.100.12.13"
}
]
}
}
},

"SFLOW_TEST_WITHOUT_COLLECTOR_IP": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_COLLECTOR": {
"SFLOW_COLLECTOR_LIST": [
{
"name": "collector1"
}
]
}
}
},

"SFLOW_TEST_EXCEEDING_MAX_ELEMENTS": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_COLLECTOR": {
"SFLOW_COLLECTOR_LIST": [
{
"name": "collector1",
"collector_ip": "10.100.12.13"
},
{
"name": "collector2",
"collector_ip": "10.144.1.2"
},
{
"name": "collector3",
"collector_ip": "10.100.12.15"
}
]
}
}
},

"SFLOW_SESSION_TEST": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 25000
}
]
}
},
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_SESSION": {
"SFLOW_SESSION_LIST": [
{
"port": "Ethernet0",
"admin_state": "up",
"sample_rate": "40000"
}
]
}
}
},

"SFLOW_SESSION_TEST_WITH_NON_EXIST_PORT": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_SESSION": {
"SFLOW_SESSION_LIST": [
{
"port": "Ethernet4",
"admin_state": "down",
"sample_rate": "32768"
}
]
}
}
},

"SFLOW_SESSION_TEST_WITH_INCORRECT_PORT_NAME_PATTERN": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_SESSION": {
"SFLOW_SESSION_LIST": [
{
"port": "allllll",
"admin_state": "down"
}
]
}
}
},

"SFLOW_SESSION_TEST_WITH_INCORRECT_SAMPLE_RATE": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 25000
}
]
}
},
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_SESSION": {
"SFLOW_SESSION_LIST": [
{
"port": "Ethernet0",
"admin_state": "up",
"sample_rate": "40"
}
]
}
}
},

"SFLOW_SESSION_TEST_WITH_INCORRECT_PORT_TYPE_IN_SAMPLE_RATE": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW_SESSION": {
"SFLOW_SESSION_LIST": [
{
"port": "all",
"admin_state": "up",
"sample_rate": "40000"
}
]
}
}
},

"SFLOW_TEST": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 25000
}
]
}
},
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW": {
"global": {
"agent_id": "Ethernet0",
"admin_state": "up",
"polling_interval": "20"
}
}
}
},

"SFLOW_TEST_WITH_NON_EXIST_PORT": {
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW": {
"global": {
"agent_id": "Ethernet0",
"admin_state": "up",
"polling_interval": "20"
}
}
}
},

"SFLOW_TEST_WITH_INCORRECT_POLLING_INTERVAL": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 25000
}
]
}
},
"sonic-sflow:sonic-sflow": {
"sonic-sflow:SFLOW": {
"global": {
"admin_state": "up",
"polling_interval": "305"
}
}
}
}
}
Loading

0 comments on commit a89087b

Please sign in to comment.