Ejemplo n.º 1
0
def get_cluster_state(profile, cluster_id):
    """Get cluster state
    
    Args:
        profile (str): Databricks CLI profile string
        cluster_id (str): Cluster ID
    
    Returns:
        dict: ClusterStatus
    """
    apiclient = connect(profile)
    try:
        client = ClusterApi(apiclient)
        cluster = client.get_cluster(cluster_id)
        state = cluster.get("state", None)
    except:
        _logger.warning("DbStatusHandler cluster not reachable")
        state = "TERMINATED"
    # if state == "TERMINATED":
    #     _logger.warning("DbStatusHandler cluster state = %s" % state)
    # else:
    #     _logger.info("DbStatusHandler cluster state = %s" % state)

    return state
Ejemplo n.º 2
0
import sys

from databricks_cli.secrets.api import SecretApi

from databrickslabs_jupyterlab.remote import connect

from helpers import get_profile

profile = get_profile()

try:
    apiclient = connect(profile)
    client = SecretApi(apiclient)
except Exception as ex:  # pylint: disable=broad-except
    print(ex)
    sys.exit(1)

client.create_scope("dbjl-pytest", None)
client.put_secret("dbjl-pytest", "pytest-key", "databrickslabs-jupyterlab", None)