Exemplo n.º 1
0
def layer_2():
    """Gets layer two information from the device"""

    return render_template('get_layer_two.html',
                           neighbors=QueryDbFor.query_cdp(device),
                           vlans=QueryDbFor.query_vlans(device),
                           trunks=QueryDbFor.query_trunks(device),
                           access_ports=QueryDbFor.query_access_ports(device),
                           port_chan=QueryDbFor.query_port_channels(device),
                           roots=QueryDbFor.query_spanning_tree(device),
                           mac_arp=QueryDbFor.query_mac_to_arp(device),
                           model=model)
Exemplo n.º 2
0
def table_refresh():
    """Used for table refreshes"""

    # Get for attribute 'name', match condition, refresh data table

    if request.form.get('action') == 'arp':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port, 'arp')
        return jsonify({
            'data':
            render_template('refresh_arp.html',
                            arps=QueryDbFor.query_arp_table(device))
        })
    elif request.form.get('action') == 'bgp':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port, 'bgp')
        return jsonify({
            'data':
            render_template('refresh_bgp.html',
                            bgp=QueryDbFor.query_bgp_status(device))
        })
    elif request.form.get('action') == 'ospf':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port,
                                   'ospf')
        return jsonify({
            'data':
            render_template('refresh_ospf.html',
                            ospf=QueryDbFor.query_ospf_status(device))
        })
    elif request.form.get('action') == 'mac':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port, 'mac')
        return jsonify({
            'data':
            render_template('refresh_mac.html',
                            mac_arp=QueryDbFor.query_mac_to_arp(device))
        })
    elif request.form.get('action') == 'cdp':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port, 'cdp')
        return jsonify({
            'data':
            render_template('refresh_cdp.html',
                            neighbors=QueryDbFor.query_cdp(device))
        })
    elif request.form.get('action') == 'access':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port,
                                   'access')
        return jsonify({
            'data':
            render_template('refresh_access.html',
                            access_ports=QueryDbFor.query_access_ports(device))
        })
    elif request.form.get('action') == 'span':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port,
                                   'span')
        return jsonify({
            'data':
            render_template('refresh_span.html',
                            roots=QueryDbFor.query_spanning_tree(device))
        })
    elif request.form.get('action') == 'clearArp':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port,
                                   'clearArp')
        return jsonify({
            'data':
            render_template('refresh_arp.html',
                            arp=QueryDbFor.query_arp_table(device))
        })
    elif request.form.get('action') == 'refreshArp':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port,
                                   'refreshArp')
        return jsonify({
            'data':
            render_template('refresh_arp.html',
                            arp=QueryDbFor.query_arp_table(device))
        })
    elif request.form.get('action') == 'vlans':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port,
                                   'vlans')
        return jsonify({
            'data':
            render_template('refresh_vlans.html',
                            vlans=QueryDbFor.query_vlans(device))
        })
    elif request.form.get('action') == 'portChannel':
        GetNeconf.indivisual_poll(username, password, device, netconf_port,
                                  'portchannel')
        return jsonify({
            'data':
            render_template('refresh_port_channels.html',
                            port_chan=QueryDbFor.query_port_channels(device))
        })
    elif request.form.get('action') == 'trunks':
        GetNeconf.indivisual_poll(username,
                                  password,
                                  device,
                                  netconf_port,
                                  'trunks',
                                  ssh_port=ssh_port)
        return jsonify({
            'data':
            render_template('refresh_trunks.html',
                            trunks=QueryDbFor.query_trunks(device))
        })
    elif request.form.get('action') == 'interfaces':
        GetNeconf.indivisual_poll(username, password, device, netconf_port,
                                  'interfaces')
        return jsonify({
            'data':
            render_template('refresh_table.html',
                            interfaces=QueryDbFor.query_interfaces(device))
        })
    elif request.form.get('action') == 'hsrp':
        GetNeconf.indivisual_poll(username, password, device, netconf_port,
                                  'hsrp')
        return jsonify({
            'data':
            render_template('refresh_hsrp.html',
                            hsrp=QueryDbFor.query_hsrp(device))
        })
    elif request.form.get('action') == 'peer_count':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port,
                                   'peer_count')
        return jsonify({
            'data':
            render_template('dmvpn_peer_refresh.html',
                            dmvpn_status=QueryDbFor.query_dmvpn_status(device))
        })
    elif request.form.get('action') == 'borderRouters':
        GetNetmiko.indivisual_poll(username, password, device, ssh_port,
                                   'borderRouters')
        return jsonify({
            'data':
            render_template(
                'refresh_border_routers.html',
                border_routers=QueryDbFor.query_ospf_routers(device))
        })