Esempio n. 1
0
def get_suciprofile(home_net_public_key_id: int):
    """
    get_suciprofile
    """
    channel = grpc.insecure_channel('localhost:50051')
    stub = SuciProfileDBStub(channel)
    response = stub.ListSuciProfile(Void())
    if not response.suci_profiles:
        print("SuciProfileList is empty")
    else:
        for x in response.suci_profiles:
            if home_net_public_key_id == x.home_net_public_key_id:
                return x.home_net_public_key
        return None
Esempio n. 2
0
    def setUp(self):
        # Create an in-memory store
        self._tmpfile = tempfile.TemporaryDirectory()
        store = SqliteStore(self._tmpfile.name + '/')

        # Bind the rpc server to a free port
        self._rpc_server = grpc.server(
            futures.ThreadPoolExecutor(max_workers=10), )
        port = self._rpc_server.add_insecure_port('0.0.0.0:0')

        suciprofile_db = {}
        # Add the servicer
        self._servicer = SuciProfileDBRpcServicer(
            store,
            suciprofile_db,
        )

        self._servicer.add_to_server(self._rpc_server)
        self._rpc_server.start()

        # Create a rpc stub
        channel = grpc.insecure_channel('0.0.0.0:{}'.format(port))
        self._stub = SuciProfileDBStub(channel)