def configure_access_port_option_check():
    switch = session.get('switch')
    options = connection_functions.ConnectionMethods()
    interface = request.form.get('interface_select')
    port_type = request.form.get('port_type')
    access_vlan = request.form.get('access_select')
    voice_vlan = request.form.get('voice_select', None)
    description = request.form.get('interface_description')
    session['interface'] = interface
    device = options.base_settings(switch)
    neighbor_check = options.check_cdp_neighbor(switch, device, interface)

    if neighbor_check:
        for neighbor in neighbor_check:
            flash('{} was detected on port {}. Select a different port'.format(
                neighbor, interface))
        return redirect(url_for('index'))

    else:

        config = render_template('access_port.j2',
                                 interface=interface,
                                 access_vlan=access_vlan,
                                 voice_vlan=voice_vlan,
                                 description=description,
                                 port_type=port_type)
        options.push_configuration(device, interface, config)
        running_config = options.get_port_configuration(device, interface)
        return render_template('running_config.html',
                               template_config=running_config,
                               running_interface=interface)
Exemple #2
0
def dev_select():
    session.clear()
    options = connection_functions.ConnectionMethods()
    switches = options.get_l2_devices()

    return render_template('switches.html',
                           template_switches=switches,
                           url=url_for('interface_select.interface_select'))
def clear_sticky_mac_select():  # Presents a dropdown of devices
    options = connection_functions.ConnectionMethods()
    switches = options.get_l2_devices()

    return render_template(
        'switches.html',
        template_switches=switches,
        url=url_for(
            'clear_sticky_mac_option_select.clear_sticky_mac_option_select'))
Exemple #4
0
def show_running():
    interface = request.form.get('Interface')
    switch = session.get('switch')
    options = connection_functions.ConnectionMethods()
    device = options.base_settings(switch)
    running_config = options.get_port_configuration(device, interface)

    return render_template('running_config.html',
                           template_config=running_config,
                           running_interface=interface)
def configure_access_port_select():
    session.clear()
    options = connection_functions.ConnectionMethods()
    switches = options.get_l2_devices()

    return render_template(
        'switches.html',
        template_switches=switches,
        url=url_for(
            'configure_access_port_option_select.configure_access_port_option_select'
        ))
Exemple #6
0
def interface_select():
    switch = request.form.get('Switch')
    options = connection_functions.ConnectionMethods()
    device = options.base_settings(switch)
    session['switch'] = switch
    all_interfaces, failed = options.get_interfaces(device, switch)
    if failed:
        flash('Connection attempt to {} failed, try again'.format(switch))
        return redirect(url_for('index'))

    else:
        return render_template('interfaces.html',
                               template_interfaces=all_interfaces,
                               url=url_for('interface_show_run.show_running'))
def clear_sticky_mac_option_select(
):  # Presents options for user to choose from
    switch = request.form.get('Switch')
    options = connection_functions.ConnectionMethods()
    device = options.base_settings(switch)
    session['switch'] = switch
    all_interfaces, failed = options.get_interfaces(device, switch)
    if failed:
        flash('Connection attempt to {} failed, try again'.format(switch))
        return redirect(url_for('index'))
    else:
        return render_template(
            'clear_sticky_template.html',
            url=url_for('clear_sticky_mac_complete.clear_sticky_mac_complete'),
            template_interfaces=all_interfaces)
def configure_access_port_option_select():
    switch = request.form.get('Switch')
    options = connection_functions.ConnectionMethods()
    device = options.base_settings(switch)
    session['switch'] = switch
    all_interfaces, failed = options.get_interfaces(device, switch)
    if failed:
        flash('Connection attempt to {} failed, try again'.format(switch))
        return redirect(url_for('index'))
    else:
        session['vlans'] = options.get_vlans(switch, device)
        return render_template(
            'access_port_template.html',
            url=url_for(
                'configure_access_port_option_check.configure_access_port_option_check'
            ),
            template_interfaces=all_interfaces,
            vlans=session.get('vlans'))
Exemple #9
0
def show_arp_result(
):  # Attempt to validate entered address then resolve the ARP mapping
    options = connection_functions.ConnectionMethods()

    l3_device = request.form.get('device_select')
    address = request.form.get('address_input')

    validate_mac = options.validate_format_mac(address)
    if not validate_mac:
        validate_ip = options.validate_ip_address(address)
        if not validate_ip:
            flash('Invalid input, try again')
            return redirect(url_for('show_arp_select.show_arp_select'))

    device = options.base_settings(l3_device)
    ip_mac_mapping = options.check_arp(device, l3_device, address)
    flash(ip_mac_mapping)
    return redirect(url_for('index'))
def clear_sticky_mac_complete():  # Attempts to clear a sticky MAC or interface
    switch = session.get('switch')
    options = connection_functions.ConnectionMethods()
    device = options.base_settings(switch)
    clear_type = request.form.get('clear_type')
    if clear_type == 'clear_sticky':
        validate_mac = options.validate_format_mac(
            request.form.get('sticky_mac_address'))
        if not validate_mac:
            flash('Invalid input, try again')
            return redirect(
                url_for('clear_sticky_mac_select.clear_sticky_mac_select'))
        options.clear_sticky_mac(device, validate_mac)
        flash('MAC address {} as been cleared'.format(
            request.form.get('sticky_mac_address')))
        return redirect(url_for('index'))
    elif clear_type == 'clear_interface':
        options.clear_sticky_interface(device,
                                       request.form.get('interface_select'))
        flash('Interface {} sticky MAC addresses have been cleared'.format(
            request.form.get('interface_select')))
        return redirect(url_for('index'))
Exemple #11
0
def show_arp_select():
    options = connection_functions.ConnectionMethods()
    l3_devices = options.get_arp_devices()
    return render_template('check_arp.html',
                           url=url_for('show_arp_result.show_arp_result'),
                           devices=l3_devices)