Exemplo n.º 1
0
def try_pcmk_wait():
    """Try pcmk.wait_for_pcmk()
    Log results and set status message
    """
    try:
        pcmk.wait_for_pcmk()
        log("Pacemaker is ready", DEBUG)
    except pcmk.ServicesNotUp:
        msg = ("Pacemaker is down. Please manually start it.")
        log(msg, ERROR)
        status_set('blocked', msg)
        raise pcmk.ServicesNotUp(msg)
Exemplo n.º 2
0
def validated_restart_corosync(retries=10):
    """Restart and validate Corosync and Pacemaker are in fact up and running.

    @param retries: number of attempts to restart the services before giving up
    @raises pcmk.ServicesNotUp if after retries services are still not up
    """
    for restart in range(retries):
        try:
            if restart_corosync():
                log("Corosync and Pacemaker are validated as up and running.",
                    INFO)
                return
            else:
                log("Corosync or Pacemaker not validated as up yet, retrying",
                    WARNING)
        except pcmk.ServicesNotUp:
            log("Pacemaker failed to start, retrying", WARNING)
            continue

    msg = ("Corosync and/or Pacemaker failed to restart after {} retries"
           "".format(retries))
    log(msg, ERROR)
    status_set('blocked', msg)
    raise pcmk.ServicesNotUp(msg)