def get_root_neighbors(device):
try:
parser = class_mapping.get(device.device_class)
if not parser:
raise RuntimeError('No parser found for {}'.format(device))
device_obj = parser(device.device_name, config.credentials)
if device_obj.connect():
neighbors = device_obj.get_neighbors()
device_obj.disconnect()
return neighbors
except Exception as e:
print("****{}**** failed connecting to root. Error ****{}****".format(device.device_name, e))
exc_type, exc_value, exc_traceback = sys.exc_info()
print(repr(traceback.extract_tb(exc_traceback)))
finally:
if device_obj.is_connected:
device_obj.disconnect()
评论列表
文章目录