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))})
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) })