From 38cc35f6da630b068048af02bf141e85d444dee8 Mon Sep 17 00:00:00 2001 From: UmaMaven <106967235+UmaMaven@users.noreply.github.com> Date: Wed, 7 Sep 2022 10:25:59 +0530 Subject: [PATCH] support for static-route yang model (#11932) *[Yang] support for static-route yang model #11932 --- src/sonic-yang-models/setup.py | 2 + .../tests/files/sample_config_db.json | 9 + .../yang_model_tests/tests/static_route.json | 57 + .../tests_config/static-route.json | 1028 +++++++++++++++++ .../yang-models/sonic-static-route.yang | 124 ++ 5 files changed, 1220 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/static_route.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/static-route.json create mode 100644 src/sonic-yang-models/yang-models/sonic-static-route.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 975b84b682..961017fc7c 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -158,6 +158,7 @@ setup( './yang-models/sonic-pfc-priority-queue-map.yang', './yang-models/sonic-pfc-priority-priority-group-map.yang', './yang-models/sonic-port-qos-map.yang', + './yang-models/sonic-static-route.yang', './yang-models/sonic-macsec.yang']), ('cvlyang-models', ['./cvlyang-models/sonic-acl.yang', './cvlyang-models/sonic-bgp-common.yang', @@ -214,6 +215,7 @@ setup( './cvlyang-models/sonic-pfc-priority-queue-map.yang', './cvlyang-models/sonic-pfc-priority-priority-group-map.yang', './cvlyang-models/sonic-port-qos-map.yang', + './cvlyang-models/sonic-static-route.yang', './cvlyang-models/sonic-macsec.yang']), ], zip_safe=False, 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 b833fab06d..ddf83de7f0 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1997,6 +1997,15 @@ "console_mgmt": { "enabled": "yes" } + }, + "STATIC_ROUTE": { + "default|20.20.20.0/24": { + "blackhole": "false", + "distance": "1", + "ifname": "Ethernet14", + "nexthop": "10.184.229.212", + "nexthop-vrf": "default" + } } }, "SAMPLE_CONFIG_DB_UNKNOWN": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/static_route.json b/src/sonic-yang-models/tests/yang_model_tests/tests/static_route.json new file mode 100644 index 0000000000..a41a94a7fc --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/static_route.json @@ -0,0 +1,57 @@ +{ + "STATIC_ROUTE_TEST": { + "desc": "Configure basic static route with default VRFs with PREFIX" + }, + "STATIC_ROUTE_TEST_WITH_INTERFACE": { + "desc": "Configure with nexthop as interface instead of IP address" + }, + "STATIC_ROUTE_TEST_WITH_BLACKHOLE": { + "desc": "Configure with nexthop as blackhole" + }, + "STATIC_ROUTE_TEST_WITH_VRF": { + "desc": "Configure with routes in non default VRF" + }, + "STATIC_ROUTE_TEST_WITH_KEY_VRF_MGMT": { + "desc": "Configure with routes in mgmt VRF as key" + }, + "STATIC_ROUTE_TEST_WITH_VRF_MGMT": { + "desc": "Configure with routes with mgmt VRF as next hop" + }, + "STATIC_ROUTE_TEST_WITH_VRF_LEAK": { + "desc": "Configure with route leak across VRFS" + }, + "STATIC_ROUTE_TEST_ECMP": { + "desc": "Configure comma separated values for ECMP, with nexthop as PREFIX" + }, + "STATIC_ROUTE_TEST_ECMP_WITH_INTERFACE": { + "desc": "Configure comma separated values with nexthop as INTERFACE" + }, + "STATIC_ROUTE_TEST_ECMP_WITH_MGMT": { + "desc": "Configure comma separated values with one nexthop as mgmt" + }, + "STATIC_ROUTE_TEST_DISTANCE_INVALID": { + "desc": "Configure with invalid distance number", + "eStrKey": "Pattern" + }, + "STATIC_ROUTE_TEST_BLACKHOLE_INVALID": { + "desc": "Configure with invalid value for blackhole", + "eStrKey": "Pattern" + }, + "STATIC_ROUTE_TEST_NEXTHOP_VRF_INVALID": { + "desc": "Configure with invalid value for VRF", + "eStrKey": "Pattern" + }, + "STATIC_ROUTE_TEST_ECMP_DISTANCE_INVALID": { + "desc": "Configure with invalid distance for ECMP", + "eStrKey": "Pattern" + }, + "STATIC_ROUTE_TEST_ECMP_BLACKHOLE_INVALID": { + "desc": "Configure with invalid blackhop for ECMP", + "eStrKey": "Pattern" + }, + "STATIC_ROUTE_TEST_ECMP_NEXTHOP_VRF_INVALID": { + "desc": "Configure with invalid vrf for ECMP", + "eStrKey": "Pattern" + } + +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/static-route.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/static-route.json new file mode 100644 index 0000000000..3afdc2e8d2 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/static-route.json @@ -0,0 +1,1028 @@ +{ + "STATIC_ROUTE_TEST": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "10.0.0.1/24", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "vrf_name": "default", + "prefix":"100.100.100.1/24", + "nexthop":"10.10.10.1", + "distance": "1", + "nexthop-vrf":"default", + "blackhole":"false" + }] + } + } + }, + "STATIC_ROUTE_TEST_WITH_INTERFACE": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "10.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "vrf_name": "default", + "prefix":"100.100.100.1/24", + "nexthop":"0.0.0.0", + "ifname":"Ethernet8", + "distance": "1", + "nexthop-vrf":"default", + "blackhole":"false" + }] + } + } + }, + "STATIC_ROUTE_TEST_WITH_BLACKHOLE": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "10.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "150.150.150.0/24", + "vrf_name": "default", + "ifname": "Ethernet8", + "distance": "1", + "nexthop-vrf": "default", + "blackhole": "true" + }] + } + } + }, + "STATIC_ROUTE_TEST_WITH_VRF": { + "sonic-vrf:sonic-vrf": { + "VRF": { + "VRF_LIST": [ + { + "name": "VrfMav", + "fallback": true + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "75.75.75.0/24", + "vrf_name": "VrfMav", + "nexthop": "1.1.1.2", + "ifname": "Ethernet8", + "distance": "1", + "nexthop-vrf": "VrfMav", + "blackhole": "false" + }] + } + } + }, + "STATIC_ROUTE_TEST_WITH_KEY_VRF_MGMT": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "75.75.75.0/24", + "vrf_name": "mgmt", + "nexthop": "1.1.1.2", + "ifname": "Ethernet8", + "distance": "1", + "nexthop-vrf": "mgmt", + "blackhole": "false" + }] + } + } + }, + "STATIC_ROUTE_TEST_WITH_VRF_MGMT": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "75.75.75.0/24", + "vrf_name": "VrfMav", + "nexthop": "1.1.1.2", + "ifname": "Ethernet8", + "distance": "1", + "nexthop-vrf": "mgmt", + "blackhole": "false" + }] + } + } + }, + "STATIC_ROUTE_TEST_WITH_VRF_LEAK": { + "sonic-vrf:sonic-vrf": { + "VRF": { + "VRF_LIST": [ + { + "name": "VrfAbc", + "fallback": true + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "85.85.85.0/24", + "vrf_name": "default", + "nexthop": "1.0.0.2", + "ifname": "Ethernet8", + "distance": "1", + "nexthop-vrf": "VrfAbc", + "blackhole": "false" + }] + } + } + }, + "STATIC_ROUTE_TEST_ECMP": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "2.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "15.15.15.0/24", + "vrf_name": "default", + "nexthop": "1.0.0.2,2.0.0.2", + "distance": "1,1", + "nexthop-vrf": "default,default", + "blackhole": "false,false" + }] + } + } + }, + "STATIC_ROUTE_TEST_ECMP_WITH_MGMT": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "2.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "15.15.15.0/24", + "vrf_name": "default", + "nexthop": "1.0.0.2,2.0.0.2", + "distance": "1,1", + "nexthop-vrf": "default,mgmt", + "blackhole": "false,false" + }] + } + } + }, + "STATIC_ROUTE_TEST_ECMP_WITH_INTERFACE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "2.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "16.16.16.0/24", + "vrf_name": "default", + "nexthop": "0.0.0.0,0.0.0.0", + "ifname": "Ethernet0,Ethernet8", + "distance": "1,1", + "nexthop-vrf": "default,default", + "blackhole": "false,false" + }] + } + } + }, + "STATIC_ROUTE_TEST_DISTANCE_INVALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "16.16.16.0/24", + "vrf_name": "default", + "nexthop": "1.0.0.4", + "distance": "300", + "nexthop-vrf": "default", + "blackhole": "false" + }] + } + } + }, + "STATIC_ROUTE_TEST_BLACKHOLE_INVALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "16.16.16.0/24", + "vrf_name": "default", + "nexthop": "1.0.0.5", + "distance": "1", + "nexthop-vrf": "default", + "blackhole": "down" + }] + } + } + }, + "STATIC_ROUTE_TEST_NEXTHOP_VRF_INVALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "16.16.16.0/24", + "vrf_name": "default", + "nexthop": "1.0.05", + "distance": "1", + "nexthop-vrf": "vrf123", + "blackhole": "false" + }] + } + } + }, + "STATIC_ROUTE_TEST_NEXTHOP_VRF_INVALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "16.16.16.0/24", + "vrf_name": "default", + "nexthop": "1.0.05", + "distance": "1", + "nexthop-vrf": "vrf123", + "blackhole": "false" + }] + } + } + }, + "STATIC_ROUTE_TEST_ECMP_DISTANCE_INVALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "2.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "16.16.16.0/24", + "vrf_name": "default", + "nexthop": "1.0.0.3,2.0.0.8", + "distance": "1000,1", + "nexthop-vrf": "default,default", + "blackhole": "false,false" + }] + } + } + }, + "STATIC_ROUTE_TEST_ECMP_BLACKHOLE_INVALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "2.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "16.16.16.0/24", + "vrf_name": "default", + "nexthop": "1.0.0.4,2.0.0.3", + "distance": "1,1", + "nexthop-vrf": "default,default", + "blackhole": "no,no" + }] + } + } + }, + "STATIC_ROUTE_TEST_ECMP_NEXTHOP_VRF_INVALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "1.0.0.1/30", + "name": "Ethernet0", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet0" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "2.0.0.1/30", + "name": "Ethernet8", + "scope": "global" + } + ], + "INTERFACE_LIST": [ + { + "name": "Ethernet8" + } + ] + } + }, + "sonic-static-route:sonic-static-route": { + "sonic-static-route:STATIC_ROUTE": { + "STATIC_ROUTE_LIST": [{ + "prefix": "16.16.16.0/24", + "vrf_name": "default", + "nexthop": "1.0.0.4,2.0.0.3", + "distance": "1,1", + "nexthop-vrf": "vrf123,xyz", + "blackhole": "false,false" + }] + } + } + } + +} + + diff --git a/src/sonic-yang-models/yang-models/sonic-static-route.yang b/src/sonic-yang-models/yang-models/sonic-static-route.yang new file mode 100644 index 0000000000..48a562f242 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-static-route.yang @@ -0,0 +1,124 @@ +module sonic-static-route { + yang-version 1.1; + namespace "http://github.com/Azure/sonic-static-route"; + prefix sroute; + + import sonic-vrf { + prefix vrf; + } + import ietf-inet-types { + prefix inet; + } + import sonic-types { + prefix stypes; + } + + organization + "SONiC"; + contact + "SONiC"; + description + "STATIC ROUTE yang Module for SONiC OS"; + + revision 2022-03-17 { + description + "First Revision"; + } + + container sonic-static-route { + container STATIC_ROUTE { + description + "STATIC_ROUTE part of config_db.json"; + list STATIC_ROUTE_TEMPLATE_LIST { + key "prefix"; + leaf prefix { + type inet:ip-prefix; + description + "prefix is the destination IP address, as key"; + } + leaf nexthop { + type string; + description + "The next-hop that is to be used for the + static route as IP address. When interface needs to be + specified, use 0.0.0.0 as leaf value"; + } + leaf ifname { + type string; + description + "When interface is specified, forwarding happens through it"; + } + leaf advertise { + type string { + pattern "((true|false),)*(true|false)"; + } + default "false"; + } + } + list STATIC_ROUTE_LIST { + key "vrf_name prefix"; + leaf vrf_name { + type union { + type string { + pattern 'default'; + } + type string { + pattern 'mgmt'; + } + type string { + pattern "Vrf[a-zA-Z0-9_-]+"; + } + } + description + "Virtual Routing Instance name as key"; + } + leaf prefix { + type inet:ip-prefix; + description + "prefix is the destination IP address, as key"; + } + leaf nexthop { + type string; + description + "The next-hop that is to be used for the + static route as IP address. When interface needs to be + specified, use 0.0.0.0 as leaf value"; + } + leaf ifname { + type string; + description + "When interface is specified, forwarding happens through it"; + } + leaf distance { + type string { + pattern "((25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?),)*(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)"; + } + default "0"; + description + "Administrative Distance (preference) of the entry. The + preference defines the order of selection when multiple + sources (protocols, static, etc.) contribute to the same + prefix entry. The lower the preference, the more preferable the + prefix is. When this value is not specified, the preference is + inherited from the default preference of the implementation for + static routes."; + } + leaf nexthop-vrf { + type string { + pattern "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))"; + } + description + "VRF name of the nexthop. This is for vrf leaking"; + } + leaf blackhole { + type string { + pattern "((true|false),)*(true|false)"; + } + default "false"; + description + "blackhole refers to a route that, if matched, discards the message silently."; + } + } /* end of list STATIC_ROUTE_LIST */ + } /* end of container STATIC_ROUTE */ + } /* end of container sonic-static_route */ +}