2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

Fix compatibility with some switch configurations

While some implementations mess up portid and need portdescr instead, others are
just the opposite.

Tolerate match either by description or name.
This commit is contained in:
Jarrod Johnson 2021-03-10 13:40:47 -05:00
parent c53e758170
commit 4f246e6a41
2 changed files with 14 additions and 5 deletions

View File

@ -139,7 +139,10 @@ def get_fingerprint(switch, port, configmanager, portmatch):
continue
if info.get('switch', None) != switch:
continue
if portmatch(info.get('port'), port):
if portmatch(info.get('portid', None), port):
return ('sha256$' + b64tohex(info['peersha256fingerprint']),
info.get('verified', False))
elif portmatch(info.get('port', None), port):
return ('sha256$' + b64tohex(info['peersha256fingerprint']),
info.get('verified', False))
return None, False
@ -235,19 +238,23 @@ def _extract_neighbor_data_b(args):
idx = oidindex[0][-1]
idxtoifname[idx] = _lldpdesc_to_ifname(sid, idx, str(oidindex[1]))
for remotedesc in conn.walk('1.0.8802.1.1.2.1.4.1.1.10'):
iname = idxtoifname[remotedesc[0][-2]]
iname = idxtoifname.get(remotedesc[0][-2],
idxtoportid[remotedesc[0][-2]])
_init_lldp(lldpdata, iname, remotedesc[0][-2], idxtoportid, switch)
_extract_extended_desc(lldpdata[iname], remotedesc[1], user)
for remotename in conn.walk('1.0.8802.1.1.2.1.4.1.1.9'):
iname = idxtoifname[remotename[0][-2]]
iname = idxtoifname.get(remotename[0][-2],
idxtoportid[remotename[0][-2]])
_init_lldp(lldpdata, iname, remotename[0][-2], idxtoportid, switch)
lldpdata[iname]['peername'] = str(remotename[1])
for remotename in conn.walk('1.0.8802.1.1.2.1.4.1.1.7'):
iname = idxtoifname[remotename[0][-2]]
iname = idxtoifname.get(remotename[0][-2],
idxtoportid[remotename[0][-2]])
_init_lldp(lldpdata, iname, remotename[0][-2], idxtoportid, switch)
lldpdata[iname]['peerportid'] = sanitize(remotename[1])
for remoteid in conn.walk('1.0.8802.1.1.2.1.4.1.1.5'):
iname = idxtoifname[remoteid[0][-2]]
iname = idxtoifname.get(remoteid[0][-2],
idxtoportid[remoteid[0][-2]])
_init_lldp(lldpdata, iname, remoteid[0][-2], idxtoportid, switch)
lldpdata[iname]['peerchassisid'] = sanitize(remoteid[1])
for entry in lldpdata:

View File

@ -82,6 +82,8 @@ _blacklistnames = (
def _namesmatch(switchdesc, userdesc):
if switchdesc is None:
return False
if switchdesc == userdesc:
return True
try: