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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_vlan_group_name_single_cab():
}


def test_vlan_group_name_pair_cab():
def test_vlan_group_name_pair_cab_dash_one():
assert vlan_group_names(
[
port("a1-1-1.abc1"),
Expand All @@ -61,6 +61,23 @@ def test_vlan_group_name_pair_cab():
}


def test_vlan_group_name_pair_cab_dash_two():
assert vlan_group_names(
[
port("a1-1-2.abc1"),
port("a1-2-2.abc1"),
port("a1-1-1f.abc1"),
port("a1-2-1f.abc1"),
],
mapping,
) == {
"a1-1-2.abc1": "a1-1-2/a1-2-2-network",
"a1-2-2.abc1": "a1-1-2/a1-2-2-network",
"a1-1-1f.abc1": "a1-1/a1-2-storage",
"a1-2-1f.abc1": "a1-1/a1-2-storage",
}


def test_vlan_group_name_with_domain():
assert vlan_group_names(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def vlan_group_names(
racks separated by a slash:

["a11-12-1", "a11-13-1"] => "a11-12/a11-13-network"

In a pair of racks using -2 switches, we add a -2 to the cabinet name:

["a11-12-2", "a11-13-2"] => "a11-12-2/a11-13-2-network"
"""
assert_consistent_data_center(ports)
assert_single_or_paired_racks(ports)
Expand All @@ -42,9 +46,19 @@ def vlan_group_names(
vlan_group_names = {}
for switch_category, ports_in_group in vlan_groups.items():
rack_names = {p.rack_name for p in ports_in_group}
switch_suffixes = {p.switch_suffix for p in ports_in_group}

# Special case naming for pairs of racks that have multiple leaf pairs.
# (We don't handle multiple pairs in a single rack.)
if switch_suffixes in [{"2"}, {"3"}, {"4"}, {"5"}, {"6"}]:
suffix = next(iter(switch_suffixes))
rack_names = {f"{rack_name}-{suffix}" for rack_name in rack_names}

vlan_group_name = "/".join(sorted(rack_names)) + "-" + switch_category

for p in ports_in_group:
vlan_group_names[p.switch_system_name] = vlan_group_name

return vlan_group_names
Comment thread
stevekeay marked this conversation as resolved.


Expand Down
Loading