Example #1
0
def get_failcounts(env,
                   resource=None,
                   node=None,
                   operation=None,
                   interval=None):
    # pylint: disable=redefined-outer-name
    """
    List resources failcounts, optionally filtered by a resource, node or op

    LibraryEnvironment env
    string resource -- show failcounts for the specified resource only
    string node -- show failcounts for the specified node only
    string operation -- show failcounts for the specified operation only
    string interval -- show failcounts for the specified operation interval only
    """
    report_items = []
    if interval is not None and operation is None:
        report_items.append(
            reports.prerequisite_option_is_missing("interval", "operation"))
    if interval is not None:
        report_items.extend(
            ValueTimeInterval("interval").validate({"interval": interval}))
    if report_items:
        raise LibraryError(*report_items)

    interval_ms = (None if interval is None else timeout_to_seconds(interval) *
                   1000)

    all_failcounts = cib_status.get_resources_failcounts(
        get_status(env.get_cib()))
    return cib_status.filter_resources_failcounts(all_failcounts,
                                                  resource=resource,
                                                  node=node,
                                                  operation=operation,
                                                  interval=interval_ms)
Example #2
0
def get_failcounts(
    env, resource=None, node=None, operation=None, interval=None
):
    # pylint: disable=redefined-outer-name
    """
    List resources failcounts, optionally filtered by a resource, node or op

    LibraryEnvironment env
    string resource -- show failcounts for the specified resource only
    string node -- show failcounts for the specified node only
    string operation -- show failcounts for the specified operation only
    string interval -- show failcounts for the specified operation interval only
    """
    report_items = []
    if interval is not None and operation is None:
        report_items.append(
            reports.prerequisite_option_is_missing("interval", "operation")
        )
    if interval is not None:
        report_items.extend(
            value_time_interval("interval")({"interval": interval})
        )
    if report_items:
        raise LibraryError(*report_items)

    interval_ms = (
        None if interval is None
        else timeout_to_seconds(interval) * 1000
    )

    all_failcounts = cib_status.get_resources_failcounts(
        get_status(env.get_cib())
    )
    return cib_status.filter_resources_failcounts(
        all_failcounts,
        resource=resource,
        node=node,
        operation=operation,
        interval=interval_ms
    )