Skip to content

Commit

Permalink
feat: allow IPV4_LABELED_UNICAST in default vrf, configure send-commu…
Browse files Browse the repository at this point in the history
…nity standard if no community type specified, and assign peer groups to ipv4 BGP neighbors
  • Loading branch information
stmosher committed Dec 15, 2023
1 parent c184b63 commit 909a83b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
5 changes: 4 additions & 1 deletion mdd/python/translation/openconfig_xe/xe_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
22 changes: 12 additions & 10 deletions package_nso_to_oc/xe/xe_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 909a83b

Please sign in to comment.