[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-versions.yang',
'./yang-models/sonic-vlan.yang',
'./yang-models/sonic-vrf.yang',
'./yang-models/sonic_yang_tree']),
],
zip_safe=False,

View File

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

View File

@ -23,5 +23,21 @@
"desc": "Configure Port in PORTCHANNEL_MEMEBER table which does not exist in PORT table.",
"eStrKey": "LeafRef",
"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;
}
import sonic-vrf {
prefix vrf;
}
description "INTERFACE yang Module for SONiC OS";
revision 2021-03-30 {
description "Modify the type of vrf name";
}
revision 2019-07-01 {
description "First Revision";
}
@ -45,9 +53,8 @@ module sonic-interface {
}
leaf vrf_name {
type string {
pattern "Vrf[a-zA-Z0-9_-]+";
length 3..255;
type leafref {
path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
}
}
}

View File

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

View File

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

View File

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

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