From ad2ace4225c1af152efc2d2d6063e6441c691368 Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Thu, 29 Apr 2021 01:24:20 +0000 Subject: [PATCH 01/12] SONiC Yang models for sFlow, AAA and TACACS features Signed-off-by: ArthiSivanantham --- src/sonic-yang-models/setup.py | 3 + .../tests/files/sample_config_db.json | 46 ++++ .../tests/yang_model_tests/tests/aaa.json | 13 ++ .../tests/yang_model_tests/tests/sflow.json | 40 ++++ .../tests/yang_model_tests/tests/tacacs.json | 32 +++ .../yang_model_tests/tests_config/aaa.json | 35 +++ .../yang_model_tests/tests_config/sflow.json | 199 ++++++++++++++++++ .../yang_model_tests/tests_config/tacacs.json | 131 ++++++++++++ .../yang-models/sonic-sflow.yang | 109 ++++++++++ .../yang-models/sonic-system-aaa.yang | 41 ++++ .../yang-models/sonic-system-tacacs.yang | 165 +++++++++++++++ 11 files changed, 814 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/tacacs.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/tacacs.json create mode 100644 src/sonic-yang-models/yang-models/sonic-sflow.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-system-aaa.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-system-tacacs.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index d511b9898a5a..7f1155eb5fe2 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -52,6 +52,9 @@ './yang-models/sonic-loopback-interface.yang', './yang-models/sonic-port.yang', './yang-models/sonic-portchannel.yang', + './yang-models/sonic-sflow.yang', + './yang-models/sonic-system-aaa.yang', + './yang-models/sonic-system-tacacs.yang', './yang-models/sonic-types.yang', './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 699ce6ad10b3..33f4e6ed4868 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -695,6 +695,51 @@ "nexthop_group_threshold_type": "percentage", "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" + } + }, + "TACPLUS": { + "global": { + "auth_type": "pap", + "timeout": "5" + } + }, + "TACPLUS_SERVER": { + "192.168.1.1": { + "timeout": "10" + } } }, @@ -703,4 +748,5 @@ "Error": "This Table is for testing, This Table does not have YANG models." } } + } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json b/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json new file mode 100644 index 000000000000..8b1d78464814 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json @@ -0,0 +1,13 @@ +{ + "AAA_TEST": { + "desc": "Configure an authentication type in AAA table." + }, + "AAA_TEST_WRONG_TYPE": { + "desc": "Configure a wrong type in AAA table.", + "eStrKey": "InvalidValue" + }, + "AAA_TEST_WRONG_FAILTHROUGH": { + "desc": "Configure a wrong failthrough in AAA table.", + "eStrKey": "InvalidValue" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json new file mode 100644 index 000000000000..afdd2623a437 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json @@ -0,0 +1,40 @@ +{ + "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": "LeafRef", + "eStr": ["port", "name"] + }, + "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_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]"] + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/tacacs.json b/src/sonic-yang-models/tests/yang_model_tests/tests/tacacs.json new file mode 100644 index 000000000000..5236aab596fe --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/tacacs.json @@ -0,0 +1,32 @@ +{ + "TACPLUS_TEST": { + "desc": "Tacplus global configuration in TACPLUS table." + }, + "TACPLUS_INVALID_TIMEOUT_TEST": { + "desc": "Tacplus global configuration with invalid timeout value in TACPLUS table.", + "eStr": "TACACS timeout must be 1..60" + }, + "TACPLUS_NOT_PRESENT_SRC_INTF_TEST": { + "desc": "Tacplus global configuration with a non existent port in TACPLUS table.", + "eStrKey": "InvalidValue" + }, + "TACPLUS_SERVER_TEST" : { + "desc": "Tacplus server configuration in TACPLUS_SERVER table." + }, + "TACPLUS_SERVER_INVALID_PRIORITY_TEST": { + "desc": "Tacplus server configuration with invalid priority value in TACPLUS_SERVER table.", + "eStr": "TACACS server priority must be 1..64" + }, + "TACPLUS_SERVER_INVALID_TIMEOUT_TEST" : { + "desc": "Tacplus server configuration with invalid timeout value in TACPLUS_SERVER table.", + "eStr": "TACACS server timeout must be 1..60" + }, + "TACPLUS_SERVER_INVALID_AUTH_TYPE_TEST" : { + "desc": "Tacplus server configuration with invalid auth type in TACPLUS_SERVER table.", + "eStrKey": "InvalidValue" + }, + "TACPLUS_SERVER_INVALID_VRF_TEST" : { + "desc": "Tacplus server configuration with invalid VRF in TACPLUS_SERVER table.", + "eStr": "Invalid VRF name" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json new file mode 100644 index 000000000000..1b79b26ac0a1 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json @@ -0,0 +1,35 @@ +{ + "AAA_TEST": { + "sonic-system-aaa:sonic-system-aaa": { + "sonic-system-aaa:AAA": { + "AAA_LIST": [{ + "type": "authentication", + "login": "tacacs+,local", + "failthrough": "true", + "debug": "true" + }] + } + } + }, + + "AAA_TEST_WRONG_TYPE": { + "sonic-system-aaa:sonic-system-aaa": { + "sonic-system-aaa:AAA": { + "AAA_LIST": [{ + "type": "authorization" + }] + } + } + }, + + "AAA_TEST_WRONG_FAILTHROUGH": { + "sonic-system-aaa:sonic-system-aaa": { + "sonic-system-aaa:AAA": { + "AAA_LIST": [{ + "type": "authentication", + "failthrough": "enable" + }] + } + } + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json new file mode 100644 index 000000000000..8fb0fd2fd2af --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json @@ -0,0 +1,199 @@ +{ + "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_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_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": { + "agent_id": "Ethernet0", + "admin_state": "up", + "polling_interval": "305" + } + } + } + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/tacacs.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/tacacs.json new file mode 100644 index 000000000000..290813121597 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/tacacs.json @@ -0,0 +1,131 @@ +{ + "TACPLUS_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + + "sonic-system-tacacs:sonic-system-tacacs": { + "sonic-system-tacacs:TACPLUS": { + "global": { + "auth_type": "chap", + "timeout": 5, + "passkey": "dellsonic", + "src_intf": "Ethernet0" + } + } + } + }, + + "TACPLUS_INVALID_TIMEOUT_TEST": { + "sonic-system-tacacs:sonic-system-tacacs": { + "sonic-system-tacacs:TACPLUS": { + "global": { + "auth_type": "chap", + "timeout": 70 + } + } + } + }, + + "TACPLUS_NOT_PRESENT_SRC_INTF_TEST": { + "sonic-system-tacacs:sonic-system-tacacs": { + "sonic-system-tacacs:TACPLUS": { + "global": { + "auth_type": "chap", + "timeout": 5, + "passkey": "dellsonic", + "src_intf": "Ethernet0" + } + } + } + }, + + "TACPLUS_SERVER_TEST": { + "sonic-system-tacacs:sonic-system-tacacs": { + "sonic-system-tacacs:TACPLUS_SERVER": { + "TACPLUS_SERVER_LIST": [ + { + "ipaddress": "192.168.1.1", + "priority": 5, + "tcp_port": 50, + "timeout": 10, + "auth_type": "chap", + "passkey": "dellsonic", + "vrf": "default" + }, + { + "ipaddress": "tacserver1", + "priority": 2, + "tcp_port": 51, + "timeout": 15, + "auth_type": "pap", + "passkey": "dellsonic1", + "vrf": "mgmt" + } + ] + } + } + }, + + "TACPLUS_SERVER_INVALID_PRIORITY_TEST": { + "sonic-system-tacacs:sonic-system-tacacs": { + "sonic-system-tacacs:TACPLUS_SERVER": { + "TACPLUS_SERVER_LIST": [ + { + "ipaddress": "192.168.1.1", + "priority": 70 + } + ] + } + } + }, + "TACPLUS_SERVER_INVALID_TIMEOUT_TEST": { + "sonic-system-tacacs:sonic-system-tacacs": { + "sonic-system-tacacs:TACPLUS_SERVER": { + "TACPLUS_SERVER_LIST": [ + { + "ipaddress": "192.168.1.1", + "timeout": 70 + } + ] + } + } + }, + "TACPLUS_SERVER_INVALID_AUTH_TYPE_TEST": { + "sonic-system-tacacs:sonic-system-tacacs": { + "sonic-system-tacacs:TACPLUS_SERVER": { + "TACPLUS_SERVER_LIST": [ + { + "ipaddress": "192.168.1.1", + "auth_type": "123" + } + ] + } + } + }, + "TACPLUS_SERVER_INVALID_VRF_TEST": { + "sonic-system-tacacs:sonic-system-tacacs": { + "sonic-system-tacacs:TACPLUS_SERVER": { + "TACPLUS_SERVER_LIST": [ + { + "ipaddress": "192.168.1.1", + "vrf": "Vrf1" + } + ] + } + } + } + +} diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang new file mode 100644 index 000000000000..dade2c16fbe2 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -0,0 +1,109 @@ +module sonic-sflow{ + + namespace "http://github.com/Azure/sonic-sflow"; + prefix sflow; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-types { + prefix stypes; + } + import sonic-port { + prefix prt; + } + import sonic-vlan { + prefix svlan; + } + + description "SFLOW yang Module for SONiC OS"; + + revision 2021-04-26 { + description "First Revision"; + } + + container sonic-sflow { + + container SFLOW_COLLECTOR { + list SFLOW_COLLECTOR_LIST { + max-elements 2; + key "name"; + + leaf name { + type string { + length 1..64; + } + } + + leaf collector_ip { + mandatory true; + type inet:ip-address; + } + + + leaf collector_port { + type inet:port-number; + } + + } /* end of list SFLOW_COLLECTOR_LIST */ + } /* end of container SFLOW_COLLECTOR */ + + container SFLOW_SESSION { + list SFLOW_SESSION_LIST { + key "port"; + + leaf port { + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + } + } + + leaf admin_state { + type stypes:admin_status; + } + + leaf sample_rate { + type uint32 { + range "256..8388608" { + error-message "sFlow sample rate must be [256-8388608]"; + } + } + } + } /* end of list SFLOW_SESSION_LIST */ + } /* end of container SFLOW_SESSION */ + + container SFLOW { + + container global { + + leaf admin_state { + type stypes:admin_status; + } + + leaf polling_interval { + type uint16 { + range "0|5..300" { + error-message "sFlow polling interval must be [0, 5-300]"; + } + } + } + + leaf agent_id { + type union { + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + } + type leafref { + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + } + } + description "Interface name"; + } + } /* end of container global */ + } /* end of container SFLOW */ + + } /* end of container sonic-sflow */ + +} /* end of module sonic-sflow */ diff --git a/src/sonic-yang-models/yang-models/sonic-system-aaa.yang b/src/sonic-yang-models/yang-models/sonic-system-aaa.yang new file mode 100644 index 000000000000..e6d70006ac96 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-system-aaa.yang @@ -0,0 +1,41 @@ +module sonic-system-aaa { + namespace "http://github.com/Azure/sonic-system-aaa"; + prefix ssys; + yang-version 1.1; + + revision 2021-04-15 { + description "Initial revision."; + } + + container sonic-system-aaa { + container AAA { + list AAA_LIST { + key "type"; + + leaf type { + type enumeration { + enum authentication; + } + description "AAA type authentication"; + } + + leaf login { + type string; + description "AAA authentication methods - local/tacacs+"; + } + + leaf failthrough { + type boolean; + description "When set to true, authentication is attempted on next configured server/local in the list upon failure."; + } + + leaf debug { + type boolean; + description "Enable/disable AAA debugging"; + } + + } + } + } +} + diff --git a/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang b/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang new file mode 100644 index 000000000000..7f8b056a4630 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang @@ -0,0 +1,165 @@ +module sonic-system-tacacs { + namespace "http://github.com/Azure/sonic-system-tacacs"; + prefix ssys; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-port { + prefix prt; + } + + import sonic-portchannel { + prefix spc; + } + + import sonic-vlan { + prefix svlan; + } + + import sonic-loopback-interface { + prefix lo; + } + + import sonic-interface { + prefix sintf; + } + +// import sonic-mgmt-port { +// prefix smt; +// } + + revision 2021-04-15 { + description "Initial revision."; + } + + typedef auth_type_enumeration { + type enumeration { + enum pap; + enum chap; + enum mschap; + enum login; + } + } + + container sonic-system-tacacs { + + container TACPLUS_SERVER { + list TACPLUS_SERVER_LIST { + max-elements 8; + key "ipaddress"; + + leaf ipaddress { + type inet:host; + description + "TACACS+ server's Domain name or IP address (IPv4 or IPv6)"; + } + + leaf priority { + default 1; + type uint8 { + range "1..64" { + error-message "TACACS server priority must be 1..64"; + } + } + description "Server priority"; + } + + leaf tcp_port { + type inet:port-number; + default 49; + description "TCP port to communite with TACACS+ server"; + } + + leaf timeout { + default 5; + type uint16 { + range "1..60" { + error-message "TACACS server timeout must be 1..60"; + } + } + description "TACACS+ server timeout"; + } + + leaf auth_type { + type auth_type_enumeration; + default pap; + description "Authentication type"; + } + + leaf passkey { + type string { + length "1..65"; + pattern "[^ #,]*" { + error-message 'TACACS shared secret (Valid chars are ASCII printable except SPACE, "#", and ",")'; + } + } + } + + leaf vrf { + type string { + pattern "mgmt|default" { + error-message "Error: Invalid VRF name"; + } + } + description + "VRF name"; + } + } + } + + + container TACPLUS { + + container global { + + leaf auth_type { + type auth_type_enumeration; + default pap; + } + + leaf timeout { + type uint16 { + range "1..60" { + error-message "TACACS timeout must be 1..60"; + } + } + default 5; + } + + leaf passkey { + type string { + length "1..65"; + pattern "[^ #,]*" { + error-message 'TACACS shared secret (Valid chars are ASCII printable except SPACE, "#", and ",")'; + } + } + description "Shared secret used for encrypting the communication"; + } + + leaf src_intf { + type union { + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + } + type leafref { + path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; + } + type leafref { + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + } + type leafref { + path "/lo:sonic-loopback-interface/lo:LOOPBACK_INTERFACE/lo:LOOPBACK_INTERFACE_LIST/lo:name"; + } + //type leafref { + // path "/smt:sonic-mgmt-port/smt:MGMT_PORT/smt:MGMT_PORT_LIST/smt:name"; + //} + } + description "Source IP to use from source interface for TACACS+ server communication."; + } + } + } + } +} From 3c4c20ee36297727a303691bd12b722d8f2ec430 Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Mon, 3 May 2021 20:07:28 +0000 Subject: [PATCH 02/12] Added description for attributes Signed-off-by: ArthiSivanantham --- .../yang-models/sonic-sflow.yang | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang index dade2c16fbe2..9c494d695d7c 100644 --- a/src/sonic-yang-models/yang-models/sonic-sflow.yang +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -17,6 +17,11 @@ module sonic-sflow{ import sonic-vlan { prefix svlan; } + /* + import sonic-mgmt-port { + prefix smt; + } + */ description "SFLOW yang Module for SONiC OS"; @@ -45,6 +50,7 @@ module sonic-sflow{ leaf collector_port { type inet:port-number; + default 6343; } } /* end of list SFLOW_COLLECTOR_LIST */ @@ -62,6 +68,7 @@ module sonic-sflow{ leaf admin_state { type stypes:admin_status; + default up; } leaf sample_rate { @@ -70,6 +77,7 @@ module sonic-sflow{ error-message "sFlow sample rate must be [256-8388608]"; } } + description "Sets the packet sampling rate. The rate is expressed as an integer N, where the intended sampling rate is 1/N packets."; } } /* end of list SFLOW_SESSION_LIST */ } /* end of container SFLOW_SESSION */ @@ -80,6 +88,7 @@ module sonic-sflow{ leaf admin_state { type stypes:admin_status; + default down; } leaf polling_interval { @@ -88,6 +97,8 @@ module sonic-sflow{ error-message "sFlow polling interval must be [0, 5-300]"; } } + description "The interval within which sFlow data is collected and sent to the configured collectors"; + default 20; } leaf agent_id { @@ -95,6 +106,10 @@ module sonic-sflow{ type leafref { path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; } + /* + type leafref { + path "/smt:sonic-mgmt-port/smt:MGMT_PORT/smt:MGMT_PORT_LIST/smt:name"; + }*/ type leafref { path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; } From 5ac683f425a75d2d6907227dd350deecac631911 Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Sat, 15 May 2021 00:34:35 +0000 Subject: [PATCH 03/12] 1. Include PortChannel type in sflow agent id. 2. Fix import prefixes Signed-off-by: ArthiSivanantham --- .../yang-models/sonic-sflow.yang | 20 +++++++++++------ .../yang-models/sonic-system-tacacs.yang | 22 +++++++++---------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang index 9c494d695d7c..f2ca931e454b 100644 --- a/src/sonic-yang-models/yang-models/sonic-sflow.yang +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -12,14 +12,17 @@ module sonic-sflow{ prefix stypes; } import sonic-port { - prefix prt; + prefix port; } import sonic-vlan { - prefix svlan; + prefix vlan; + } + import sonic-portchannel { + prefix lag; } /* import sonic-mgmt-port { - prefix smt; + prefix mgmt-port; } */ @@ -62,7 +65,7 @@ module sonic-sflow{ leaf port { type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; } } @@ -104,14 +107,17 @@ module sonic-sflow{ leaf agent_id { type union { type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type leafref { + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } /* type leafref { - path "/smt:sonic-mgmt-port/smt:MGMT_PORT/smt:MGMT_PORT_LIST/smt:name"; + path "/mgmt-port:sonic-mgmt-port/mgmt-port:MGMT_PORT/mgmt-port:MGMT_PORT_LIST/mgmt-port:name"; }*/ type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } description "Interface name"; diff --git a/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang b/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang index 7f8b056a4630..d4338d94cd6d 100644 --- a/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang +++ b/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang @@ -8,27 +8,27 @@ module sonic-system-tacacs { } import sonic-port { - prefix prt; + prefix port; } import sonic-portchannel { - prefix spc; + prefix lag; } import sonic-vlan { - prefix svlan; + prefix vlan; } import sonic-loopback-interface { - prefix lo; + prefix loopback; } import sonic-interface { - prefix sintf; + prefix interface; } // import sonic-mgmt-port { -// prefix smt; +// prefix mgmt-port; // } revision 2021-04-15 { @@ -142,19 +142,19 @@ module sonic-system-tacacs { leaf src_intf { type union { type leafref { - path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; } type leafref { - path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name"; + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } type leafref { - path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } type leafref { - path "/lo:sonic-loopback-interface/lo:LOOPBACK_INTERFACE/lo:LOOPBACK_INTERFACE_LIST/lo:name"; + path "/loopback:sonic-loopback-interface/loopback:LOOPBACK_INTERFACE/loopback:LOOPBACK_INTERFACE_LIST/loopback:name"; } //type leafref { - // path "/smt:sonic-mgmt-port/smt:MGMT_PORT/smt:MGMT_PORT_LIST/smt:name"; + // path "/mgmt-port:sonic-mgmt-port/mgmt-port:MGMT_PORT/mgmt-port:MGMT_PORT_LIST/mgmt-port:name"; //} } description "Source IP to use from source interface for TACACS+ server communication."; From 990392860ca1d1528a5f68bb5a2fa367918e7ad7 Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Thu, 20 May 2021 18:53:57 +0000 Subject: [PATCH 04/12] Retain only sflow changes Signed-off-by: ArthiSivanantham --- src/sonic-yang-models/setup.py | 2 - .../tests/files/sample_config_db.json | 18 +- .../tests/yang_model_tests/tests/aaa.json | 13 -- .../tests/yang_model_tests/tests/tacacs.json | 32 ---- .../yang_model_tests/tests_config/aaa.json | 35 ---- .../yang_model_tests/tests_config/tacacs.json | 131 -------------- .../yang-models/sonic-system-aaa.yang | 41 ----- .../yang-models/sonic-system-tacacs.yang | 165 ------------------ 8 files changed, 1 insertion(+), 436 deletions(-) delete mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json delete mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/tacacs.json delete mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json delete mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/tacacs.json delete mode 100644 src/sonic-yang-models/yang-models/sonic-system-aaa.yang delete mode 100644 src/sonic-yang-models/yang-models/sonic-system-tacacs.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 7f1155eb5fe2..8c7c74ad77d5 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -53,8 +53,6 @@ './yang-models/sonic-port.yang', './yang-models/sonic-portchannel.yang', './yang-models/sonic-sflow.yang', - './yang-models/sonic-system-aaa.yang', - './yang-models/sonic-system-tacacs.yang', './yang-models/sonic-types.yang', './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 85e1cad26e04..6c94e6f28416 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -728,24 +728,8 @@ "polling_interval": "20", "agent_id": "Ethernet0" } - }, - - "AAA": { - "authentication": { - "login": "local" - } - }, - "TACPLUS": { - "global": { - "auth_type": "pap", - "timeout": "5" - } - }, - "TACPLUS_SERVER": { - "192.168.1.1": { - "timeout": "10" - } } + }, "SAMPLE_CONFIG_DB_UNKNOWN": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json b/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json deleted file mode 100644 index 8b1d78464814..000000000000 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "AAA_TEST": { - "desc": "Configure an authentication type in AAA table." - }, - "AAA_TEST_WRONG_TYPE": { - "desc": "Configure a wrong type in AAA table.", - "eStrKey": "InvalidValue" - }, - "AAA_TEST_WRONG_FAILTHROUGH": { - "desc": "Configure a wrong failthrough in AAA table.", - "eStrKey": "InvalidValue" - } -} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/tacacs.json b/src/sonic-yang-models/tests/yang_model_tests/tests/tacacs.json deleted file mode 100644 index 5236aab596fe..000000000000 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/tacacs.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "TACPLUS_TEST": { - "desc": "Tacplus global configuration in TACPLUS table." - }, - "TACPLUS_INVALID_TIMEOUT_TEST": { - "desc": "Tacplus global configuration with invalid timeout value in TACPLUS table.", - "eStr": "TACACS timeout must be 1..60" - }, - "TACPLUS_NOT_PRESENT_SRC_INTF_TEST": { - "desc": "Tacplus global configuration with a non existent port in TACPLUS table.", - "eStrKey": "InvalidValue" - }, - "TACPLUS_SERVER_TEST" : { - "desc": "Tacplus server configuration in TACPLUS_SERVER table." - }, - "TACPLUS_SERVER_INVALID_PRIORITY_TEST": { - "desc": "Tacplus server configuration with invalid priority value in TACPLUS_SERVER table.", - "eStr": "TACACS server priority must be 1..64" - }, - "TACPLUS_SERVER_INVALID_TIMEOUT_TEST" : { - "desc": "Tacplus server configuration with invalid timeout value in TACPLUS_SERVER table.", - "eStr": "TACACS server timeout must be 1..60" - }, - "TACPLUS_SERVER_INVALID_AUTH_TYPE_TEST" : { - "desc": "Tacplus server configuration with invalid auth type in TACPLUS_SERVER table.", - "eStrKey": "InvalidValue" - }, - "TACPLUS_SERVER_INVALID_VRF_TEST" : { - "desc": "Tacplus server configuration with invalid VRF in TACPLUS_SERVER table.", - "eStr": "Invalid VRF name" - } -} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json deleted file mode 100644 index 1b79b26ac0a1..000000000000 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "AAA_TEST": { - "sonic-system-aaa:sonic-system-aaa": { - "sonic-system-aaa:AAA": { - "AAA_LIST": [{ - "type": "authentication", - "login": "tacacs+,local", - "failthrough": "true", - "debug": "true" - }] - } - } - }, - - "AAA_TEST_WRONG_TYPE": { - "sonic-system-aaa:sonic-system-aaa": { - "sonic-system-aaa:AAA": { - "AAA_LIST": [{ - "type": "authorization" - }] - } - } - }, - - "AAA_TEST_WRONG_FAILTHROUGH": { - "sonic-system-aaa:sonic-system-aaa": { - "sonic-system-aaa:AAA": { - "AAA_LIST": [{ - "type": "authentication", - "failthrough": "enable" - }] - } - } - } -} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/tacacs.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/tacacs.json deleted file mode 100644 index 290813121597..000000000000 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/tacacs.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "TACPLUS_TEST": { - "sonic-port:sonic-port": { - "sonic-port:PORT": { - "PORT_LIST": [ - { - "admin_status": "up", - "alias": "eth8", - "description": "Ethernet8", - "lanes": "65", - "mtu": 9000, - "name": "Ethernet0", - "speed": 25000 - } - ] - } - }, - - "sonic-system-tacacs:sonic-system-tacacs": { - "sonic-system-tacacs:TACPLUS": { - "global": { - "auth_type": "chap", - "timeout": 5, - "passkey": "dellsonic", - "src_intf": "Ethernet0" - } - } - } - }, - - "TACPLUS_INVALID_TIMEOUT_TEST": { - "sonic-system-tacacs:sonic-system-tacacs": { - "sonic-system-tacacs:TACPLUS": { - "global": { - "auth_type": "chap", - "timeout": 70 - } - } - } - }, - - "TACPLUS_NOT_PRESENT_SRC_INTF_TEST": { - "sonic-system-tacacs:sonic-system-tacacs": { - "sonic-system-tacacs:TACPLUS": { - "global": { - "auth_type": "chap", - "timeout": 5, - "passkey": "dellsonic", - "src_intf": "Ethernet0" - } - } - } - }, - - "TACPLUS_SERVER_TEST": { - "sonic-system-tacacs:sonic-system-tacacs": { - "sonic-system-tacacs:TACPLUS_SERVER": { - "TACPLUS_SERVER_LIST": [ - { - "ipaddress": "192.168.1.1", - "priority": 5, - "tcp_port": 50, - "timeout": 10, - "auth_type": "chap", - "passkey": "dellsonic", - "vrf": "default" - }, - { - "ipaddress": "tacserver1", - "priority": 2, - "tcp_port": 51, - "timeout": 15, - "auth_type": "pap", - "passkey": "dellsonic1", - "vrf": "mgmt" - } - ] - } - } - }, - - "TACPLUS_SERVER_INVALID_PRIORITY_TEST": { - "sonic-system-tacacs:sonic-system-tacacs": { - "sonic-system-tacacs:TACPLUS_SERVER": { - "TACPLUS_SERVER_LIST": [ - { - "ipaddress": "192.168.1.1", - "priority": 70 - } - ] - } - } - }, - "TACPLUS_SERVER_INVALID_TIMEOUT_TEST": { - "sonic-system-tacacs:sonic-system-tacacs": { - "sonic-system-tacacs:TACPLUS_SERVER": { - "TACPLUS_SERVER_LIST": [ - { - "ipaddress": "192.168.1.1", - "timeout": 70 - } - ] - } - } - }, - "TACPLUS_SERVER_INVALID_AUTH_TYPE_TEST": { - "sonic-system-tacacs:sonic-system-tacacs": { - "sonic-system-tacacs:TACPLUS_SERVER": { - "TACPLUS_SERVER_LIST": [ - { - "ipaddress": "192.168.1.1", - "auth_type": "123" - } - ] - } - } - }, - "TACPLUS_SERVER_INVALID_VRF_TEST": { - "sonic-system-tacacs:sonic-system-tacacs": { - "sonic-system-tacacs:TACPLUS_SERVER": { - "TACPLUS_SERVER_LIST": [ - { - "ipaddress": "192.168.1.1", - "vrf": "Vrf1" - } - ] - } - } - } - -} diff --git a/src/sonic-yang-models/yang-models/sonic-system-aaa.yang b/src/sonic-yang-models/yang-models/sonic-system-aaa.yang deleted file mode 100644 index e6d70006ac96..000000000000 --- a/src/sonic-yang-models/yang-models/sonic-system-aaa.yang +++ /dev/null @@ -1,41 +0,0 @@ -module sonic-system-aaa { - namespace "http://github.com/Azure/sonic-system-aaa"; - prefix ssys; - yang-version 1.1; - - revision 2021-04-15 { - description "Initial revision."; - } - - container sonic-system-aaa { - container AAA { - list AAA_LIST { - key "type"; - - leaf type { - type enumeration { - enum authentication; - } - description "AAA type authentication"; - } - - leaf login { - type string; - description "AAA authentication methods - local/tacacs+"; - } - - leaf failthrough { - type boolean; - description "When set to true, authentication is attempted on next configured server/local in the list upon failure."; - } - - leaf debug { - type boolean; - description "Enable/disable AAA debugging"; - } - - } - } - } -} - diff --git a/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang b/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang deleted file mode 100644 index d4338d94cd6d..000000000000 --- a/src/sonic-yang-models/yang-models/sonic-system-tacacs.yang +++ /dev/null @@ -1,165 +0,0 @@ -module sonic-system-tacacs { - namespace "http://github.com/Azure/sonic-system-tacacs"; - prefix ssys; - yang-version 1.1; - - import ietf-inet-types { - prefix inet; - } - - import sonic-port { - prefix port; - } - - import sonic-portchannel { - prefix lag; - } - - import sonic-vlan { - prefix vlan; - } - - import sonic-loopback-interface { - prefix loopback; - } - - import sonic-interface { - prefix interface; - } - -// import sonic-mgmt-port { -// prefix mgmt-port; -// } - - revision 2021-04-15 { - description "Initial revision."; - } - - typedef auth_type_enumeration { - type enumeration { - enum pap; - enum chap; - enum mschap; - enum login; - } - } - - container sonic-system-tacacs { - - container TACPLUS_SERVER { - list TACPLUS_SERVER_LIST { - max-elements 8; - key "ipaddress"; - - leaf ipaddress { - type inet:host; - description - "TACACS+ server's Domain name or IP address (IPv4 or IPv6)"; - } - - leaf priority { - default 1; - type uint8 { - range "1..64" { - error-message "TACACS server priority must be 1..64"; - } - } - description "Server priority"; - } - - leaf tcp_port { - type inet:port-number; - default 49; - description "TCP port to communite with TACACS+ server"; - } - - leaf timeout { - default 5; - type uint16 { - range "1..60" { - error-message "TACACS server timeout must be 1..60"; - } - } - description "TACACS+ server timeout"; - } - - leaf auth_type { - type auth_type_enumeration; - default pap; - description "Authentication type"; - } - - leaf passkey { - type string { - length "1..65"; - pattern "[^ #,]*" { - error-message 'TACACS shared secret (Valid chars are ASCII printable except SPACE, "#", and ",")'; - } - } - } - - leaf vrf { - type string { - pattern "mgmt|default" { - error-message "Error: Invalid VRF name"; - } - } - description - "VRF name"; - } - } - } - - - container TACPLUS { - - container global { - - leaf auth_type { - type auth_type_enumeration; - default pap; - } - - leaf timeout { - type uint16 { - range "1..60" { - error-message "TACACS timeout must be 1..60"; - } - } - default 5; - } - - leaf passkey { - type string { - length "1..65"; - pattern "[^ #,]*" { - error-message 'TACACS shared secret (Valid chars are ASCII printable except SPACE, "#", and ",")'; - } - } - description "Shared secret used for encrypting the communication"; - } - - leaf src_intf { - type union { - type leafref { - path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; - } - type leafref { - path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; - } - type leafref { - path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - } - type leafref { - path "/loopback:sonic-loopback-interface/loopback:LOOPBACK_INTERFACE/loopback:LOOPBACK_INTERFACE_LIST/loopback:name"; - } - //type leafref { - // path "/mgmt-port:sonic-mgmt-port/mgmt-port:MGMT_PORT/mgmt-port:MGMT_PORT_LIST/mgmt-port:name"; - //} - } - description "Source IP to use from source interface for TACACS+ server communication."; - } - } - } - } -} From 5f75b445201c0bc65f8aaf6ac6858cbd0d148e8a Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Fri, 21 May 2021 19:58:40 +0000 Subject: [PATCH 05/12] Modify setup.py to include sflow Signed-off-by: ArthiSivanantham --- src/sonic-yang-models/setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 8c7c74ad77d5..d511b9898a5a 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -52,7 +52,6 @@ './yang-models/sonic-loopback-interface.yang', './yang-models/sonic-port.yang', './yang-models/sonic-portchannel.yang', - './yang-models/sonic-sflow.yang', './yang-models/sonic-types.yang', './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', From 5e3fd6a16fa55dc590e1c31076d1064745511dd5 Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Tue, 25 May 2021 22:51:58 +0000 Subject: [PATCH 06/12] Include sflow in setup.py Signed-off-by: ArthiSivanantham --- src/sonic-yang-models/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index d511b9898a5a..8c7c74ad77d5 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -52,6 +52,7 @@ './yang-models/sonic-loopback-interface.yang', './yang-models/sonic-port.yang', './yang-models/sonic-portchannel.yang', + './yang-models/sonic-sflow.yang', './yang-models/sonic-types.yang', './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', From 59d9510a73c3474f30d55c0d07509c7374872081 Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Sun, 6 Jun 2021 01:49:35 +0000 Subject: [PATCH 07/12] Update key of sflow session to inlude interface all case Signed-off-by: ArthiSivanantham --- .../tests/yang_model_tests/tests/sflow.json | 7 +++++-- .../tests/yang_model_tests/tests_config/sflow.json | 13 +++++++++++++ src/sonic-yang-models/yang-models/sonic-sflow.yang | 9 +++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json index afdd2623a437..86a9659a9826 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json @@ -19,8 +19,11 @@ }, "SFLOW_SESSION_TEST_WITH_NON_EXIST_PORT": { "desc": "Configure Port in SFLOW_SESSION table which does not exist in PORT table.", - "eStrKey": "LeafRef", - "eStr": ["port", "name"] + "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.", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json index 8fb0fd2fd2af..54179e88e760 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json @@ -102,6 +102,19 @@ } }, + "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": { diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang index f2ca931e454b..94123b1f8e06 100644 --- a/src/sonic-yang-models/yang-models/sonic-sflow.yang +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -64,8 +64,13 @@ module sonic-sflow{ key "port"; leaf port { - type leafref { - path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + type union { + type leafref { + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type string { + pattern "all"; + } } } From 62918c7b7d5c73fcb0d669ef7104e8da8de281f9 Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Fri, 11 Jun 2021 00:49:18 +0000 Subject: [PATCH 08/12] Modify type of vlan to string due to build issues Signed-off-by: ArthiSivanantham --- src/sonic-yang-models/yang-models/sonic-sflow.yang | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang index 94123b1f8e06..e0849fab9836 100644 --- a/src/sonic-yang-models/yang-models/sonic-sflow.yang +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -14,9 +14,11 @@ module sonic-sflow{ import sonic-port { prefix port; } + /* import sonic-vlan { prefix vlan; } + */ import sonic-portchannel { prefix lag; } @@ -121,9 +123,14 @@ module sonic-sflow{ type leafref { path "/mgmt-port:sonic-mgmt-port/mgmt-port:MGMT_PORT/mgmt-port:MGMT_PORT_LIST/mgmt-port:name"; }*/ + /* type leafref { path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } + */ + type string { + pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + } } description "Interface name"; } From 698cccef013e735edd5be9dcb6c57c14580429d4 Mon Sep 17 00:00:00 2001 From: Arthi Sivanantham Date: Sun, 20 Jun 2021 19:21:08 -0700 Subject: [PATCH 09/12] 1. Add must statement for sflow session sample rate. 2. Enable mgmt_port type for sflow session agent id Signed-off-by: Arthi Sivanantham --- .../tests/yang_model_tests/tests/sflow.json | 4 ++++ .../tests/yang_model_tests/tests_config/sflow.json | 14 ++++++++++++++ src/sonic-yang-models/yang-models/sonic-sflow.yang | 10 ++++------ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json index 86a9659a9826..42d09a773c0d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/sflow.json @@ -29,6 +29,10 @@ "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." }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json index 54179e88e760..a01877d52159 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json @@ -144,6 +144,20 @@ } }, + "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": { diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang index e0849fab9836..50418c70c565 100644 --- a/src/sonic-yang-models/yang-models/sonic-sflow.yang +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -22,11 +22,9 @@ module sonic-sflow{ import sonic-portchannel { prefix lag; } - /* - import sonic-mgmt-port { + import sonic-mgmt_port { prefix mgmt-port; } - */ description "SFLOW yang Module for SONiC OS"; @@ -82,6 +80,7 @@ module sonic-sflow{ } leaf sample_rate { + must "../port != 'all'"; type uint32 { range "256..8388608" { error-message "sFlow sample rate must be [256-8388608]"; @@ -119,10 +118,9 @@ module sonic-sflow{ type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - /* type leafref { - path "/mgmt-port:sonic-mgmt-port/mgmt-port:MGMT_PORT/mgmt-port:MGMT_PORT_LIST/mgmt-port:name"; - }*/ + path "/mgmt-port:sonic-mgmt_port/mgmt-port:MGMT_PORT/mgmt-port:MGMT_PORT_LIST/mgmt-port:name"; + } /* type leafref { path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; From fa0cd3279bfc76be2b4b55079d801fa13a38744c Mon Sep 17 00:00:00 2001 From: Arthi Sivanantham Date: Mon, 21 Jun 2021 11:49:20 -0700 Subject: [PATCH 10/12] Add description for sflow session table all key Signed-off-by: Arthi Sivanantham --- src/sonic-yang-models/yang-models/sonic-sflow.yang | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang index 50418c70c565..17e772c99439 100644 --- a/src/sonic-yang-models/yang-models/sonic-sflow.yang +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -70,6 +70,7 @@ module sonic-sflow{ } type string { pattern "all"; + description "Sets sflow session table attributes for all interfaces"; } } } From 5c459dd087fa128bc3ae6e99b4cf93af165cc4af Mon Sep 17 00:00:00 2001 From: Arthi Sivanantham Date: Mon, 21 Jun 2021 12:11:52 -0700 Subject: [PATCH 11/12] Fix build issues Signed-off-by: Arthi Sivanantham --- src/sonic-yang-models/yang-models/sonic-sflow.yang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-yang-models/yang-models/sonic-sflow.yang b/src/sonic-yang-models/yang-models/sonic-sflow.yang index 17e772c99439..62984f064c51 100644 --- a/src/sonic-yang-models/yang-models/sonic-sflow.yang +++ b/src/sonic-yang-models/yang-models/sonic-sflow.yang @@ -70,9 +70,9 @@ module sonic-sflow{ } type string { pattern "all"; - description "Sets sflow session table attributes for all interfaces"; } } + description "Sets sflow session table attributes for either all interfaces or a specific Ethernet interface."; } leaf admin_state { From 6487d32a11385dbfd93a2613f3f37aa695f8a4d0 Mon Sep 17 00:00:00 2001 From: Arthi Sivanantham Date: Mon, 5 Jul 2021 13:19:26 -0700 Subject: [PATCH 12/12] Fix test case attributes Signed-off-by: Arthi Sivanantham --- .../tests/yang_model_tests/tests_config/sflow.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json index a01877d52159..5d1a561a9f66 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sflow.json @@ -6,7 +6,7 @@ { "name": "collector1", "collector_ip": "10.100.12.13", - "collector_port": "6343" + "collector_port": "6343" } ] } @@ -216,7 +216,6 @@ "sonic-sflow:sonic-sflow": { "sonic-sflow:SFLOW": { "global": { - "agent_id": "Ethernet0", "admin_state": "up", "polling_interval": "305" }