How to use the ndlib.execute.send_command function in ndlib

To help you get started, we’ve selected a few ndlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yantisj / ndcrawl / ndlib / topology.py View on Github external
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:
        logger.debug('Found Neighbor %s on %s', n, dname)
    ses.disconnect()
github yantisj / ndcrawl / ndlib / topology.py View on Github external
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:
        logger.debug('Found Neighbor %s on %s', n, dname)
    ses.disconnect()

    nd = parse.merge_nd(nd_cdp, nd_lldp)
github yantisj / ndcrawl / ndlib / topology.py View on Github external
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:
        logger.debug('Found Neighbor %s on %s', n, dname)
    ses.disconnect()

    nd = parse.merge_nd(nd_cdp, nd_lldp)