Delete a Kubernetes cluster.
490368
def delete(self, name, provider='AwsEKS'):
        
        # if self.check_cluster_exists(name) is False:
        #     raise JhubctlError("Cluster name not found in availabe clusters.")

        # Create cluster object
        Cluster = getattr(providers, provider)
        cluster = Cluster(name)
        cluster.delete()

        # Remove from kubeconf
        self.kubeconf.open()
        self.kubeconf.remove_context(name)
        self.kubeconf.remove_user(name)
        self.kubeconf.remove_cluster(cluster.cluster_name)
        self.kubeconf.close()
1151580
async def delete(self):
        """"""
        await self._handler.delete(
            system_id=self.block_device.node.system_id,
            device_id=self.block_device.id, id=self.id)
1058050
def destroy(self):
        

        subnets = (
            str(net.gw()) for net in self.virt_env.get_nets().itervalues()
        )

        self._subnet_store.release(subnets)
        self.cleanup()
        shutil.rmtree(self.paths.prefix_path())
278022
def destroyCluster(self):
        
        logger.debug("Destroying cluster %s" % self.clusterName)
        instancesToTerminate = self._getNodesInCluster()
        attempts = 0
        while instancesToTerminate and attempts < 3:
            self._terminateInstances(instances=instancesToTerminate)
            instancesToTerminate = self._getNodesInCluster()
            attempts += 1

        # remove group
        instanceGroup = self._gceDriver.ex_get_instancegroup(self.clusterName, zone=self._zone)
        instanceGroup.destroy()
237753
private void handleDelete() {
    log.debug(String.format("%s - Network configuration removed from cluster: %s", NetworkManager.this, cluster.address()));
    tasks.runTask(new Handler<Task>() {
      @Override
      public void handle(final Task task) {
        unready(new Handler<AsyncResult<Void>>() {
          @Override
          public void handle(AsyncResult<Void> result) {
            if (result.failed()) {
              log.error(result.cause());
            }
            if (currentContext != null) {
              log.info(String.format("%s - Undeploying network", NetworkManager.this));
              undeployNetwork(currentContext, new Handler<AsyncResult<Void>>() {
                @Override
                public void handle(AsyncResult<Void> result) {
                  if (result.failed()) {
                    log.error(result.cause());
                    task.complete();
                  } else {
                    // Once we've finished undeploying all the components of the
                    // network, set the network's status to nothing in order to
                    // indicate that the manager (this) can be undeployed.
                    data.put(currentContext.status(), "", new Handler<AsyncResult<String>>() {
                      @Override
                      public void handle(AsyncResult<String> result) {
                        if (result.failed()) {
                          log.error(result.cause());
                        } else {
                          log.info(String.format("%s - Successfully undeployed all components", NetworkManager.this));
                        }
                        task.complete();
                      }
                    });
                  }
                }
              });
            } else {
              task.complete();
            }
          }
        });
      }
    });
  }
105767
@Override
    public void destroy()
    {
        if (indexManager != null)
        {
            indexManager.close();
        }
        if (schemaManager != null)
        {
            schemaManager.dropSchema();
        }
        schemaManager = null;
        externalProperties = null;

        for (Object connectionPool : hostPools.values())
        {
            if (connectionPool != null && connectionPool.getClass().isAssignableFrom(ConnectionPool.class))
            {
                ((ConnectionPool) connectionPool).close(true);
            }
        }
        ((CassandraRetryService) hostRetryService).shutdown();
    }
848258
def member_del(self, cluster_id, member_id):
        """"""
        cluster = self._storage[cluster_id]
        result = cluster.member_remove(member_id)
        self._storage[cluster_id] = cluster
        return result
1227762
def delete(cls, cluster_id_label):
        
        conn = Qubole.agent(version=Cluster.api_version)
        return conn.delete(cls.element_path(cluster_id_label))
177326
def _disconnect(self):
        """"""
        for cluster in self._clusters:
            if 'connection' in cluster:
                connection = cluster.pop('connection')
                connection.close()
        # Remove all attributes that are database names so that next time
        # when they are accessed, __getattr__ will be called and will create
        # new Clients
        for dbname in self._mapped_databases:
            self.__delattr__(dbname)
        self._mapped_databases = []
296628
def cleanup_pods(self):
        
        pods = self.list_pods()

        for pod in pods:
            if pod.namespace in self.managed_namespaces:
                pod.delete()
700202
def delete(self, hdfs_path, recursive=False):
        """"""
        return self.client.delete(hdfs_path, recursive=recursive)
980878
def destroy(name, conn=None, call=None, kwargs=None):
    '''
    
    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The destroy action must be called with -d, --destroy, '
            '-a or --action.'
        )

    if not conn:
        conn = get_conn()

    if kwargs is None:
        kwargs = {}

    instance_data = show_instance(name, call='action')
    service_name = instance_data['deployment']['name']
    disk_name = instance_data['role_info']['os_virtual_hard_disk']['disk_name']

    ret = {}
    # TODO: Add the ability to delete or not delete a hosted service when
    # deleting a VM
    try:
        log.debug('Deleting role')
        result = conn.delete_role(service_name, service_name, name)
        delete_type = 'delete_role'
    except AzureException:
        log.debug('Failed to delete role, deleting deployment')
        try:
            result = conn.delete_deployment(service_name, service_name)
        except AzureConflictHttpError as exc:
            log.error(exc.message)
            raise SaltCloudSystemExit('{0}: {1}'.format(name, exc.message))
        delete_type = 'delete_deployment'
    _wait_for_async(conn, result.request_id)
    ret[name] = {
        delete_type: {'request_id': result.request_id},
    }
    if __opts__.get('update_cachedir', False) is True:
        __utils__['cloud.delete_minion_cachedir'](name, __active_provider_name__.split(':')[0], __opts__)

    cleanup_disks = config.get_cloud_config_value(
        'cleanup_disks',
        get_configured_provider(), __opts__, search_global=False, default=False,
    )
    if cleanup_disks:
        cleanup_vhds = kwargs.get('delete_vhd', config.get_cloud_config_value(
            'cleanup_vhds',
            get_configured_provider(), __opts__, search_global=False, default=False,
        ))
        log.debug('Deleting disk %s', disk_name)
        if cleanup_vhds:
            log.debug('Deleting vhd')

        def wait_for_destroy():
            '''
            Wait for the VM to be deleted
            '''
            try:
                data = delete_disk(kwargs={'name': disk_name, 'delete_vhd': cleanup_vhds}, call='function')
                return data
            except AzureConflictHttpError:
                log.debug('Waiting for VM to be destroyed...')
            time.sleep(5)
            return False

        data = salt.utils.cloud.wait_for_fun(
            wait_for_destroy,
            timeout=config.get_cloud_config_value(
                'wait_for_fun_timeout', {}, __opts__, default=15 * 60),
        )
        ret[name]['delete_disk'] = {
            'name': disk_name,
            'delete_vhd': cleanup_vhds,
            'data': data
        }

        # Services can't be cleaned up unless disks are too
        cleanup_services = config.get_cloud_config_value(
            'cleanup_services',
            get_configured_provider(), __opts__, search_global=False, default=False
        )
        if cleanup_services:
            log.debug('Deleting service %s', service_name)

            def wait_for_disk_delete():
                '''
                Wait for the disk to be deleted
                '''
                try:
                    data = delete_service(kwargs={'name': service_name}, call='function')
                    return data
                except AzureConflictHttpError:
                    log.debug('Waiting for disk to be deleted...')
                time.sleep(5)
                return False

            data = salt.utils.cloud.wait_for_fun(
                wait_for_disk_delete,
                timeout=config.get_cloud_config_value(
                    'wait_for_fun_timeout', {}, __opts__, default=15 * 60),
            )
            ret[name]['delete_services'] = {
                'name': service_name,
                'data': data
            }

    return ret
1098758
def delete(self):
        """"""
        pipeline = self.db.pipeline()
        self._delete_from_indices(pipeline)
        self._delete_membership(pipeline)
        pipeline.delete(self.key())
        pipeline.execute()
543976
def delete_deployment(name, namespace='default', **kwargs):
    '''
    
    '''
    cfg = _setup_conn(**kwargs)
    body = kubernetes.client.V1DeleteOptions(orphan_dependents=True)

    try:
        api_instance = kubernetes.client.ExtensionsV1beta1Api()
        api_response = api_instance.delete_namespaced_deployment(
            name=name,
            namespace=namespace,
            body=body)
        mutable_api_response = api_response.to_dict()
        if not salt.utils.platform.is_windows():
            try:
                with _time_limit(POLLING_TIME_LIMIT):
                    while show_deployment(name, namespace) is not None:
                        sleep(1)
                    else:  # pylint: disable=useless-else-on-loop
                        mutable_api_response['code'] = 200
            except TimeoutError:
                pass
        else:
            # Windows has not signal.alarm implementation, so we are just falling
            # back to loop-counting.
            for i in range(60):
                if show_deployment(name, namespace) is None:
                    mutable_api_response['code'] = 200
                    break
                else:
                    sleep(1)
        if mutable_api_response['code'] != 200:
            log.warning('Reached polling time limit. Deployment is not yet '
                        'deleted, but we are backing off. Sorry, but you\'ll '
                        'have to check manually.')
        return mutable_api_response
    except (ApiException, HTTPError) as exc:
        if isinstance(exc, ApiException) and exc.status == 404:
            return None
        else:
            log.exception(
                'Exception when calling '
                'ExtensionsV1beta1Api->delete_namespaced_deployment'
            )
            raise CommandExecutionError(exc)
    finally:
        _cleanup(**cfg)
1074457
def destroy(self):
        """"""
        self._refresh_connection()

        self.push_queue = []
        index_name = self.document_class()._get_index()  # pylint: disable=protected-access
        connections.get_connection().indices.delete(index_name, ignore=404)

        self._mapping_created = False
311092
def remove(self):
        
        LOGGER.debug("Cluster.remove - " + self.name)
        if self.id is None:
            return None
        else:
            params = SessionService.complete_transactional_req({
                'name': self.name
            })

            if MappingService.driver_type != DriverFactory.DRIVER_REST:
                params['OPERATION'] = 'deleteCluster'
                args = {'properties': params}
            else:
                args = {'http_operation': 'GET', 'operation_path': 'delete', 'parameters': params}

            response = ClusterService.requester.call(args)

            if MappingService.driver_type != DriverFactory.DRIVER_REST:
                response = response.get()

            if response.rc != 0:
                LOGGER.warning(
                    'Cluster.remove - Problem while deleting cluster ' + self.name +
                    '. Reason: ' + str(response.response_content) + ' - ' + str(response.error_message) +
                    " (" + str(response.rc) + ")"
                )
                if response.rc == 500 and ArianeMappingOverloadError.ERROR_MSG in response.error_message:
                    raise ArianeMappingOverloadError("Cluster.remove", ArianeMappingOverloadError.ERROR_MSG)
                # traceback.print_stack()
                return self
            else:
                return None
985223
def cleanup(api_instance=None):
    
    api = api_instance or get_api()
    r = api.list_job_for_all_namespaces()
    delete_opts = kubernetes.client.V1DeleteOptions(
            propagation_policy="Background")
    for job in r.items:
        if job.status.succeeded == job.spec.completions:
            print(job.metadata.name, "finished!")
            api.delete_namespaced_job(
                job.metadata.name, 'default', body=delete_opts)