Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions osism/tasks/conductor/sonic/config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,12 +1258,12 @@ def get_vrf_for_interface(interface_name):
vrf_name = get_vrf_for_interface(port_name)

ipv4_key = f"{vrf_name}|{neighbor_id}|{BGP_AF_IPV4_UNICAST}"
config["BGP_NEIGHBOR_AF"][ipv4_key] = {"admin_status": "true"}
config["BGP_NEIGHBOR_AF"][ipv4_key] = {"admin_status": "up"}

# Only add ipv6_unicast if v6only would be true (no transfer role IPv4)
if not has_transfer_ipv4:
ipv6_key = f"{vrf_name}|{neighbor_id}|{BGP_AF_IPV6_UNICAST}"
config["BGP_NEIGHBOR_AF"][ipv6_key] = {"admin_status": "true"}
config["BGP_NEIGHBOR_AF"][ipv6_key] = {"admin_status": "up"}
logger.debug(
f"Added BGP_NEIGHBOR_AF with ipv4_unicast and ipv6_unicast for interface {port_name} (no direct IPv4)"
)
Expand Down Expand Up @@ -1292,7 +1292,7 @@ def get_vrf_for_interface(interface_name):

if is_switch_connection or has_l2vpn_tag:
l2vpn_key = f"{vrf_name}|{neighbor_id}|l2vpn_evpn"
config["BGP_NEIGHBOR_AF"][l2vpn_key] = {"admin_status": "true"}
config["BGP_NEIGHBOR_AF"][l2vpn_key] = {"admin_status": "up"}
logger.debug(
f"Added BGP_NEIGHBOR_AF l2vpn_evpn for interface {port_name} "
f"(connected to {connected_device.name})"
Expand Down Expand Up @@ -1334,8 +1334,8 @@ def get_vrf_for_interface(interface_name):

ipv4_key = f"{vrf_name}|{neighbor_id}|{BGP_AF_IPV4_UNICAST}"
ipv6_key = f"{vrf_name}|{neighbor_id}|{BGP_AF_IPV6_UNICAST}"
config["BGP_NEIGHBOR_AF"][ipv4_key] = {"admin_status": "true"}
config["BGP_NEIGHBOR_AF"][ipv6_key] = {"admin_status": "true"}
config["BGP_NEIGHBOR_AF"][ipv4_key] = {"admin_status": "up"}
config["BGP_NEIGHBOR_AF"][ipv6_key] = {"admin_status": "up"}

# Add l2vpn_evpn only for switch-to-switch connections (default VRF)
if vrf_name == "default":
Expand All @@ -1348,7 +1348,7 @@ def get_vrf_for_interface(interface_name):
)
if is_switch_connection:
l2vpn_key = f"{vrf_name}|{neighbor_id}|l2vpn_evpn"
config["BGP_NEIGHBOR_AF"][l2vpn_key] = {"admin_status": "true"}
config["BGP_NEIGHBOR_AF"][l2vpn_key] = {"admin_status": "up"}
logger.debug(
f"Added BGP_NEIGHBOR_AF l2vpn_evpn for port channel {pc_name} "
f"(connected to switch {connected_device.name})"
Expand Down Expand Up @@ -1645,7 +1645,7 @@ def get_vrf_for_interface(interface_name):

# Add BGP_NEIGHBOR_AF for the matching address family
af_key = f"{vrf_name}|{peer_ip}|{address_family}"
config["BGP_NEIGHBOR_AF"][af_key] = {"admin_status": "true"}
config["BGP_NEIGHBOR_AF"][af_key] = {"admin_status": "up"}

logger.info(
f"Added BGP neighbor configuration for VLAN {vid} using peer IP {peer_ip} "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ def test_direct_ipv4_excluded_and_logged(self, bgp_config, patch_bgp, loguru_log
def test_no_direct_ipv4_adds_ipv4_and_ipv6(self, bgp_config, patch_bgp):
self._base(bgp_config, interface_ips={}, transfer_ips={})
af = bgp_config["BGP_NEIGHBOR_AF"]
assert af["default|Ethernet0|ipv4_unicast"] == {"admin_status": "true"}
assert af["default|Ethernet0|ipv6_unicast"] == {"admin_status": "true"}
assert af["default|Ethernet0|ipv4_unicast"] == {"admin_status": "up"}
assert af["default|Ethernet0|ipv6_unicast"] == {"admin_status": "up"}
assert "default|Ethernet0|l2vpn_evpn" not in af

def test_transfer_role_ipv4_adds_ipv4_only(self, bgp_config, patch_bgp):
self._base(bgp_config, transfer_ips={"eth0": "10.0.0.1/31"})
af = bgp_config["BGP_NEIGHBOR_AF"]
assert af["default|Ethernet0|ipv4_unicast"] == {"admin_status": "true"}
assert af["default|Ethernet0|ipv4_unicast"] == {"admin_status": "up"}
assert "default|Ethernet0|ipv6_unicast" not in af

def test_switch_to_switch_adds_l2vpn(self, bgp_config, patch_bgp):
patch_bgp.connected_device.return_value = _switch_device()
self._base(bgp_config)
assert bgp_config["BGP_NEIGHBOR_AF"]["default|Ethernet0|l2vpn_evpn"] == {
"admin_status": "true"
"admin_status": "up"
}

def test_non_switch_with_l2vpn_tag_adds_l2vpn(self, bgp_config, patch_bgp):
Expand Down Expand Up @@ -198,8 +198,8 @@ class TestBgpNeighborAfPortChannels:
def test_adds_ipv4_and_ipv6(self, bgp_config, patch_bgp):
_call_bgp(bgp_config, connected_portchannels={"PortChannel1"})
af = bgp_config["BGP_NEIGHBOR_AF"]
assert af["default|PortChannel1|ipv4_unicast"] == {"admin_status": "true"}
assert af["default|PortChannel1|ipv6_unicast"] == {"admin_status": "true"}
assert af["default|PortChannel1|ipv4_unicast"] == {"admin_status": "up"}
assert af["default|PortChannel1|ipv6_unicast"] == {"admin_status": "up"}

def test_switch_connection_adds_l2vpn(self, bgp_config, patch_bgp):
patch_bgp.connected_device.return_value = _switch_device()
Expand Down Expand Up @@ -365,7 +365,7 @@ def test_untagged_member_with_peer_ip(self, bgp_config, patch_bgp):
"v6only": "false",
}
assert bgp_config["BGP_NEIGHBOR_AF"]["default|192.0.2.20|ipv4_unicast"] == {
"admin_status": "true"
"admin_status": "up"
}

def test_untagged_member_with_peer_ipv6(self, bgp_config, patch_bgp):
Expand All @@ -384,7 +384,7 @@ def test_untagged_member_with_peer_ipv6(self, bgp_config, patch_bgp):
"v6only": "false",
}
assert bgp_config["BGP_NEIGHBOR_AF"]["default|2001:db8::20|ipv6_unicast"] == {
"admin_status": "true"
"admin_status": "up"
}
assert "default|2001:db8::20|ipv4_unicast" not in bgp_config["BGP_NEIGHBOR_AF"]

Expand All @@ -404,10 +404,10 @@ def test_dual_stack_peer_adds_both_neighbors(self, bgp_config, patch_bgp):
"default|2001:db8::20",
}
assert bgp_config["BGP_NEIGHBOR_AF"]["default|192.0.2.20|ipv4_unicast"] == {
"admin_status": "true"
"admin_status": "up"
}
assert bgp_config["BGP_NEIGHBOR_AF"]["default|2001:db8::20|ipv6_unicast"] == {
"admin_status": "true"
"admin_status": "up"
}

def test_ipv4_only_svi_skips_ipv6_peer(self, bgp_config, patch_bgp):
Expand Down Expand Up @@ -1072,8 +1072,8 @@ def test_svi_peer_resolved_for_untagged_port_channel(self, bgp_config, patch_bgp
"v6only": "false",
}
assert bgp_config["BGP_NEIGHBOR_AF"] == {
"default|192.0.2.1|ipv4_unicast": {"admin_status": "true"},
"default|2001:db8::1|ipv6_unicast": {"admin_status": "true"},
"default|192.0.2.1|ipv4_unicast": {"admin_status": "up"},
"default|2001:db8::1|ipv6_unicast": {"admin_status": "up"},
}
# The SVI lookup is the one caller that opts into the LAG member walk;
# without the flag the resolver stops at the uncabled bundle and this
Expand Down