[yang]: SONiC Yang model for PORTCHANNEL_INTERFACE_LIST and VRF (#7194)

SONiC YANG model support for PORTCHANNEL_INTERFACE_LIST and VRF in config DB.

Signed-off-by: Arthi Sivanantham <arthi_sivanantham@dell.com>
This commit is contained in:
ArthiSivanantham 2021-04-15 19:15:04 -07:00 committed by GitHub
parent ee728aab7b
commit cbd4ef594c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 351 additions and 113 deletions

View File

@ -55,6 +55,7 @@ setup(
'./yang-models/sonic-types.yang', './yang-models/sonic-types.yang',
'./yang-models/sonic-versions.yang', './yang-models/sonic-versions.yang',
'./yang-models/sonic-vlan.yang', './yang-models/sonic-vlan.yang',
'./yang-models/sonic-vrf.yang',
'./yang-models/sonic_yang_tree']), './yang-models/sonic_yang_tree']),
], ],
zip_safe=False, zip_safe=False,

View File

@ -1,5 +1,9 @@
{ {
"SAMPLE_CONFIG_DB_JSON": { "SAMPLE_CONFIG_DB_JSON": {
"VRF": {
"Vrf_blue": {
}
},
"PORTCHANNEL": { "PORTCHANNEL": {
"PortChannel0003": { "PortChannel0003": {
"admin_status": "up", "admin_status": "up",
@ -18,6 +22,10 @@
"mtu": "9100" "mtu": "9100"
} }
}, },
"PORTCHANNEL_INTERFACE": {
"PortChannel0003": {},
"PortChannel0004": {"vrf_name": "Vrf_blue"}
},
"PORTCHANNEL_MEMBER": { "PORTCHANNEL_MEMBER": {
"PortChannel0003|Ethernet1": {}, "PortChannel0003|Ethernet1": {},
"PortChannel0004|Ethernet2": {} "PortChannel0004|Ethernet2": {}

View File

@ -23,5 +23,21 @@
"desc": "Configure Port in PORTCHANNEL_MEMEBER table which does not exist in PORT table.", "desc": "Configure Port in PORTCHANNEL_MEMEBER table which does not exist in PORT table.",
"eStrKey": "LeafRef", "eStrKey": "LeafRef",
"eStr": ["port", "name"] "eStr": ["port", "name"]
},
"PORTCHANNEL_INTERFACE_LIST_VRF_TEST": {
"desc": "Configure Vrf name in PORTCHANNEL_INTERFACE table."
},
"PORTCHANNEL_INTERFACE_LIST_WITH_NO_VRF": {
"desc": "Empty PORTCHANNEL_INTERFACE table."
},
"PORTCHANNEL_INTERFACE_LIST_VRF_TEST_ON_NON_EXIST_PO": {
"desc": "Configure vrf name on a non existent PortChannel.",
"eStrKey": "LeafRef",
"eStr": ["sonic-portchannel:name"]
},
"PORTCHANNEL_INTERFACE_LIST_NON_EXIST_VRF_TEST": {
"desc": "Configure a non existent Vrf in PORTCHANNEL_INTERFACE table.",
"eStrKey": "LeafRef",
"eStr": ["sonic-vrf:name"]
} }
} }

View File

@ -0,0 +1,12 @@
{
"VRF_TEST": {
"desc": "Configure VRF in VRF table."
},
"VRF_TEST_WRONG_NAME": {
"desc": "Configure wrong value for vrf name.",
"eStr" : ["Invalid", "VRF name"]
},
"VRF_TEST_WITH_FALLBACK": {
"desc": "Configure VRF with fallback in VRF table."
}
}

View File

@ -125,5 +125,79 @@
] ]
} }
} }
},
"PORTCHANNEL_INTERFACE_LIST_VRF_TEST": {
"sonic-vrf:sonic-vrf": {
"sonic-vrf:VRF": {
"VRF_LIST": [{
"name": "Vrf_blue"
}]
}
},
"sonic-portchannel:sonic-portchannel": {
"sonic-portchannel:PORTCHANNEL": {
"PORTCHANNEL_LIST": [{
"name": "PortChannel0001",
"admin_status": "up"
}]
},
"sonic-portchannel:PORTCHANNEL_INTERFACE": {
"PORTCHANNEL_INTERFACE_LIST": [{
"name": "PortChannel0001",
"vrf_name": "Vrf_blue"
}]
}
}
},
"PORTCHANNEL_INTERFACE_LIST_WITH_NO_VRF": {
"sonic-portchannel:sonic-portchannel": {
"sonic-portchannel:PORTCHANNEL": {
"PORTCHANNEL_LIST": [{
"name": "PortChannel0001",
"admin_status": "up"
}]
},
"sonic-portchannel:PORTCHANNEL_INTERFACE": {
"PORTCHANNEL_INTERFACE_LIST": [{
"name": "PortChannel0001"
}]
}
}
},
"PORTCHANNEL_INTERFACE_LIST_VRF_TEST_ON_NON_EXIST_PO": {
"sonic-vrf:sonic-vrf": {
"sonic-vrf:VRF": {
"VRF_LIST": [{
"name": "Vrf_blue"
}]
}
},
"sonic-portchannel:sonic-portchannel": {
"sonic-portchannel:PORTCHANNEL_INTERFACE": {
"PORTCHANNEL_INTERFACE_LIST": [{
"name": "PortChannel0001",
"vrf_name": "Vrf_blue"
}]
}
}
},
"PORTCHANNEL_INTERFACE_LIST_NON_EXIST_VRF_TEST": {
"sonic-portchannel:sonic-portchannel": {
"sonic-portchannel:PORTCHANNEL": {
"PORTCHANNEL_LIST": [{
"name": "PortChannel0001",
"admin_status": "up"
}]
},
"sonic-portchannel:PORTCHANNEL_INTERFACE": {
"PORTCHANNEL_INTERFACE_LIST": [{
"name": "PortChannel0001",
"vrf_name": "Vrf_blue"
}]
}
}
} }
} }

View File

@ -0,0 +1,32 @@
{
"VRF_TEST": {
"sonic-vrf:sonic-vrf": {
"sonic-vrf:VRF": {
"VRF_LIST": [{
"name": "Vrf_blue"
}]
}
}
},
"VRF_TEST_WRONG_NAME": {
"sonic-vrf:sonic-vrf": {
"sonic-vrf:VRF": {
"VRF_LIST": [{
"name": "blue"
}]
}
}
},
"VRF_TEST_WITH_FALLBACK": {
"sonic-vrf:sonic-vrf": {
"sonic-vrf:VRF": {
"VRF_LIST": [{
"name": "Vrf_blue",
"fallback": true
}]
}
}
}
}

View File

@ -20,8 +20,16 @@ module sonic-interface {
revision-date 2019-07-01; revision-date 2019-07-01;
} }
import sonic-vrf {
prefix vrf;
}
description "INTERFACE yang Module for SONiC OS"; description "INTERFACE yang Module for SONiC OS";
revision 2021-03-30 {
description "Modify the type of vrf name";
}
revision 2019-07-01 { revision 2019-07-01 {
description "First Revision"; description "First Revision";
} }
@ -45,9 +53,8 @@ module sonic-interface {
} }
leaf vrf_name { leaf vrf_name {
type string { type leafref {
pattern "Vrf[a-zA-Z0-9_-]+"; path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
length 3..255;
} }
} }
} }

View File

@ -15,9 +15,17 @@ module sonic-loopback-interface {
revision-date 2019-07-01; revision-date 2019-07-01;
} }
import sonic-vrf {
prefix vrf;
}
description description
"SONIC LOOPBACK INTERFACE"; "SONIC LOOPBACK INTERFACE";
revision 2021-04-05 {
description "Modify the type of vrf name";
}
revision 2020-02-05 { revision 2020-02-05 {
description "First Revision"; description "First Revision";
} }
@ -34,9 +42,8 @@ module sonic-loopback-interface {
} }
leaf vrf_name { leaf vrf_name {
type string { type leafref {
pattern "Vrf[a-zA-Z0-9_-]+"; path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
length 3..255;
} }
} }
} }

View File

@ -1,143 +1,168 @@
module sonic-portchannel { module sonic-portchannel {
yang-version 1.1; yang-version 1.1;
namespace "http://github.com/Azure/sonic-portchannel"; namespace "http://github.com/Azure/sonic-portchannel";
prefix lag; prefix lag;
import sonic-types { import sonic-types {
prefix stypes; prefix stypes;
revision-date 2019-07-01; revision-date 2019-07-01;
} }
import sonic-extension { import sonic-extension {
prefix ext; prefix ext;
revision-date 2019-07-01; revision-date 2019-07-01;
} }
import sonic-port { import sonic-port {
prefix port; prefix port;
revision-date 2019-07-01; revision-date 2019-07-01;
} }
description "PORTCHANNEL yang Module for SONiC OS"; import sonic-vrf {
prefix vrf;
}
revision 2021-03-15 { description "PORTCHANNEL yang Module for SONiC OS";
description "Add SONiC PortChannel Interface model";
}
revision 2019-07-01 { revision 2021-03-31 {
description "First Revision"; description "Add PortChannel Interface List with VRF attribute";
} }
revision 2021-03-15 {
description "Add SONiC PortChannel Interface model";
}
revision 2019-07-01 {
description "First Revision";
}
container sonic-portchannel { container sonic-portchannel {
container PORTCHANNEL { container PORTCHANNEL {
description "PORTCHANNEL part of config_db.json"; description "PORTCHANNEL part of config_db.json";
list PORTCHANNEL_LIST { list PORTCHANNEL_LIST {
key "name"; key "name";
leaf name { leaf name {
type string { type string {
length 1..128; length 1..128;
pattern 'PortChannel[0-9]{1,4}'; pattern 'PortChannel[0-9]{1,4}';
} }
} }
leaf-list members { leaf-list members {
/* leaf-list members are unique by default */ /* leaf-list members are unique by default */
type union { type union {
type leafref { type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:name; path /port:sonic-port/port:PORT/port:PORT_LIST/port:name;
} }
type string { type string {
pattern ""; pattern "";
} }
} }
/* Today in SONiC, we do not delete the list once /* Today in SONiC, we do not delete the list once
* created, instead we set to empty list. Due to that * created, instead we set to empty list. Due to that
* below default values are needed. * below default values are needed.
*/ */
default ""; default "";
} }
leaf min_links { leaf min_links {
type uint8 { type uint8 {
range 1..128; range 1..128;
} }
} }
leaf description { leaf description {
type string { type string {
length 1..255; length 1..255;
} }
} }
leaf mtu { leaf mtu {
type uint16 { type uint16 {
range 1..9216; range 1..9216;
} }
} }
leaf admin_status { leaf admin_status {
mandatory true; mandatory true;
type stypes:admin_status; type stypes:admin_status;
} }
} /* end of list PORTCHANNEL_LIST */ } /* end of list PORTCHANNEL_LIST */
} /* end of container PORTCHANNEL */ } /* end of container PORTCHANNEL */
container PORTCHANNEL_MEMBER { container PORTCHANNEL_MEMBER {
description "PORTCHANNEL_MEMBER part of config_db.json"; description "PORTCHANNEL_MEMBER part of config_db.json";
list PORTCHANNEL_MEMBER_LIST { list PORTCHANNEL_MEMBER_LIST {
key "name port"; key "name port";
leaf name { leaf name {
type leafref { type leafref {
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
} }
} }
leaf port { leaf port {
/* key elements are mandatory by default */ /* key elements are mandatory by default */
type leafref { type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:name; path /port:sonic-port/port:PORT/port:PORT_LIST/port:name;
} }
} }
} /* end of list PORTCHANNEL_MEMBER_LIST */ } /* end of list PORTCHANNEL_MEMBER_LIST */
} /* end of container PORTCHANNEL_MEMBER */ } /* end of container PORTCHANNEL_MEMBER */
container PORTCHANNEL_INTERFACE { container PORTCHANNEL_INTERFACE {
description "PORTCHANNEL_INTERFACE part of config_db.json"; description "PORTCHANNEL_INTERFACE part of config_db.json";
list PORTCHANNEL_INTERFACE_IPPREFIX_LIST { list PORTCHANNEL_INTERFACE_LIST {
key "name";
key "name ip_prefix"; leaf name {
/* key elements are mandatory by default */
type leafref {
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
}
}
leaf name { leaf vrf_name {
/* key elements are mandatory by default */ type leafref {
type leafref { path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; }
} }
} } /* end of list PORTCHANNEL_INTERFACE_LIST */
leaf ip_prefix { list PORTCHANNEL_INTERFACE_IPPREFIX_LIST {
/* key elements are mandatory by default */
type stypes:sonic-ip-prefix;
}
} /* end of list PORTCHANNEL_INTERFACE_IPPREFIX_LIST */
} /* end of container PORTCHANNEL_INTERFACE */ key "name ip_prefix";
} /* end of container sonic-portchannel */ leaf name {
/* key elements are mandatory by default */
type leafref {
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
}
}
leaf ip_prefix {
/* key elements are mandatory by default */
type stypes:sonic-ip-prefix;
}
} /* end of list PORTCHANNEL_INTERFACE_IPPREFIX_LIST */
} /* end of container PORTCHANNEL_INTERFACE */
} /* end of container sonic-portchannel */
} /* end of module sonic-portchannel */ } /* end of module sonic-portchannel */

View File

@ -24,8 +24,16 @@ module sonic-vlan {
revision-date 2019-07-01; revision-date 2019-07-01;
} }
import sonic-vrf {
prefix vrf;
}
description "VLAN yang Module for SONiC OS"; description "VLAN yang Module for SONiC OS";
revision 2021-03-30 {
description "Modify the type of vrf name";
}
revision 2019-07-01 { revision 2019-07-01 {
description "First Revision"; description "First Revision";
} }
@ -49,9 +57,8 @@ module sonic-vlan {
} }
leaf vrf_name { leaf vrf_name {
type string { type leafref{
pattern "Vrf[a-zA-Z0-9_-]+"; path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
length 3..255;
} }
} }
} }

View File

@ -0,0 +1,49 @@
module sonic-vrf {
namespace "http://github.com/Azure/sonic-vrf";
prefix vrf;
import sonic-extension {
prefix sonic-ext;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC VRF";
revision 2021-03-30 {
description
"Initial revision.";
}
container sonic-vrf {
container VRF {
description "Vrf configuration.";
list VRF_LIST {
key "name";
leaf name {
type string {
pattern "Vrf[a-zA-Z0-9_-]+" {
error-message "Invalid VRF name";
error-app-tag vrf-name-invalid;
}
}
}
leaf fallback {
type boolean;
default false;
description
"Enable/disable fallback feature which is useful for specified VRF user to access internet through global/main route.";
}
} /* end of list VRF_LISt */
} /* end of container VRf */
} /* end of container sonic-vrf */
}/* end of module sonic-vrf */