Ejemplo n.º 1
0
    def __init__(self, host=None, port=None, auth_token=None):
        """
        Creates a client to connect to PPS.

        host: The pachd host. Default is 'localhost', which is used with `pachctl port-forward`
        port: The port to connect to. Default is 30650
        auth_token: The authentication token; used if authentication is enabled on the cluster. Default to `None`.
        """

        address = get_address(host, port)
        self.metadata = get_metadata(auth_token)
        self.channel = grpc.grpc.insecure_channel(address)
        self.stub = grpc.APIStub(self.channel)
Ejemplo n.º 2
0
    def __init__(self, host=None, port=None, auth_token=None, root_certs=None):
        """
        Creates a client to connect to PPS.

        host: The pachd host. Default is 'localhost'.
        port: The port to connect to. Default is 30650.
        auth_token: The authentication token; used if authentication is
        enabled on the cluster. Default to `None`.
        root_certs:  The PEM-encoded root certificates as byte string.
        """

        address = get_address(host, port)
        self.metadata = get_metadata(auth_token)
        if root_certs:
            ssl_channel_credentials = grpc.grpc.ssl_channel_credentials
            ssl = ssl_channel_credentials(root_certificates=root_certs)
            self.channel = grpc.grpc.secure_channel(address, ssl)
        else:
            self.channel = grpc.grpc.insecure_channel(address)
        self.stub = grpc.APIStub(self.channel)