Пример #1
0
# Detect if another instance is running
def exit_if_running(pid):
    syslog.syslog(syslog.LOG_DEBUG,
                  "Checking if process %d is still alive" % (pid, ))
    try:
        os.kill(pid, 0)
        # If we reached here, there is another process in progress
        syslog.syslog(syslog.LOG_DEBUG,
                      "Process %d still working, quitting" % (pid, ))
        sys.exit(0)
    except OSError:
        syslog.syslog(syslog.LOG_DEBUG, "Process %d gone" % (pid, ))

MNTLOCK = mntlock()
setname('autorepl')
syslog.openlog("autorepl", syslog.LOG_CONS | syslog.LOG_PID)

sshcmd = '/usr/bin/ssh -i /data/ssh/replication -o BatchMode=yes -o StrictHostKeyChecking=yes -q'

mypid = os.getpid()
templog = '/tmp/repl-%d' % (mypid)

# (mis)use MNTLOCK as PIDFILE lock.
locked = True
try:
    MNTLOCK.lock_try()
except IOError:
    locked = False
if not locked:
    sys.exit(0)
Пример #2
0
from metanasUI.common.pipesubr import setname, pipeopen, system
from metanasUI.common.locks import mntlock

log = logging.getLogger('tools.autosnap')

# NOTE
#
# In this script there is no asynchnous programming so ALL locks are obtained
# in the blocking way.
#
# With this assumption, the mntlock SHOULD only be instansized once during the
# whole lifetime of this script.
#
MNTLOCK=mntlock()
setname('autosnap')

# Set to True if verbose log desired
debug = False

def snapinfodict2datetime(snapinfo):
    year = int(snapinfo['year'])
    month = int(snapinfo['month'])
    day = int(snapinfo['day'])
    hour = int(snapinfo['hour'])
    minute = int(snapinfo['minute'])
    return datetime(year, month, day, hour, minute)

def snap_expired(snapinfo, snaptime):
    snapinfo_expirationtime = snapinfodict2datetime(snapinfo)
    snap_ttl_value = int(snapinfo['retcount'])
Пример #3
0
# Detect if another instance is running
def exit_if_running(pid):
    syslog.syslog(syslog.LOG_DEBUG,
                  "Checking if process %d is still alive" % (pid, ))
    try:
        os.kill(pid, 0)
        # If we reached here, there is another process in progress
        syslog.syslog(syslog.LOG_DEBUG,
                      "Process %d still working, quitting" % (pid, ))
        sys.exit(0)
    except OSError:
        syslog.syslog(syslog.LOG_DEBUG, "Process %d gone" % (pid, ))


MNTLOCK = mntlock()
setname('autorepl')
syslog.openlog("autorepl", syslog.LOG_CONS | syslog.LOG_PID)

sshcmd = '/usr/bin/ssh -i /data/ssh/replication -o BatchMode=yes -o StrictHostKeyChecking=yes -q'

mypid = os.getpid()
templog = '/tmp/repl-%d' % (mypid)

# (mis)use MNTLOCK as PIDFILE lock.
locked = True
try:
    MNTLOCK.lock_try()
except IOError:
    locked = False
if not locked:
    sys.exit(0)
Пример #4
0
from metanasUI.common.pipesubr import setname, pipeopen, system
from metanasUI.common.locks import mntlock

log = logging.getLogger('tools.autosnap')

# NOTE
#
# In this script there is no asynchnous programming so ALL locks are obtained
# in the blocking way.
#
# With this assumption, the mntlock SHOULD only be instansized once during the
# whole lifetime of this script.
#
MNTLOCK = mntlock()
setname('autosnap')

# Set to True if verbose log desired
debug = False


def snapinfodict2datetime(snapinfo):
    year = int(snapinfo['year'])
    month = int(snapinfo['month'])
    day = int(snapinfo['day'])
    hour = int(snapinfo['hour'])
    minute = int(snapinfo['minute'])
    return datetime(year, month, day, hour, minute)


def snap_expired(snapinfo, snaptime):