Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def scrape_device(device, host, username, password):
""" Scrape a device and return the results as list of neighbors """
dname = device['remote_device_id']
ses = execute.get_session(host, device['os'], username, password)
cdp = execute.send_command(ses, 'show cdp neighbor detail', dname)
lldp = execute.send_command(ses, 'show lldp neighbor detail', dname)
lldp_sum = execute.send_command(ses, 'show lldp neighbor', dname)
if device['os'] == 'cisco_nxos':
nd_cdp = parse.parse_cdp(cdp, device)
nd_lldp = parse.parse_lldp(lldp, lldp_sum, device)
elif device['os'] == 'cisco_ios':
nd_cdp = parse.parse_cdp(cdp, device)
nd_lldp = parse.parse_lldp(lldp, lldp_sum, device)
else:
logger.warning('Unknown OS Type to Parse on %s: %s', dname, device['os'])
for n in nd_cdp: