def run()

in curator/cli.py [0:0]


def run(ctx: click.Context) -> None:
    """
    :param ctx: The Click command context

    :type ctx: :py:class:`Context <click.Context>`

    Called by :py:func:`cli` to execute what was collected at the command-line
    """
    logger = logging.getLogger(__name__)
    logger.debug('action_file: %s', ctx.params['action_file'])
    all_actions = ActionsFile(ctx.params['action_file'])
    for idx in sorted(list(all_actions.actions.keys())):
        action_def = all_actions.actions[idx]
        # Skip to next action if 'disabled'
        if action_def.disabled:
            logger.info(
                'Action ID: %s: "%s" not performed because "disable_action" '
                'is set to True',
                idx,
                action_def.action,
            )
            continue
        logger.info('Preparing Action ID: %s, "%s"', idx, action_def.action)

        # Override the timeout, if specified, otherwise use the default.
        if action_def.timeout_override:
            ctx.obj['configdict']['elasticsearch']['client'][
                'request_timeout'
            ] = action_def.timeout_override

        # Create a client object for each action...
        logger.info('Creating client object and testing connection')

        try:
            client = get_client(
                configdict=ctx.obj['configdict'],
                version_max=VERSION_MAX,
                version_min=VERSION_MIN,
            )
        except ClientException as exc:
            # No matter where logging is set to go, make sure we dump these messages to
            # the CLI
            click.echo('Unable to establish client connection to Elasticsearch!')
            click.echo(f'Exception: {exc}')
            sys.exit(1)
        except Exception as other:
            logger.debug('Fatal exception encountered: %s', other)

        # Filter ILM indices unless expressly permitted
        if ilm_action_skip(client, action_def):
            continue
        #
        # Process the action
        #
        msg = (
            f'Trying Action ID: {idx}, "{action_def.action}": {action_def.description}'
        )
        try:
            logger.info(msg)
            process_action(client, action_def, dry_run=ctx.params['dry_run'])
        except Exception as err:
            exception_handler(action_def, err)
        logger.info('Action ID: %s, "%s" completed.', idx, action_def.action)
    logger.info('All actions completed.')