Ejemplo n.º 1
0
def stopShell():
    shell_lock.acquire()
    try:
        te = sh.TableEntry('control_out_port.ipv4_check_checksum')(
            action='DoMirror')
        sh.TableEntry('control_out_port.ipv4_check_checksum').read(
            lambda t: t.delete())
        sh.teardown()
        print("disconnected")
    finally:
        shell_lock.release()
Ejemplo n.º 2
0
print("deleting entries from any previous run")


tables = sh.P4Objects(context.P4Type.table)
count = 0
for table in tables:
    for te in sh.TableEntry(table.name).read():
        count += 1
        te.delete()
print("Deleted %d entries" % count)


print("installing entries")
for i, entry in enumerate(entries):
    print("installing %d" % i)
    try:
        te = sh.TableEntry(entry["table"])(action=entry["action"])
        for key, val in entry["keys"].items():  te.match[key] = val
        for arg,val in entry["args"].items():   te.action[arg] = val
        priority = entry.get("priority", None)
        if priority != None: te.priority = priority
        te.insert()
    except Exception:
        print("ENTRY FAILED:\n", json.dumps(entry, indent=2), "\nEND FAILURE")
        raise Exception


sh.teardown()
print("Successful teardown!")
Ejemplo n.º 3
0
 def tearDown(self):
     sh.teardown()
     super().tearDown()