def modify_inteface(interface): """Renders and build configurations for interface modification""" if not request.form: current_config = GetNetmiko.current_int_config( netmiko_session, interface.replace('%2f', '/')) return render_template('modify_interface.html', interface=interface.replace('%2f', '/'), vrfs=QueryDbFor.query_vrfs(device), current_config=current_config, mgmt_int=[ i for i in QueryDbFor.query_interfaces(device) if i.id == device ], model=model[:3][-2:]) else: status = BuildConfig.parse_int_form(request.form, device, password, username) current_config = GetNetmiko.current_int_config( netmiko_session, interface.replace('%2f', '/')) return render_template('modify_interface.html', interface=interface.replace('%2f', '/'), vrfs=QueryDbFor.query_vrfs(device), mgmt_int=[ i for i in QueryDbFor.query_interfaces(device) if i.id == device ], current_config=current_config, model=model[:3][-2:], status=status)
def add_poch(): """Renders vlan configuration form""" # Remove duplicate channel-group numbers for html dropdown groups = [i.group for i in QueryDbFor.query_port_channels(device)] if not request.form: return render_template( 'add_poch.html', interfaces=QueryDbFor.query_interfaces(device), port_channels=list(dict.fromkeys(groups)), int_status=QueryDbFor.query_access_ports(device)) else: channel_mode = [ i.mode for i in QueryDbFor.query_port_channels(device) if request.form.get('pochannel') == i.group ] status = BuildConfig.parse_poch_interface( request.form, list(dict.fromkeys(channel_mode)), device, password, username) current_config = GetNetmiko.current_int_config( netmiko_session, request.form.get('interface')) return render_template( 'add_poch.html', interfaces=QueryDbFor.query_interfaces(device), port_channels=groups, int_status=QueryDbFor.query_access_ports(device), current_config=current_config, status=status)
def modify_trunk_interface(interface): """Render trunk modification page""" if not request.form: current_config = GetNetmiko.current_int_config( netmiko_session, interface.replace('%2f', '/')) return render_template('modify_trunk_int.html', interface=interface.replace('%2f', '/'), current_config=current_config, vlans=QueryDbFor.query_vlans(device)) else: status = BuildConfig.parse_trunk_interface(request.form, device, password, username) current_config = GetNetmiko.current_int_config( netmiko_session, interface.replace('%2f', '/')) return render_template('modify_trunk_int.html', interface=interface.replace('%2f', '/'), current_config=current_config, vlans=QueryDbFor.query_vlans(device), status=status)
def modify_access_interface(interface): """POST BGP configuration from form data""" if not request.form: current_config = GetNetmiko.current_int_config( netmiko_session, interface.replace('%2f', '/')) return render_template('modify_access_int.html', interface=interface.replace('%2f', '/'), current_config=current_config, vlans=QueryDbFor.query_vlans(device)) else: status = BuildConfig.parse_access_int_form(request.form, device, password, username) current_config = GetNetmiko.current_int_config( netmiko_session, interface.replace('%2f', '/')) return render_template('modify_access_int.html', interface=interface.replace('%2f', '/'), current_config=current_config, vlans=QueryDbFor.query_vlans(device), status=status)
def new_dmvpn_interface(): """POST new interface""" if not request.form: return render_template('new_dmvpn_int.html', vrfs=QueryDbFor.query_vrfs(device)) else: status = BuildConfig.parse_int_form(request.form, device, password, username) interface = request.form.get('newIntCustomForm').splitlines() current_config = GetNetmiko.current_int_config(netmiko_session, interface[0].split()[1]) return render_template('new_dmvpn_int.html')