def post_neighbor(): """Submit BGP for configuration""" build_neighbors = Build_bgp_config.Templates(request.form.get("localAs")) bgp_config = build_neighbors.build_neighbor( request.form.get("neighborId"), request.form.get("remoteAs"), model, policy=[ request.form.get("softReconfig"), request.form.get("direction"), request.form.get("policy"), request.form.get("nextHop") ]) status = SendConfig.send_configuration(netconf_session, bgp_config) if status == 'Success': get_status = GetInfo.get_bgp_status(netmiko_session) return jsonify({ 'data': render_template('bgp_neighbor_table.html', bgp=get_status[0]) }) else: return jsonify( {'data': render_template('config_failed.html', status=status)})
def apply_qos(): """POST QOS configuration from form data""" find_int_num = [ i for i in request.form.get("interface") if i not in string.ascii_letters ] find_int_type = [ i for i in request.form.get("interface") if i in string.ascii_letters ] build_config = BuildService.build_policy(''.join(find_int_type), ''.join(find_int_num), request.form.get("direction"), request.form.get("servicePolicy")) status = SendConfig.send_configuration(netconf_session, build_config) if status == 'Success': interface_qos = GetQos.get_interfaces(netconf_session) return jsonify({ 'data': render_template('qos_table.html', interface_qos=interface_qos) }) else: return jsonify( {'data': render_template('config_failed.html', status=status)})
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 post_ospf_neighbor(): """POST OSPF configuration from form data""" build_neighbors = Build_ospf_config.Templates(request.form.get("process")) ospf_config = build_neighbors.build_neighbor(request.form.get("neighbor"), request.form.get("wildcard"), request.form.get("area")) status = SendConfig.send_configuration(netconf_session, ospf_config) if status == 'Success': get_status = GetInfo.get_ospf_status(netmiko_session) return jsonify({'data': render_template('ospf_neighbor_table.html', ospf=get_status)}) else: return jsonify({'data': render_template('config_failed.html', status=status)})