Skip to content

Commit

Permalink
Relax switchgroup count and vendor requirements (tests missing)
Browse files Browse the repository at this point in the history
We now allow more than two switches per switchgroup and also allow
mixed-vendor switchgroups. We need this for some experimental setups in
our qa regions where we want to have certain pairs to be configured in
the same way.
  • Loading branch information
sebageek committed Aug 16, 2024
1 parent 935e601 commit 00edab9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
14 changes: 3 additions & 11 deletions networking_ccloud/common/config/config_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,9 @@ def vlan_pool(self):

@pydantic.validator('members')
def validate_members(cls, v):
# we currently plan with having exactly two members in each group
if len(v) != 2:
raise ValueError(f"Expected two switch members, got {len(v)} - "
"the code should work with other member counts, but this "
"should be checked beforehand")

# members need to be of the same platform
platforms = set(s.platform for s in v)
if len(platforms) > 1:
raise ValueError("Switchgroup members need to have the same platform! Found {}"
.format(", ".join(f"{s.name} of type {s.platform}" for s in v)))
# we currently plan having two or more members in each group
if len(v) < 2:
raise ValueError(f"Expected two or more switch members, got {len(v)}")

return v

Expand Down
10 changes: 0 additions & 10 deletions networking_ccloud/tests/unit/common/test_driver_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ def make_switch(self, name, host="1.2.3.4", platform=cc_const.PLATFORM_EOS):
return config.Switch(name=name, host=host, platform=platform, user="admin", password="maunz",
bgp_source_ip="2.3.4.5")

def test_switchgroup_two_members(self):
sw1 = self.make_switch("sw1")
sw2 = self.make_switch("sw2")
sw3 = self.make_switch("sw3")
sg_args = dict(name="foo", availability_zone="qa-de-1a", role="vpod", vtep_ip="1.1.1.1", asn=65001, group_id=1)

self.assertRaises(ValueError, config.SwitchGroup, members=[sw1], **sg_args)
self.assertRaises(ValueError, config.SwitchGroup, members=[sw1, sw2, sw3], **sg_args)
config.SwitchGroup(members=[sw1, sw2], **sg_args)

def test_switchgroup_group_ids_uniq(self):
gc = cfix.make_global_config()
sg1 = cfix.make_switchgroup("seagull", group_id=1000)
Expand Down

0 comments on commit 00edab9

Please sign in to comment.