Exemple #1
0
    def setUp(self):
        super().setUp()
        self.device_id = 0
        self.election_id = (0, 1)

        self.servicer = P4RuntimeServicer()
        self.servicer.Write = Mock(spec=[], return_value=p4runtime_pb2.WriteResponse())
        self.servicer.Read = Mock(spec=[], return_value=p4runtime_pb2.ReadResponse())
        p4runtime_pb2_grpc.add_P4RuntimeServicer_to_server(self.servicer, self.server)

        sh.setup(device_id=self.device_id,
                 grpc_addr=self.grpc_addr,
                 election_id=self.election_id,
                 config=sh.FwdPipeConfig(self._p4info_path, self._config_path))
Exemple #2
0
    def setUp(self):
        super().setUp()
        self.device_id = 0
        self.election_id = (0, 1)

        self.servicer = P4RuntimeServicer()
        self.servicer.Write = Mock(spec=[], return_value=p4runtime_pb2.WriteResponse())
        self.servicer.Read = Mock(spec=[], return_value=p4runtime_pb2.ReadResponse())
        # Starting with gRPC 1.20.0, the server code checks for the presence of an
        # experimental_non_blocking
        # (https://github.com/grpc/grpc/blob/v1.20.0/src/python/grpcio/grpc/_server.py#L532). We
        # need to make sure it is *not* present with spec=[].
        self.servicer.StreamChannel = Mock(spec=[])
        p4runtime_pb2_grpc.add_P4RuntimeServicer_to_server(self.servicer, self.server)
Exemple #3
0
 def setUp(self):
     super().setUp()
     self.servicer = P4RuntimeServicer()
     p4runtime_pb2_grpc.add_P4RuntimeServicer_to_server(
         self.servicer, self.server)
Exemple #4
0
if __name__ == "__main__":
    signal.signal(signal.SIGINT, close_sig)

    LOG_F = ServerLog.open_log('logs/pvs_log')

    LoadVSwitch.load_switches()

    Auth.loadDbMemory()
    SwitchConf.loadDbMemory()

    #Plugins
    VerifyEvent.init_vifc()

    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    p4runtime_instance = P4Runtime()
    p4runtime_pb2_grpc.add_P4RuntimeServicer_to_server(p4runtime_instance,
                                                       server)

    with open(ServerConfig.SERVER_KEY, "rb") as file:
        private_key = file.read()
    with open(ServerConfig.SERVER_CERTIFICATE, "rb") as file:
        certificate_chain = file.read()

    server_credentials = grpc.ssl_server_credentials(((
        private_key,
        certificate_chain,
    ), ))
    # server.add_insecure_port('localhost:50052')
    server.add_secure_port("[::]:{}".format(p4runtime_instance.server_port),
                           server_credentials)
    server.start()
    print "PvS P4Runtime server running @ grpcs://{}:{}".format(