Exemple #1
0
def clear():
    with settings(
            hide('status', 'running', 'stdout', 'stderr', 'warnings'),
            warn_only=True,
    ):
        out = run("rpm -q sanlock")
    if not out.succeeded:
        info("Sanlock was not installed.")
        return

    out = run("sanlock client status")
    if out.failed:
        fail("Failed to check sanlock status")

    locks = [
        line.rsplit(' ', 1)[-1] for line in out.splitlines()
        if line.startswith('s ')
    ]
    info("Got %d locks" % len(locks))
    failed_locks = []
    for lock in locks:
        info("  Freeing lock %s" % lock)
        with settings(hide('running', 'stdout', 'stderr', 'warnings'),
                      warn_only=True,
                      disable_known_hosts=True):
            res = run("sanlock rem_lockspace -s '%s'" % lock)
            if not res.succeeded:
                failed_locks.append(lock)

    if failed_locks:
        abort("Failed to freed locks: " + ','.join(failed_locks))

    info("Done")
Exemple #2
0
def sync(ntp_server=config.NTP_SERVER):
    """
    Sync the server with the given ntp server, stops and restarts the ntpd
    service if it was enabled.

    :param ntp_server:
        NTP server to use, default = config.NTP_SERVER
    """
    start = False
    with settings(hide('running', 'status', 'stderr', 'stdout', 'warnings'),
                  warn_only=True):
        res = run("service ntpd status")
    if res.succeeded:
        info("Stopping ntpd")
        run("service ntpd stop")
        start = True
    info("Synching the time")
    run("ntpdate %s" % ntp_server)
    if start:
        info("Starting ntpd again")
        run("service ntpd start")
Exemple #3
0
def sync(ntp_server=config.NTP_SERVER):
    """
    Sync the server with the given ntp server, stops and restarts the ntpd
    service if it was enabled.

    :param ntp_server:
        NTP server to use, default = config.NTP_SERVER
    """
    start = False
    with settings(hide('running', 'status', 'stderr', 'stdout', 'warnings'),
                  warn_only=True):
        res = run("service ntpd status")
    if res.succeeded:
        info("Stopping ntpd")
        run("service ntpd stop")
        start = True
    info("Synching the time")
    run("ntpdate %s" % ntp_server)
    if start:
        info("Starting ntpd again")
        run("service ntpd start")