Fix / change the format of clag_id since the old format does not work for 800G switches
This commit is contained in:
parent
cbe9884684
commit
c04538d4f6
1 changed files with 12 additions and 10 deletions
|
|
@ -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'''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue