Exemplo n.º 1
0
def deleteBridge(bridge):
    #if does not exist, cant delete, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_remus.delete_bridge(bridge)

    if len(str(errorhandling_remus.get_bridge_EH(bridge))) != 0:
        abort(400)

    return jsonify({'result': True})
Exemplo n.º 2
0
def getBridge(bridge):
    #if does not exist, cant get, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    bridge = sub_remus.get_bridge(bridge)
    return jsonify({'Bridge': bridge.splitlines()})
Exemplo n.º 3
0
def updateFlowGroup(bridge, groupid):
    #if curl no -d, or -d not type/action, abort 400
    if not request.json or not 'type' in request.json or type(
            request.json['type']
    ) != unicode or not 'action' in request.json or type(
            request.json['action']) != unicode:
        abort(400)

    type1 = request.json['type']
    action = request.json['action']

    #if does not exist, cant update, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    #if does not exist, cant update, so abort 404
    if len(str(errorhandling_remus.get_groupid_EH(bridge, groupid))) == 0:
        abort(404)

    sub_remus.update_flowgroup(bridge, groupid, type1, action)
    return jsonify({
        'bridge': bridge,
        'groupid': groupid,
        'type': type1,
        'action': action
    })
Exemplo n.º 4
0
def getFlowGroup(bridge):
    #if does not exist, cant get, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    flowgroup = sub_remus.get_flowgroup(bridge)
    return jsonify({'Flowgroup': flowgroup.splitlines()})
Exemplo n.º 5
0
def addFlowGroup(bridge):
    #if curl no -d, or -d not groupid/type/action, abort 400
    if not request.json or not 'groupid' in request.json or type(
            request.json['groupid']
    ) != unicode or not 'type' in request.json or type(
            request.json['type']
    ) != unicode or not 'action' in request.json or type(
            request.json['action']) != unicode:
        abort(400)

    groupid = request.json['groupid']
    type1 = request.json['type']
    action = request.json['action']

    #if does not exist, cant post, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    #if exist, cant post, so abort 400
    if len(str(errorhandling_remus.get_groupid_EH(bridge, groupid))) != 0:
        abort(400)

    sub_remus.add_flowgroup(bridge, groupid, type1, action)

    #check if successfully created
    if len(str(errorhandling_remus.get_groupid_EH(bridge, groupid))) == 0:
        abort(400)

    return jsonify({
        'bridge': bridge,
        'groupid': groupid,
        'type': type1,
        'action': action
    }), 201
Exemplo n.º 6
0
def deleteAllFlow(bridge):
    #if bridge does not exist, cant delete, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_remus.delete_allflow(bridge)

    return jsonify({'result': True})
Exemplo n.º 7
0
def addBridge():
    #if curl no -d, or -d not bridge, abort 400
    if not request.json or not 'bridge' in request.json or type(
            request.json['bridge']) != unicode:
        abort(400)

    bridge = request.json['bridge']

    #if already exist, cant post, so abort 400
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) != 0:
        abort(400)

    sub_remus.add_bridge(bridge)

    #check if added successfully
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(400)

    return jsonify({'bridge': bridge}), 201
Exemplo n.º 8
0
def deleteAllFlowGroup(bridge):
    #if does not exist, cant update, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_remus.delete_allflowgroup(bridge)

    if len(str(errorhandling_remus.get_any_groupid_EH(bridge))) != 0:
        abort(400)

    return jsonify({'result': True})
Exemplo n.º 9
0
def addFlowTablieFileToBridge(bridge, flowtablefile):
    ##if bridge does not exist, cant post, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    #if flowtablefile does not exist, cant apply, so abort 404
    if len(str(errorhandling_remus.get_flowtablefile_EH(flowtablefile))) == 0:
        abort(404)

    sub_remus.apply_flowtablefile(bridge, flowtablefile)
    return jsonify({'bridge': bridge, 'flowtablefile': flowtablefile}), 201
Exemplo n.º 10
0
def deleteSpecificFlow(bridge):
    #if curl no -d, or -d not flow, abort 400
    if not request.json or not 'flow' in request.json or type(
            request.json['flow']) != unicode:
        abort(400)

    flow = request.json['flow']

    #if bridge does not exist, cant delete, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_remus.delete_specificflow(bridge, flow)
    return jsonify({'result': True})
Exemplo n.º 11
0
def updateAllFlow(bridge):
    #if curl no -d, or -d not flow, abort 400
    if not request.json or not 'flow' in request.json or type(
            request.json['flow']) != unicode:
        abort(400)

    flow = request.json['flow']

    #if bridge does not exist, cant delete, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_remus.update_allflow(bridge, flow)
    return jsonify({'bridge': bridge, 'flow': flow})
Exemplo n.º 12
0
def updateBridge(bridge):
    #if curl no -d, or -d not options, abort 400
    if not request.json or not 'options' in request.json or type(
            request.json['options']) != unicode:
        abort(400)

    options = request.json['options']

    #if does not exist, cant update, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_remus.update_bridge(bridge, options)

    return jsonify({'bridge': bridge, 'options': options})
Exemplo n.º 13
0
def deleteSpecificFlowGroup(bridge, groupid):
    #if does not exist, cant update, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    #if does not exist, cant update, so abort 404
    if len(str(errorhandling_remus.get_groupid_EH(bridge, groupid))) == 0:
        abort(404)

    sub_remus.delete_specificflowgroup(bridge, groupid)

    #check if successfully deleted
    if len(str(errorhandling_remus.get_groupid_EH(bridge, groupid))) != 0:
        abort(400)

    return jsonify({'result': True})
Exemplo n.º 14
0
def applyUpdatedFlowTableFile(bridge):
    #if curl no -d, or -d not flowtablefile, abort 400
    if not request.json or not 'flowtablefile' in request.json or type(
            request.json['flowtablefile']) != unicode:
        abort(400)

    ftFile = request.json['flowtablefile']

    #if flowtablefile does not exist, cant apply, so abort 404
    if len(str(errorhandling_remus.get_flowtablefile_EH(ftFile))) == 0:
        abort(404)

    ##if bridge does not exist, cant post, so abort 404
    if len(str(errorhandling_remus.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_remus.applyupdated_flowtablefile(bridge, ftFile)
    return jsonify({'bridge': bridge, 'flowtablefile': ftFile})