[yang][multi-asic]bgp internal neighbor yang model (#10632)

closes #10157

Why I did it
Add yang model for the bgp_internal_neighbor table in config_db

How I did it
Add new yang model file and unit tests

How to verify it
UT and compile sonic_yang_models-1.0-py3-none-any.whl and sonic_yang_mgmt-1.0-py3-none-any.whl

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
This commit is contained in:
arlakshm 2022-05-04 15:05:44 -07:00 committed by GitHub
parent 6284d136ec
commit 288d667c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 270 additions and 4 deletions

View File

@ -82,6 +82,7 @@ setup(
'./yang-models/sonic-bgp-common.yang',
'./yang-models/sonic-bgp-global.yang',
'./yang-models/sonic-bgp-monitor.yang',
'./yang-models/sonic-bgp-internal-neighbor.yang',
'./yang-models/sonic-bgp-neighbor.yang',
'./yang-models/sonic-bgp-peergroup.yang',
'./yang-models/sonic-bgp-peerrange.yang',

View File

@ -103,18 +103,32 @@
"tpid": "0x9200",
"mtu": "9100",
"lacp_key": "auto"
},
"PortChannel42": {
"admin_status": "up",
"members": [
"Ethernet-BP0",
"Ethernet-BP4"
],
"min_links": "2",
"mtu": "9100",
"tpid": "0x8100"
}
},
"PORTCHANNEL_INTERFACE": {
"PortChannel0003": {
"nat_zone": "1"
},
"PortChannel0004": {"vrf_name": "Vrf_blue"}
"PortChannel0004": {"vrf_name": "Vrf_blue"},
"PortChannel42|10.1.0.1/31": {},
"PortChannel42|2603:10e2:400:1::2/126": {}
},
"PORTCHANNEL_MEMBER": {
"PortChannel0003|Ethernet1": {},
"PortChannel0004|Ethernet2": {},
"PortChannel2|Ethernet12": {}
"PortChannel2|Ethernet12": {},
"PortChannel42|Ethernet-BP0": {},
"PortChannel42|Ethernet-BP4": {}
},
"VLAN_INTERFACE": {
"Vlan111": {
@ -734,6 +748,32 @@
"speed": "11100",
"tpid": "0x8100",
"admin_status": "up"
},
"Ethernet-BP0": {
"admin_status": "up",
"alias": "Eth4-ASIC0",
"asic_port_name": "Eth4-ASIC0",
"description": "ASIC2:Eth0-ASIC2",
"index": "0",
"lanes": "17,18,19,20",
"mtu": "9100",
"pfc_asym": "off",
"role": "Int",
"speed": "40000",
"tpid": "0x8100"
},
"Ethernet-BP4": {
"admin_status": "up",
"alias": "Eth5-ASIC0",
"asic_port_name": "Eth5-ASIC0",
"description": "ASIC2:Eth1-ASIC2",
"index": "1",
"lanes": "21,22,23,24",
"mtu": "9100",
"pfc_asym": "off",
"role": "Int",
"speed": "40000",
"tpid": "0x8100"
}
},
"ACL_TABLE": {
@ -1704,8 +1744,30 @@
"send_sci": "true",
"rekey_period": "3600"
}
}
},
"BGP_INTERNAL_NEIGHBOR": {
"10.1.0.0": {
"asn": "64850",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.1.0.1",
"name": "ASIC1",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
},
"2603:10e2:400:1::1": {
"asn": "64850",
"holdtime": "180",
"keepalive": "60",
"local_addr": "2603:10e2:400:1::2",
"name": "ASIC0",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
}
}
},
"SAMPLE_CONFIG_DB_UNKNOWN": {
"UNKNOWN_TABLE": {

View File

@ -0,0 +1,17 @@
{
"BGP_INTERNAL_TEST": {
"desc": "Load bgp internal neighbor table with ipv4 and ipv6 neighbors."
},
"BGP_INTERNAL_INVALID_ASN_TEST": {
"desc": "Load bgp internal neighbor table with ipv4 neighbor having incorrect asn.",
"eStr": ["Internal iBGP neighbors should have same ASN as defined in device metadata"]
},
"BGP_INVALID_LOCAL_ADDRESS_FAMILY_TEST": {
"desc": "Load bgp internal ipv4 neighboripv6 local address.",
"eStr": ["local address and neighbor address family doesnt match"]
},
"BGP_LOCAL_ADDRESS_ABSENT_TEST": {
"desc":"Load bgp internal neighbor table no local address.",
"eStrKey" : "Mandatory"
}
}

View File

@ -0,0 +1,128 @@
{
"BGP_INTERNAL_TEST": {
"sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": {
"sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": {
"BGP_INTERNAL_NEIGHBOR_LIST": [
{
"neighbor": "10.0.0.1",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.2",
"name": "ASIC0",
"nhopself": "0",
"rrclient": "0",
"admin_status": "up"
},
{
"neighbor": "2603:10e2:400:1::1",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "2603:10e2:400:1::2",
"name": "ASIC0",
"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": "MASIC",
"platform": "multi-asic"
}
}
}
},
"BGP_INTERNAL_INVALID_ASN_TEST": {
"sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": {
"sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": {
"BGP_INTERNAL_NEIGHBOR_LIST": [
{
"neighbor": "10.0.0.1",
"asn": "65002",
"holdtime": "180",
"keepalive": "60",
"local_addr": "10.0.0.2",
"name": "ASIC0",
"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": "MASIC",
"platform": "multi-asic"
}
}
}
},
"BGP_INVALID_LOCAL_ADDRESS_FAMILY_TEST": {
"sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": {
"sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": {
"BGP_INTERNAL_NEIGHBOR_LIST": [
{
"neighbor": "10.0.0.1",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"local_addr": "2603:10e2:400:1::5",
"name": "ASIC0",
"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": "MASIC",
"platform": "multi-asic"
}
}
}
},
"BGP_LOCAL_ADDRESS_ABSENT_TEST": {
"sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": {
"sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": {
"BGP_INTERNAL_NEIGHBOR_LIST": [
{
"neighbor": "2603:10e2:400:1::1",
"asn": "65001",
"holdtime": "180",
"keepalive": "60",
"name": "ASIC0",
"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": "MASIC",
"platform": "multi-asic"
}
}
}
}
}

View File

@ -0,0 +1,58 @@
module sonic-bgp-internal-neighbor {
namespace "http://github.com/Azure/sonic-bgp-internal-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 multi asic platforms";
revision 2021-04-10 {
description
"Initial revision.";
}
container sonic-bgp-internal-neighbor {
container BGP_INTERNAL_NEIGHBOR {
list BGP_INTERNAL_NEIGHBOR_LIST {
description "List for internal neighbors in multi asic 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 "Internal iBGP 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";
}
}
}
}
}
}
}