Skip to content

Commit

Permalink
[chassis][yang]yang model for bgp voq chassis neighbor (sonic-net#10642)
Browse files Browse the repository at this point in the history
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com

Why I did it
Fixes sonic-net#10158

How I did it
Add yang model for config_db table BGP_VOQ_CHASSIS_NEIGHBOR and UT
  • Loading branch information
arlakshm authored and liushilongbuaa committed May 12, 2022
1 parent 00ed2ce commit 5e45879
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def run(self):
'./yang-models/sonic-bgp-peergroup.yang',
'./yang-models/sonic-bgp-peerrange.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-buffer-pg.yang',
'./yang-models/sonic-buffer-pool.yang',
Expand Down
22 changes: 22 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
"test": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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"]
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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";
}
}
}
}
}

0 comments on commit 5e45879

Please sign in to comment.