def clear_counters(netmiko_connection, interface, netconf_session): """Clears interface counters""" send_command(netmiko_connection, f"clear counters {interface}", expect_string="[confirm]") send_command(netmiko_connection, "\n", expect_string="#") refresh_interfaces = GetInterfacesInfo.get_ip_interfaces(netconf_session) return refresh_interfaces[0]
def submit_inteface(): """POST interface configuration from form data""" global unassigned_ints, interface_nums ip = None mask = None status = None descr = None vrf = None negotiation = None int_num = [ i for i in request.form.get("interface") if i not in string.ascii_letters ] int_type = [ i for i in request.form.get("interface") if i in string.ascii_letters ] interface = BuildInterface.Templates(''.join(int_type), ''.join(int_num)) if request.form.get('ip') and request.form.get('mask'): ip = request.form.get('ip') mask = request.form.get('mask') if request.form.get('status'): status = request.form.get('status') if request.form.get('description'): descr = request.form.get('description') if request.form.get('vrf'): vrf = request.form.get('vrf') if request.form.get('negotiation'): negotiation = request.form.get('negotiation') if request.form.get('vlan'): negotiation = request.form.get('negotiation') config = interface.build_interface(ip, mask, status, descr, vrf, negotiation) status = SendConfig.send_configuration(netconf_session, config) if status == 'Success': show_interfaces = GetInterfacesInfo.get_ip_interfaces(netconf_session) unassigned_ints = show_interfaces[2] interface_nums = show_interfaces[3] return jsonify({ 'data': render_template('interface_table.html', interfaces=show_interfaces[0]) }) else: return jsonify( {'data': render_template('config_failed.html', status=status)})
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')