Exemplo n.º 1
0
def table_refresh():
    """Used for table refreshes"""

    action = request.form.get('action')

    # Used for refreshing tables without page reload, return data to call wich is js/ajax
    if action == 'arp':
        clear = GetInfo.clear_arp(netmiko_session)
        return jsonify(
            {'data': render_template('refresh_arp.html', arps=clear)})
    elif action == 'bgp':
        get_status = GetInfo.get_bgp_status(netmiko_session)
        return jsonify(
            {'data': render_template('refresh_bgp.html', bgp=get_status[0])})
    elif action == 'ospf':
        get_status = GetInfo.get_ospf_status(netmiko_session)
        return jsonify(
            {'data': render_template('refresh_ospf.html', ospf=get_status)})
    elif action == 'clearInt':
        clear = GetInfo.clear_counters(netmiko_session,
                                       request.form.get('interface'),
                                       netconf_session)
        return jsonify(
            {'data': render_template('refresh_table.html', interfaces=clear)})
    elif action == 'mac':
        mac_to_arp = GetInfo.get_mac_arp_table(netmiko_session)
        return jsonify(
            {'data': render_template('refresh_mac.html', mac_arp=mac_to_arp)})
    elif action == 'cdp':
        cdp = GetInfo.get_cdp_neighbors(netmiko_session)
        return jsonify(
            {'data': render_template('refresh_cdp.html', neighbors=cdp)})
    elif action == 'access':
        access_ports = GetInterfacesInfo.get_access_ports(netconf_session)
        return jsonify({
            'data':
            render_template('refresh_access.html', access_ports=access_ports)
        })
    elif action == 'span':
        spanning_tree = GetInfo.get_span_root(netmiko_session)
        return jsonify({
            'data':
            render_template('refresh_span.html', roots=spanning_tree)
        })
Exemplo n.º 2
0
def layer_2():
    """Gets layer two information from the device"""

    cdp = GetInfo.get_cdp_neighbors(netmiko_session)
    vlans = GetInfo.get_netmiko_vlans(netmiko_session)
    spanning_tree = GetInfo.get_span_root(netmiko_session)
    mac_to_arp = GetInfo.get_mac_arp_table(netmiko_session)
    trunks = GetInterfacesInfo.get_trunk_ports(netconf_session)
    access_ports = GetInterfacesInfo.get_access_ports(netconf_session)
    port_channels = GetInterfacesInfo.get_port_channels(netconf_session)

    return render_template('get_layer_two.html',
                           neighbors=cdp,
                           vlans=vlans,
                           trunks=trunks,
                           access_ports=access_ports,
                           port_chan=port_channels,
                           roots=spanning_tree,
                           mac_arp=mac_to_arp)