2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-29 00:31:09 +00:00

Provide rescan functionality for network macmap

This commit is contained in:
Jarrod Johnson
2017-05-15 10:57:24 -04:00
parent 40f700c46d
commit 79b4482298
@@ -314,12 +314,25 @@ def _dump_locations(info, macaddr, nodename=None):
'port': location[1], 'macsonport': location[2]})
yield msg.KeyValueData(retdata)
def handle_api_request(configmanager, inputdata, operation, pathcomponents):
if operation == 'retrieve':
return handle_read_api_request(pathcomponents)
if operation in ('update', 'create') and pathcomponents[-1] == 'rescan':
eventlet.spawn_n(rescan, configmanager)
return [msg.KeyValueData({'rescan': 'started'})]
raise exc.NotImplementedException(
'Operation {0} on {1} not implemented'.format(
operation, '/'.join(pathcomponents)))
def handle_read_api_request(pathcomponents):
if len(pathcomponents) == 1:
return [msg.ChildCollection('macs/')]
elif len(pathcomponents) == 2:
return [msg.ChildCollection(x) for x in ('node-by-mac/',
'ports-by-mac/', 'switches/')]
'ports-by-mac/', 'switches/',
'rescan')]
if pathcomponents[2] == 'node-by-mac':
if len(pathcomponents) == 3:
return [msg.ChildCollection(x.replace(':', '-'))
@@ -376,6 +389,11 @@ def dump_macinfo(macaddr):
return _dump_locations(info, macaddr, _nodesbymac.get(macaddr, None))
def rescan(cfg):
for _ in update_macmap(cfg):
pass
if __name__ == '__main__':
cg = cfm.ConfigManager(None)
for res in update_macmap(cg):