コード例 #1
0
ファイル: test_proxies.py プロジェクト: bgkyer/dask-gateway
async def cluster_and_security(tmpdir):
    tls_cert, tls_key = new_keypair("temp")
    tls_key_path = str(tmpdir.join("dask.pem"))
    tls_cert_path = str(tmpdir.join("dask.crt"))
    with open(tls_key_path, "wb") as f:
        f.write(tls_key)
    with open(tls_cert_path, "wb") as f:
        f.write(tls_cert)

    security = Security(
        tls_scheduler_key=tls_key_path,
        tls_scheduler_cert=tls_cert_path,
        tls_client_key=tls_key_path,
        tls_client_cert=tls_cert_path,
        tls_ca_file=tls_cert_path,
        require_encryption=True,
    )
    client_security = GatewaySecurity(tls_key.decode(), tls_cert.decode())

    cluster = None
    try:
        cluster = await LocalCluster(
            0,
            scheduler_port=0,
            silence_logs=False,
            dashboard_address=None,
            security=security,
            asynchronous=True,
        )
        yield cluster, client_security
    finally:
        if cluster is not None:
            await cluster.close()
コード例 #2
0
ファイル: utils.py プロジェクト: jhamman/dask-gateway
 def new_cluster(self):
     cluster_name = uuid.uuid4().hex
     cert, key = new_keypair(cluster_name)
     cluster = Cluster(
         name=cluster_name,
         user=User(name="alice"),
         token=uuid.uuid4().hex,
         tls_cert=cert,
         tls_key=key,
         state={},
         status=ClusterStatus.STARTING,
     )
     self.clusters[cluster_name] = cluster
     return cluster