support for static-route yang model (#11932)

*[Yang] support for static-route yang model #11932
This commit is contained in:
UmaMaven 2022-09-07 10:25:59 +05:30 committed by GitHub
parent 3b9bbf7d28
commit 38cc35f6da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1220 additions and 0 deletions

View File

@ -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,

View File

@ -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": {

View File

@ -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"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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 */
}