28 lines
996 B
Python
28 lines
996 B
Python
#!/usr/bin/python3
|
|
import subprocess
|
|
import Pyro4
|
|
|
|
ENCODING = 'utf-8'
|
|
|
|
class ZfsSnapshotManagerDaemon(object):
|
|
# TODO docstrings class and methods
|
|
snapshots = list()
|
|
def __init__(self):
|
|
self.snapshots = self.call_zfs_list_snapshots()
|
|
|
|
def call_zfs_list_snapshots(self):
|
|
command = ('zfs list -Hp -t snapshot -o name,creation,used,referenced -s name')
|
|
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
snapshot_list = [snapshot.decode(ENCODING) for snapshot in p.stdout]
|
|
retval = p.wait() ## TODO Implement retval actions
|
|
return snapshot_list
|
|
|
|
@Pyro4.expose
|
|
def get_current_list(self):
|
|
return self.snapshots
|
|
|
|
# TODO socket start and delete handling + SIGINT handling
|
|
daemon = Pyro4.Daemon(port=None,unixsocket='/run/zfssmd.sock')
|
|
uri = daemon.register(ZfsSnapshotManagerDaemon(), "058b7dde9ec53de9235cfc57a07ce17a9eabfce3")
|
|
print (uri) ## FIXME debug only
|
|
daemon.requestLoop() |