From 909a83bd55ffdaf0af24c58142009f212cd51a4a Mon Sep 17 00:00:00 2001 From: Steven Mosher Date: Fri, 15 Dec 2023 09:52:01 -0500 Subject: [PATCH] feat: allow IPV4_LABELED_UNICAST in default vrf, configure send-community standard if no community type specified, and assign peer groups to ipv4 BGP neighbors --- .../translation/openconfig_xe/xe_bgp.py | 5 ++++- package_nso_to_oc/xe/xe_bgp.py | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/mdd/python/translation/openconfig_xe/xe_bgp.py b/mdd/python/translation/openconfig_xe/xe_bgp.py index dfd751d..f67603d 100644 --- a/mdd/python/translation/openconfig_xe/xe_bgp.py +++ b/mdd/python/translation/openconfig_xe/xe_bgp.py @@ -62,7 +62,8 @@ def xe_bgp_global_program_service(self, nso_props, service_protocol, network_ins device_bgp_cbd.bgp.default.ipv4_unicast = False # If using AFI_SAFI turn off BGP ipv4 default for afi_safi_service in service_bgp_global.afi_safis.afi_safi: if network_instance_type == 'oc-ni-types:DEFAULT_INSTANCE' and afi_safi_service.config.enabled: - if afi_safi_service.config.afi_safi_name == 'oc-bgp-types:IPV4_UNICAST': + if afi_safi_service.config.afi_safi_name == 'oc-bgp-types:IPV4_UNICAST' or \ + afi_safi_service.config.afi_safi_name == 'oc-bgp-types:IPV4_LABELED_UNICAST': if not device_bgp_cbd.address_family.ipv4.exists('unicast'): device_bgp_cbd.address_family.ipv4.create('unicast') if afi_safi_service.ipv4_unicast.config.send_default_route: @@ -344,6 +345,8 @@ def xe_bgp_neighbors_program_service(self, nso_props, service_protocol, network_ apply_policy(neighbor_object_cdb, afi_safi_service) if service_bgp_neighbor.config.send_community and service_bgp_neighbor.config.send_community != 'NONE': send_community(neighbor_object_cdb, service_bgp_neighbor) + if afi_safi_service.config.afi_safi_name == 'oc-bgp-types:IPV4_LABELED_UNICAST': + neighbor_object_cdb.send_label.create() elif afi_safi_service.config.afi_safi_name == 'oc-bgp-types:L3VPN_IPV4_UNICAST': if not device_bgp_cbd.address_family.vpnv4['unicast'].neighbor.exists( service_bgp_neighbor.neighbor_address): diff --git a/package_nso_to_oc/xe/xe_bgp.py b/package_nso_to_oc/xe/xe_bgp.py index 3c44c09..2064d66 100644 --- a/package_nso_to_oc/xe/xe_bgp.py +++ b/package_nso_to_oc/xe/xe_bgp.py @@ -509,10 +509,10 @@ def process_neighbor_and_neighbor_tag(is_afi_safi, attr_name, bgp_before, bgp_le process_as_override(neighbor, peer_or_neighbor, index, neighbor_leftover) process_send_label(neighbor, peer_or_neighbor, index, neighbor_leftover) - if attr_name == ATTR_NEIGHBOR: - process_shutdown(neighbor, peer_or_neighbor, index, neighbor_leftover) - process_peer_group(neighbor, peer_or_neighbor, index, neighbor_leftover) - process_ttl_security(neighbor, peer_or_neighbor, index, neighbor_leftover) + if attr_name == ATTR_NEIGHBOR: + process_shutdown(neighbor, peer_or_neighbor, index, neighbor_leftover) + process_peer_group(neighbor, peer_or_neighbor, index, neighbor_leftover) + process_ttl_security(neighbor, peer_or_neighbor, index, neighbor_leftover) if len(neighbor_leftover) > index and neighbor_leftover[index] != None: if "peer-group" in neighbor_leftover[index]: del neighbor_leftover[index]["peer-group"] @@ -548,13 +548,16 @@ def delete_leftover_neighbor_prop(attr_name, index, neighbor_leftover): del neighbor_leftover[index][attr_name] def process_send_community(neighbor, peer_group_or_neighbor, index, neighbor_leftover): - if not neighbor.get("send-community", {}).get("send-community-where"): + if not neighbor.get("send-community"): return - - peer_group_or_neighbor["openconfig-network-instance:config"][ - "openconfig-network-instance:send-community"] = neighbor["send-community"]["send-community-where"].upper() + if neighbor.get("send-community", {}).get("send-community-where"): + peer_group_or_neighbor["openconfig-network-instance:config"][ + "openconfig-network-instance:send-community"] = neighbor["send-community"]["send-community-where"].upper() + else: + peer_group_or_neighbor["openconfig-network-instance:config"][ + "openconfig-network-instance:send-community"] = "STANDARD" delete_leftover_neighbor_prop("send-community", index, neighbor_leftover) - + def process_route_reflectors(neighbor, peer_group_or_neighbor, index, neighbor_leftover, is_afi_safi): if not "route-reflector-client" in neighbor and not "cluster-id" in neighbor: return @@ -716,7 +719,6 @@ def process_shutdown(neighbor, peer_group_or_neighbor, index, neighbor_leftover) def process_peer_group(neighbor, peer_group_or_neighbor, index, neighbor_leftover): if not "peer-group" in neighbor: return - peer_group_or_neighbor["openconfig-network-instance:config"][ "openconfig-network-instance:peer-group"] = neighbor["peer-group"] delete_leftover_neighbor_prop("peer-group", index, neighbor_leftover)