Beispiel #1
0
def modifity_2l(key1, key2, action):
    xml2("content/command/add.xml", key1, key2, action)
    if br_id_set() == "error":
        return "xml file error"
    global TEMPFILE, USERNAME, PASSWORD, ODL_HOST, BRIDGE_NAME
    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 ' + BRIDGE_NAME)
    result = flow._verification(xdict, ftable, count)
    return result
Beispiel #2
0
def active(act):
    global TEMPFILE, USERNAME, PASSWORD, ODL_HOST, BRIDGE_NAME
    if act == "True" or act == "true":
        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 ' + BRIDGE_NAME)
        result = flow._verification(xdict, ftable, count)
        return result

    elif act == "False" or act == "false":
        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 ' + BRIDGE_NAME)
        if ftable == "":
            return "correct"
        result = "correct" if flow._verification(xdict, ftable,
                                                 count) == "error" else "error"
        return result
    else:
        return "parameter error"