forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chassis][yang]yang model for bgp voq chassis neighbor (sonic-net#10642)
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
1 parent
00ed2ce
commit 5e45879
Showing
5 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/sonic-yang-models/tests/yang_model_tests/tests/bgp_voq_chassis_neighbor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} | ||
} |
206 changes: 206 additions & 0 deletions
206
src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_voq_chassis_neighbor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} | ||
} | ||
} | ||
} |