示例#1
0
文件: zfs.py 项目: gclawes/tardis
 def get_snapshot_size(self, snapshot):
     cmd_out = zfs_cmd.list("-H", snapshot.name)
     size = cmd_out.split("\t")[1]
     if size == "0":
         return 0
     else:
         return size
示例#2
0
文件: zfs.py 项目: gclawes/tardis
    def get_snapshots(self, filesystem=None):
        """retrieve all ZFS snapshots marked as auto-snapshot"""

        if filesystem is None:
            raw_list = zfs_cmd.list("-H", "-t", "snapshot")
        else:
            raw_list = zfs_cmd.list("-H", "-r", "-d1", "-t", "snapshot", filesystem)
        zfs_reader = reader(StringIO(raw_list), delimiter="\t")
        snapshots = []
        for row in zfs_reader:
            if "zfs-auto-snap" in row[0]:
                dataset, name = row[0].split("@")
                _, temp = name.split("_")
                split = temp.split("-")
                interval = split[0]
                label = "-".join(split[1:])
                snapshots.append(Snapshot(self, dataset, interval, label, size=row[1]))
        return snapshots
示例#3
0
文件: zfs.py 项目: gclawes/tardis
 def get_datasets(self):
     raw_list = zfs_cmd.list("-H")
     l = reader(StringIO(raw_list), delimiter="\t")
     return [row[0] for row in l]