Example #1
0
def cluster_delete(ctx, cluster_name, vdc, org):
    """Delete an Ent-PKS cluster."""
    CLIENT_LOGGER.debug(f'Executing command: {ctx.command_path}')
    try:
        client_utils.cse_restore_session(ctx)
        client = ctx.obj['client']
        cluster = PksCluster(client)
        if not client.is_sysadmin() and org is None:
            org = ctx.obj['profiles'].get('org_in_use')
        result = cluster.delete_cluster(cluster_name, org, vdc)
        # result is empty for delete cluster operation on Ent-PKS clusters.
        # In that specific case, below check helps to print out a meaningful
        # message to users.
        if len(result) == 0:
            msg = f"Delete cluster operation has been initiated on " \
                  f"{cluster_name}, please check the status using" \
                  f" 'vcd cse pks-cluster info {cluster_name}'."
            click.secho(msg, fg='yellow')
            CLIENT_LOGGER.debug(msg)
        stdout(result, ctx)
        CLIENT_LOGGER.debug(result)
    except Exception as e:
        stderr(e, ctx)
        CLIENT_LOGGER.error(str(e))