Exemple #1
0
 if zfsproc.returncode:
     syslog.syslog(syslog.LOG_ALERT,
         'Could not determine last available snapshot for dataset %s: %s'
         % (localfs, error, ))
     MNTLOCK.unlock()
     continue
 if output != '':
     snapshots_list = output.split('\n')
     found_latest = False
     for snapshot_item in snapshots_list:
         if snapshot_item != '':
             snapshot, state = snapshot_item.split('\t')
             if found_latest:
                 # assert (known_latest_snapshot != '') because found_latest
                 if state != '-':
                     system('/sbin/zfs set metanas:state=NEW %s' % (known_latest_snapshot))
                     system('/sbin/zfs set metanas:state=LATEST %s' % (snapshot))
                     wanted_list.insert(0, known_latest_snapshot)
                     syslog.syslog(syslog.LOG_DEBUG, "Snapshot %s added to wanted list (was LATEST)" % (snapshot))
                     known_latest_snapshot = snapshot
                     syslog.syslog(syslog.LOG_ALERT, "Snapshot %s became latest snapshot" % (snapshot))
             else:
                 syslog.syslog(syslog.LOG_DEBUG, "Snapshot: %s State: %s" % (snapshot, state))
                 if state == 'LATEST' and not resetonce:
                     found_latest = True
                     known_latest_snapshot = snapshot
                     syslog.syslog(syslog.LOG_DEBUG, "Snapshot %s is the recorded latest snapshot" % (snapshot))
                 elif state == 'NEW' or resetonce:
                     wanted_list.insert(0, snapshot)
                     syslog.syslog(syslog.LOG_DEBUG, "Snapshot %s added to wanted list" % (snapshot))
                 elif state.startswith('INPROGRESS'):
Exemple #2
0
    recursive = False
    for task in tasklist:
        if task.task_recursive == True:
            recursive = True
    if recursive == True:
        rflag = ' -r'
    else:
        rflag = ''

    snapname = '%s@auto-%s-%s' % (fs, snaptime_str, expire)

    # If there is associated replication task, mark the snapshots as 'NEW'.
    if Replication.objects.filter(repl_filesystem = fs).count() > 0:
        MNTLOCK.lock()
        snapcmd = '/sbin/zfs snapshot%s -o metanas:state=NEW %s' % (rflag, snapname)
        system(snapcmd)
        MNTLOCK.unlock()
    else:
        snapcmd = '/sbin/zfs snapshot%s %s' % (rflag, snapname)
        system(snapcmd)

MNTLOCK.lock()
for snapshot in snapshots_pending_delete:
    zfsproc = pipeopen('/sbin/zfs get -H metanas:state %s' % (snapshot))
    output = zfsproc.communicate()[0]
    if output != '':
        fsname, attrname, value, source = output.split('\n')[0].split('\t')
	if value == '-':
            snapcmd = '/sbin/zfs destroy %s' % (snapshot)
            system(snapcmd)
Exemple #3
0
         (
             localfs,
             error,
         ))
     MNTLOCK.unlock()
     continue
 if output != '':
     snapshots_list = output.split('\n')
     found_latest = False
     for snapshot_item in snapshots_list:
         if snapshot_item != '':
             snapshot, state = snapshot_item.split('\t')
             if found_latest:
                 # assert (known_latest_snapshot != '') because found_latest
                 if state != '-':
                     system('/sbin/zfs set metanas:state=NEW %s' %
                            (known_latest_snapshot))
                     system('/sbin/zfs set metanas:state=LATEST %s' %
                            (snapshot))
                     wanted_list.insert(0, known_latest_snapshot)
                     syslog.syslog(
                         syslog.LOG_DEBUG,
                         "Snapshot %s added to wanted list (was LATEST)" %
                         (snapshot))
                     known_latest_snapshot = snapshot
                     syslog.syslog(
                         syslog.LOG_ALERT,
                         "Snapshot %s became latest snapshot" % (snapshot))
             else:
                 syslog.syslog(syslog.LOG_DEBUG,
                               "Snapshot: %s State: %s" % (snapshot, state))
                 if state == 'LATEST' and not resetonce:
Exemple #4
0
    for task in tasklist:
        if task.task_recursive == True:
            recursive = True
    if recursive == True:
        rflag = ' -r'
    else:
        rflag = ''

    snapname = '%s@auto-%s-%s' % (fs, snaptime_str, expire)

    # If there is associated replication task, mark the snapshots as 'NEW'.
    if Replication.objects.filter(repl_filesystem=fs).count() > 0:
        MNTLOCK.lock()
        snapcmd = '/sbin/zfs snapshot%s -o metanas:state=NEW %s' % (rflag,
                                                                    snapname)
        system(snapcmd)
        MNTLOCK.unlock()
    else:
        snapcmd = '/sbin/zfs snapshot%s %s' % (rflag, snapname)
        system(snapcmd)

MNTLOCK.lock()
for snapshot in snapshots_pending_delete:
    zfsproc = pipeopen('/sbin/zfs get -H metanas:state %s' % (snapshot))
    output = zfsproc.communicate()[0]
    if output != '':
        fsname, attrname, value, source = output.split('\n')[0].split('\t')
        if value == '-':
            snapcmd = '/sbin/zfs destroy %s' % (snapshot)
            system(snapcmd)