Ejemplo n.º 1
0
def modify_inteface(interface):
    """POST BGP configuration from form data"""

    reformat_interface = interface.replace('%2f', '/')
    vrfs = GetInfo.get_vrfs(netmiko_session)
    mac = GetInterfacesInfo.get_single_interfaces(netconf_session,
                                                  reformat_interface)

    return render_template('modify_interface.html',
                           interface=reformat_interface,
                           vrfs=vrfs,
                           mgmt_int=management_int,
                           mac=mac[0].get(reformat_interface).get('MAC'))
Ejemplo n.º 2
0
def submit_new_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')

    config = interface.build_interface(ip, mask, status, descr, vrf,
                                       negotiation)
    status = SendConfig.send_configuration(netconf_session, config)

    if status == 'Success':
        show_interfaces = GetInterfacesInfo.get_single_interfaces(
            netconf_session, request.form.get("interface"))
        return jsonify({
            'data':
            render_template('new_interface_table.html',
                            interfaces=show_interfaces)
        })
    else:
        return jsonify(
            {'data': render_template('config_failed.html', status=status)})