[chassis][yang]yang model for bgp voq chassis neighbor (#10642)

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com

Why I did it
Fixes #10158

How I did it
Add yang model for config_db table BGP_VOQ_CHASSIS_NEIGHBOR and UT
This commit is contained in:
arlakshm 2022-05-04 15:07:59 -07:00 committed by GitHub
parent 288d667c66
commit 0dcbfa3a97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 313 additions and 0 deletions

View File

@ -87,6 +87,7 @@ setup(
'./yang-models/sonic-bgp-peergroup.yang', './yang-models/sonic-bgp-peergroup.yang',
'./yang-models/sonic-bgp-peerrange.yang', './yang-models/sonic-bgp-peerrange.yang',
'./yang-models/sonic-bgp-allowed-prefix.yang', './yang-models/sonic-bgp-allowed-prefix.yang',
'./yang-models/sonic-bgp-voq-chassis-neighbor.yang',
'./yang-models/sonic-breakout_cfg.yang', './yang-models/sonic-breakout_cfg.yang',
'./yang-models/sonic-buffer-pg.yang', './yang-models/sonic-buffer-pg.yang',
'./yang-models/sonic-buffer-pool.yang', './yang-models/sonic-buffer-pool.yang',

View File

@ -1729,6 +1729,28 @@
} }
}, },
"BGP_VOQ_CHASSIS_NEIGHBOR": {
"10.0.0.1": {
"asn": "64850",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.2",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
},
"3333::3:6": {
"asn": "64850",
"holdtime": "180",
"keepalive": "60",
"local_addr": "3333::3:3",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
}
},
"MACSEC_PROFILE": { "MACSEC_PROFILE": {
"test": { "test": {

View File

@ -0,0 +1,21 @@
{
"BGP_VOQ_CHASSIS_NEIGHBOR_TEST" : {
"desc": "Load bgp voq chassis neighbor"
},
"BGP_VOQ_CHASSIS_WITH_INVALID_SWITCH_TYPE_TEST" : {
"desc": "Load bgp voq chassis on non voq chassis switch",
"eStr": ["Bgp voq neighbor are applicable only when switch_type is voq"]
},
"BGP_VOQ_CHASSIS_ABSENT_LOCAL_ADDRESS_TEST" : {
"desc": "Load bgp voq chassis with no local address",
"eStrKey" : "Mandatory"
},
"BGP_VOQ_CHASSIS_INVALID_LOCAL_ADDRESS_ADDRESS_FAMILY_TEST": {
"desc": "Load ipv6 bgp voq chassis with ipv4 local address",
"eStr": ["local address and neighbor address family doesnt match"]
},
"BGP_VOQ_CHASSIS_INVALID_ASN_TEST": {
"desc" :"Load bgp voq chassis neighbor with asn number different than local asn",
"eStr": ["Voq chassis BGP neighbors should have same ASN as defined in device metadata"]
}
}

View File

@ -0,0 +1,206 @@
{
"BGP_VOQ_CHASSIS_NEIGHBOR_TEST": {
"sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": {
"sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": {
"BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [
{
"neighbor": "10.0.0.1",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.2",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
},
{
"neighbor": "3333::3:6",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "3333::3:3",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
}
]
}
},
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"localhost": {
"bgp_asn": "65001",
"default_bgp_status": "up",
"hostname": "sonic-chassis",
"platform": "voq-chassis",
"switch_type": "voq"
}
}
}
},
"BGP_VOQ_CHASSIS_WITH_INVALID_SWITCH_TYPE_TEST": {
"sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": {
"sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": {
"BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [
{
"neighbor": "10.0.0.1",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.2",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
},
{
"neighbor": "3333::3:6",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "3333::3:3",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
}
]
}
},
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"localhost": {
"bgp_asn": "65001",
"default_bgp_status": "up",
"hostname": "sonic-chassis",
"platform": "voq-chassis",
"switch_type": "chassis-packet"
}
}
}
},
"BGP_VOQ_CHASSIS_ABSENT_LOCAL_ADDRESS_TEST": {
"sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": {
"sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": {
"BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [
{
"neighbor": "10.0.0.1",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.2",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
},
{
"neighbor": "3333::3:6",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
}
]
}
},
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"localhost": {
"bgp_asn": "65001",
"default_bgp_status": "up",
"hostname": "sonic-chassis",
"platform": "voq-chassis",
"switch_type": "voq"
}
}
}
},
"BGP_VOQ_CHASSIS_INVALID_LOCAL_ADDRESS_ADDRESS_FAMILY_TEST": {
"sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": {
"sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": {
"BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [
{
"neighbor": "10.0.0.1",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.2",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
},
{
"neighbor": "3333::3:6",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "3.3.3.3",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
}
]
}
},
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"localhost": {
"bgp_asn": "65001",
"default_bgp_status": "up",
"hostname": "sonic-chassis",
"platform": "voq-chassis",
"switch_type": "voq"
}
}
}
},
"BGP_VOQ_CHASSIS_INVALID_ASN_TEST": {
"sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": {
"sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": {
"BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [
{
"neighbor": "10.0.0.1",
"asn": "65000",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.2",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
},
{
"neighbor": "3333::3:6",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "3333::3:3",
"name": "sonic-chassis-lc3",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
}
]
}
},
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"localhost": {
"bgp_asn": "65001",
"default_bgp_status": "up",
"hostname": "sonic-chassis",
"platform": "voq-chassis",
"switch_type": "voq"
}
}
}
}
}

View File

@ -0,0 +1,63 @@
module sonic-bgp-voq-chassis-neighbor {
namespace "http://github.com/Azure/sonic-bgp-voq-chassis-neighbor";
prefix bgpintnbr;
yang-version 1.1;
import ietf-inet-types {
prefix inet;
}
import sonic-device_metadata {
prefix dm;
}
import sonic-bgp-common {
prefix bgpcmn;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC BGP Internal Neighbor for voq chassis platforms";
revision 2021-04-10 {
description
"Initial revision.";
}
container sonic-bgp-voq-chassis-neighbor {
container BGP_VOQ_CHASSIS_NEIGHBOR {
list BGP_VOQ_CHASSIS_NEIGHBOR_LIST {
description "List for internal neighbors in voq chassis platforms";
key "neighbor";
leaf neighbor {
type inet:ip-address;
description "BGP Neighbor address";
}
uses bgpcmn:sonic-bgp-cmn-neigh {
refine asn {
must "(current() = /dm:sonic-device_metadata/dm:DEVICE_METADATA/dm:localhost/dm:bgp_asn)" {
error-message "Voq chassis BGP neighbors should have same ASN as defined in device metadata";
}
}
refine local_addr {
mandatory true;
must "((contains(../neighbor, '.') and contains(current(), '.')) or
(contains(../neighbor, ':') and contains(current(), ':')))" {
error-message "local address and neighbor address family doesnt match";
}
}
}
must "(/dm:sonic-device_metadata/dm:DEVICE_METADATA/dm:localhost/dm:switch_type = 'voq')" {
error-message "Bgp voq neighbor are applicable only when switch_type is voq";
}
}
}
}
}