From c04538d4f6e2160ad0b5fd0265471b59df4668aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Fele-=C5=BDor=C5=BE?= Date: Fri, 10 Apr 2026 16:40:27 +0200 Subject: [PATCH] Fix / change the format of clag_id since the old format does not work for 800G switches --- filter_plugins/cumulus.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/filter_plugins/cumulus.py b/filter_plugins/cumulus.py index 7186cd9..72386e1 100644 --- a/filter_plugins/cumulus.py +++ b/filter_plugins/cumulus.py @@ -34,19 +34,21 @@ class FilterModule(object): ''' Generate a clag-id from a list of interfaces making up a MLAG bond - The clag-id for a bond must be between 1 and 65535. Generate it by - combining the indexes of the lowest-numbered interface on each switch. - This avoids manual ID assignment while keeping them mostly stable. - - This clag-id does not change unless the lowest-numbered interface for - the bond on any switch changes. IDs of other bonds are not affected. + Interfaces on both sides must be the same. The clag-id is generated + from the interface name such as: + swp3 -> 3 + swpX -> X + swpXsY -> X0Y + This may fail on very large switches with more than 1000 ports. ''' clag_id = 0 key = lambda i: i.get('device', {}).get('name') - for device, ifaces in itertools.groupby(sorted(interfaces, key=key), key): - clag_id = 256 * clag_id + min(self.cl_iface_index(ifaces)) - if 1 <= clag_id <= 65535: # sanity checking - return clag_id + proto_iface = sorted(interfaces, key=key)[0] + g = re.match(r"[^0-9]*([0-9]+)(s([0-9]+))?", proto_iface["name"]).groups() + clag_id = g[0] + if g[2] is not None: + clag_id += '0' + g[2] + return clag_id def cl_clag_sys_mac(self, address): '''Generate a system MAC address for a MLAG with the given address'''