예제 #1
0
    def start_cluster(self, profile, cluster_id, kernel_id):
        """Start cluster in a separate thread
        
        Args:
            profile (str): Databricks CLI profile string
            cluster_id (str): Cluster ID
            kernel_id (str): Internal jupyter kernel ID
        """
        global_status = KernelHandler.status

        if global_status.installing(profile, cluster_id):
            _logger.info("DbStartHandler cluster %s:%s already starting" %
                         (profile, cluster_id))
        else:
            _logger.info("DbStartHandler cluster %s:%s start triggered" %
                         (profile, cluster_id))
            global_status.set_installing(profile, cluster_id)

            host, token = get_db_config(profile)
            cluster_id, public_ip, cluster_name, dummy = get_cluster(
                profile, host, token, cluster_id, global_status)
            if cluster_name is None:
                global_status.set_status(profile, cluster_id,
                                         "ERROR: Cluster could not be found")
                return

            global_status.set_status(profile, cluster_id, "Configuring SSH")
            prepare_ssh_config(cluster_id, profile, public_ip)
            if not is_reachable(public_dns=public_ip):
                global_status.set_status(profile, cluster_id, "UNREACHABLE")
            else:
                global_status.set_status(profile, cluster_id,
                                         "Installing driver libs")
                result = install_libs(cluster_id, host, token)
                if result[0] == 0:
                    _logger.info("DbStartHandler: installations done")
                else:
                    _logger.error("DbStartHandler: installations failed")
                    global_status.set_status(profile, cluster_id, "ERROR")

                time.sleep(1)
                kernel = self.get_kernel(kernel_id)
                kernel.restart_kernel(now=True)
                global_status.set_status(profile, cluster_id, "Running")
            global_status.unset_installing(profile, cluster_id)
 def test_install_libs(self, name, cluster_id):
     result = install_libs(cluster_id, self.host, self.token)
     self.log.info("result: %s", result)