Exemplo n.º 1
0
def post_neighbor():
    """Submit BGP for configuration"""

    build_neighbors = Build_bgp_config.Templates(request.form.get("localAs"))
    bgp_config = build_neighbors.build_neighbor(
        request.form.get("neighborId"),
        request.form.get("remoteAs"),
        model,
        policy=[
            request.form.get("softReconfig"),
            request.form.get("direction"),
            request.form.get("policy"),
            request.form.get("nextHop")
        ])
    status = SendConfig.send_configuration(netconf_session, bgp_config)

    if status == 'Success':
        get_status = GetInfo.get_bgp_status(netmiko_session)
        return jsonify({
            'data':
            render_template('bgp_neighbor_table.html', bgp=get_status[0])
        })
    else:
        return jsonify(
            {'data': render_template('config_failed.html', status=status)})
Exemplo n.º 2
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 == 'routes':

        # ReAuth and get IOS-XE routing table
        routing_session = ConnectWith.creat_netmiko_connection(username, password, device)
        mydb = sqlite3.connect("app/Modules/ProjectRouting/Database/Routing")
        cursor = mydb.cursor()
        db_obj = DB.RoutingDatabase(mydb, cursor)
        IOSXE.RoutingIos(routing_session, db_obj, mydb, cursor)

        return jsonify({'data': render_template('get_routing.html', route_table=Db_queries.view_routes_ios(cursor))})
Exemplo n.º 3
0
def get_routing():
    """Gets all things routing, arp, interfaces, routing protocols"""

    global get_interfaces, local_as, netconf_session, management_int, unassigned_ints, interface_nums

    netconf_session = ConnectWith.create_netconf_connection(username, password, device)
    get_interfaces = GetInterfacesInfo.get_ip_interfaces(netconf_session, device)
    management_int = get_interfaces[1]
    unassigned_ints = get_interfaces[2]
    interface_nums = get_interfaces[3]
    bgp_status = GetInfo.get_bgp_status(netmiko_session)
    local_as = bgp_status[1][0]
    ospf_status = GetInfo.get_ospf_status(netmiko_session)
    arp_table = GetInfo.get_arp(netmiko_session)

    return render_template('routing.html', interfaces=get_interfaces[0],
                           bgp=bgp_status[0], ospf=ospf_status, arp=arp_table, intial='yes')
Exemplo n.º 4
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)
        })