mirror of
https://github.com/xcat2/confluent.git
synced 2025-08-23 11:40:26 +00:00
Fixes to the recent attempt
Names had '/' in it and some assumptions about key were broken. Correct the various mistakes.
This commit is contained in:
@@ -168,8 +168,8 @@ def _extract_neighbor_data_b(args):
|
||||
entry = lldpdata[entry]
|
||||
entry['switch'] = switch
|
||||
peerid = '{0}--{1}'.format(
|
||||
entry.get('peerchassisid', '').replace(':', '-'),
|
||||
entry.get('peerport', '').replace(':', '-'))
|
||||
entry.get('peerchassisid', '').replace(':', '-').replace('/', '-'),
|
||||
entry.get('peerport', '').replace(':', '-').replace('/', '-'))
|
||||
entry['peerid'] = peerid
|
||||
_neighbypeerid[peerid] = entry
|
||||
_neighdata[switch] = lldpdata
|
||||
@@ -194,8 +194,9 @@ def _update_neighbors_backend(configmanager, force):
|
||||
return
|
||||
_neighdata = {'!!vintage': now}
|
||||
_neighbypeerid = {'!!vintage': now}
|
||||
switches = list_switches(configmanager)
|
||||
switchcreds = netutil.get_switchcreds(configmanager, switches) + (force,)
|
||||
switches = netutil.list_switches(configmanager)
|
||||
switchcreds = netutil.get_switchcreds(configmanager, switches)
|
||||
switchcreds = [ x + (force,) for x in switchcreds]
|
||||
pool = GreenPool(64)
|
||||
for ans in pool.imap(_extract_neighbor_data, switchcreds):
|
||||
yield ans
|
||||
@@ -256,6 +257,8 @@ def list_info(parms, requestedparameter):
|
||||
results = set([])
|
||||
requestedparameter = requestedparameter.replace('by-', '')
|
||||
for info in _neighbypeerid:
|
||||
if info == '!!vintage':
|
||||
continue
|
||||
info = _neighbypeerid[info]
|
||||
for mk in parms:
|
||||
mk = mk.replace('by-', '')
|
||||
@@ -267,7 +270,7 @@ def list_info(parms, requestedparameter):
|
||||
results.add(info[requestedparameter])
|
||||
return [msg.ChildCollection(x + suffix) for x in util.natural_sort(results)]
|
||||
|
||||
def _handle_neighbor_query(pathcomponents, configmanager, list_switches):
|
||||
def _handle_neighbor_query(pathcomponents, configmanager):
|
||||
choices, parms, listrequested, childcoll = _parameterize_path(
|
||||
pathcomponents)
|
||||
if not childcoll: # this means it's a single entry with by-peerid
|
||||
@@ -280,7 +283,7 @@ def _handle_neighbor_query(pathcomponents, configmanager, list_switches):
|
||||
if 'by-switch' in parms:
|
||||
update_switch_data(parms['by-switch'], configmanager)
|
||||
else:
|
||||
update_neighbors(configmanager)
|
||||
list(update_neighbors(configmanager))
|
||||
return list_info(parms, listrequested)
|
||||
|
||||
|
||||
|
@@ -373,14 +373,11 @@ def handle_read_api_request(pathcomponents, configmanager):
|
||||
return [msg.ChildCollection('macs/'),
|
||||
msg.ChildCollection('neighbors/')]
|
||||
elif pathcomponents[1] == 'neighbors':
|
||||
if len(pathcomponents) == 2:
|
||||
return [msg.ChildCollection('by-switch/')]
|
||||
elif len(pathcomponents) == 3:
|
||||
if len(pathcomponents) == 3 and pathcomponents[-1] == 'by-switch':
|
||||
return [msg.ChildCollection(x + '/')
|
||||
for x in list_switches(configmanager)]
|
||||
else:
|
||||
return _handle_neighbor_query(pathcomponents[2:], configmanager,
|
||||
list_switches)
|
||||
return _handle_neighbor_query(pathcomponents[2:], configmanager)
|
||||
elif len(pathcomponents) == 2:
|
||||
if pathcomponents[-1] == 'macs':
|
||||
return [msg.ChildCollection(x) for x in (# 'by-node/',
|
||||
|
Reference in New Issue
Block a user