コード例 #1
0
def when_not_cli(block_id, *desired_states):
    """
    CLI version of the when_not decorator.
    """
    if not was_invoked(block_id) and not all_states(*desired_states):
        set_invoked(block_id)
        return True
    return False
コード例 #2
0
def hook_cli(block_id, *hook_patterns):
    """
    CLI version of the hook decorator.
    """
    if not was_invoked(block_id) and any_hook(*hook_patterns):
        set_invoked(block_id)
        return True
    return False
コード例 #3
0
def when_cli(block_id, *desired_states):
    """
    CLI version of the when decorator.

    Evaluates to true (exit 0) if all of the ``desired_states`` are active,
    as per :func:`~charmhelpers.core.reactive.bus.all_states`, and if it
    has not evaluated to true for the given ``block_id`` already for this
    round of dispatch.

    :param str block_id: Any unique identifier for the block, such as the
        filename and line number of the start of the block.
    :param list desired_states: List of states that should be active.
    """
    if not was_invoked(block_id) and all_states(*desired_states):
        set_invoked(block_id)
        return True
    return False