Beispiel #1
0
def _check_if_atb_can_be_disabled(
    service_manager: ServiceManagerInterface,
    report_processor: ReportProcessor,
    corosync_conf: CorosyncConfFacade,
    was_enabled: bool,
    force: bool = False,
) -> None:
    """
    Check whenever auto_tie_breaker can be changed without affecting SBD.
    Raises LibraryError if change of ATB will affect SBD functionality.

    service_manager --
    report_processor -- report processor
    corosync_conf -- corosync conf facade
    was_enabled -- True if ATB was enabled, False otherwise
    force -- force change
    """
    if (was_enabled and not corosync_conf.is_enabled_auto_tie_breaker() and
            sbd.is_auto_tie_breaker_needed(service_manager, corosync_conf)):
        report_processor.report(
            ReportItem(
                severity=reports.item.get_severity(
                    reports.codes.FORCE,
                    force,
                ),
                message=(reports.messages.
                         CorosyncQuorumAtbCannotBeDisabledDueToSbd()),
            ))
        if report_processor.has_errors:
            raise LibraryError()
Beispiel #2
0
def atb_has_to_be_enabled(
    service_manager: ServiceManagerInterface,
    corosync_conf_facade: CorosyncConfFacade,
    node_number_modifier: int = 0,
) -> bool:
    """
    Return True whenever quorum option auto tie breaker has to be enabled for
    proper working of SBD fencing. False if it's not needed or it is already
    enabled.

    service_manager --
    corosync_conf_facade --
    node_number_modifier -- this value vill be added to current number of nodes.
        This can be useful to test whenever is ATB needed when adding/removeing
        node.
    """
    return (not corosync_conf_facade.is_enabled_auto_tie_breaker()
            and is_auto_tie_breaker_needed(
                service_manager, corosync_conf_facade, node_number_modifier))