Exemplo n.º 1
0
def no_active(act):
    global TEMPFILE, USERNAME, PASSWORD, ODL_HOST
    if act == "True":
        command = "curl -X POST -H \"Content-Type: application/xml\" -d @" + TEMPFILE + " --user " + USERNAME + ":" + PASSWORD + " http://" + ODL_HOST + ":8080/restconf/operations/sal-flow:remove-flow"
        os.system(command)

        xdict = flow._xml2dict(TEMPFILE)
        ftable, count = flow._flow_data('ovs-ofctl dump-flows my-br')
        if ftable == "":
            print "correct"
        fid = flow._flow_id(xdict, ftable, count)
        if fid == -1:
            print "correct"
        else:
            print "error"
    elif act == "False":
        command = "curl -X POST -H \"Content-Type: application/xml\" -d @" + TEMPFILE + " --user " + USERNAME + ":" + PASSWORD + " http://" + ODL_HOST + ":8080/restconf/operations/sal-flow:add-flow"
        os.system(command)

        xdict = flow._xml2dict(TEMPFILE)
        ftable, count = flow._flow_data('ovs-ofctl dump-flows my-br')
        fid = flow._flow_id(xdict, ftable, count)
        if fid == -1:
            print "error"
        result = flow._verification(xdict, ftable, fid)
        print result
    else:
        print("input error")
Exemplo n.º 2
0
def modifity(key, action):
    xml("add.xml", key, action)
    global TEMPFILE, USERNAME, PASSWORD, ODL_HOST
    command = "curl -X POST -H \"Content-Type: application/xml\" -d @" + TEMPFILE + " --user " + USERNAME + ":" + PASSWORD + " http://" + ODL_HOST + ":8080/restconf/operations/sal-flow:add-flow"
    os.system(command)

    xdict = flow._xml2dict(TEMPFILE)
    ftable, count = flow._flow_data('ovs-ofctl dump-flows my-br')
    result = flow._verification(xdict, ftable, count)
    print result
Exemplo n.º 3
0
def update(target, actuator, modifier):
    """
    parm URI is the location where POST Body file is stored
    parm URL is ODL IP
    """
    ##updateflow
    command = "curl -X POST -H \"Content-Type: application/xml\" -d @" + target[
        'URI'] + " --user admin:admin http://" + target[
            'URL'] + ":8080/restconf/operations/sal-flow:update-flow"
    os.popen(command).read()

    ##end
    ##verification
    xdict = flow._xml2dict(target['URI'])
    ftable, count = flow._flow_data('ovs-ofctl dump-flows s1')
    fid = flow._flow_id_u(xdict, ftable, count)
    if fid == -1:
        return "error"
    result = flow._verification_u(xdict, ftable, fid)
    return result