Example #1
0
    def setUp(self):
        BaseTest.setUp(self)
        self.device_id = 0

        # Setting up PTF dataplane
        self.dataplane = ptf.dataplane_instance
        self.dataplane.flush()

        self._swports = []
        for device, port, ifname in config["interfaces"]:
            self._swports.append(port)

        grpc_addr = testutils.test_param_get("grpcaddr")
        if grpc_addr is None:
            grpc_addr = 'localhost:50051'

        self.channel = grpc.insecure_channel(grpc_addr)
        self.stub = p4runtime_pb2.P4RuntimeStub(self.channel)

        proto_txt_path = testutils.test_param_get("p4info")
        print "Importing p4info proto from", proto_txt_path
        self.p4info = p4info_pb2.P4Info()
        with open(proto_txt_path, "rb") as fin:
            google.protobuf.text_format.Merge(fin.read(), self.p4info)

        # used to store write requests sent to the P4Runtime server, useful for
        # autocleanup of tests (see definition of autocleanup decorator below)
        self._reqs = []

        self.set_up_stream()
Example #2
0
 def __init__(self, p4_info_filepath):
     p4info = p4info_pb2.P4Info()
     print p4info
     # Load the p4info file into a skeleton P4Info object
     with open(p4_info_filepath) as p4info_f:
         google.protobuf.text_format.Merge(p4info_f.read(), p4info)
     self.p4info = p4info
Example #3
0
from p4.config import p4info_pb2
import google.protobuf.text_format

p4info = p4info_pb2.P4Info()
p4info_loc = "/home/ben/p4/tiered/p4src/tiered.p4info"
with open(p4info_loc) as p4info_file:
    google.protobuf.text_format.Merge(p4info_file.read(), p4info)
    p4info_file.close()

print p4info