Exemple #1
0
def getFlow(bridge):
    #if does not exist, cant get, so abort 404
    if len(str(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

    flow = sub_P01T2OpenvSwitch.get_flow(bridge)
    return jsonify({'Flow': flow.splitlines()})
Exemple #2
0
def updateFlowGroup(openflowversion, 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(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

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

    sub_P01T2OpenvSwitch.update_flowgroup(openflowversion, bridge, groupid,
                                          type1, action)
    return jsonify({
        'bridge': bridge,
        'groupid': groupid,
        'type': type1,
        'action': action
    })
Exemple #3
0
def getFlowGroup(openflowversion, bridge):
    #if does not exist, cant get, so abort 404
    if len(str(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

    flowgroup = sub_P01T2OpenvSwitch.get_flowgroup(openflowversion, bridge)
    return jsonify({'Flowgroup': flowgroup.splitlines()})
Exemple #4
0
def deleteAllFlow(bridge):
    #if bridge does not exist, cant delete, so abort 404
    if len(str(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_P01T2OpenvSwitch.delete_allflow(bridge)

    return jsonify({'result': True})
Exemple #5
0
def addFlowTablieFileToBridge(bridge, flowtablefile):
    ##if bridge does not exist, cant post, so abort 404
    if len(str(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

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

    sub_P01T2OpenvSwitch.apply_flowtablefile(bridge, flowtablefile)
    return jsonify({'bridge': bridge, 'flowtablefile': flowtablefile}), 201
Exemple #6
0
def deleteAllFlowGroup(openflowversion, bridge):
    #if does not exist, cant update, so abort 404
    if len(str(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_P01T2OpenvSwitch.delete_allflowgroup(openflowversion, bridge)

    if len(
            str(
                sub_P01T2OpenvSwitch.get_any_groupid_EH(
                    openflowversion, bridge))) != 0:
        abort(400)

    return jsonify({'result': True})
Exemple #7
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(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_P01T2OpenvSwitch.delete_specificflow(bridge, flow)
    return jsonify({'result': True})
Exemple #8
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(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

    sub_P01T2OpenvSwitch.update_allflow(bridge, flow)
    return jsonify({'bridge': bridge, 'flow': flow})
Exemple #9
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(sub_P01T2OpenvSwitch.get_flowtablefile_EH(ftFile))) == 0:
        abort(404)

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

    sub_P01T2OpenvSwitch.applyupdated_flowtablefile(bridge, ftFile)
    return jsonify({'bridge': bridge, 'flowtablefile': ftFile})
Exemple #10
0
def addFlowGroup(openflowversion, 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(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

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

    sub_P01T2OpenvSwitch.add_flowgroup(openflowversion, bridge, groupid, type1,
                                       action)

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

    return jsonify({
        'bridge': bridge,
        'groupid': groupid,
        'type': type1,
        'action': action
    }), 201
Exemple #11
0
def deleteSpecificFlowGroup(openflowversion, bridge, groupid):
    #if does not exist, cant update, so abort 404
    if len(str(sub_P01T2OpenvSwitch.get_bridge_EH(bridge))) == 0:
        abort(404)

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

    sub_P01T2OpenvSwitch.delete_specificflowgroup(openflowversion, bridge,
                                                  groupid)

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

    return jsonify({'result': True})