refactor: ZFS.destroy_snapshot
This commit is contained in:
+6
-7
@@ -244,16 +244,15 @@ class ZFS:
|
|||||||
]
|
]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
# TODO must take a Snapshot object
|
def destroy_snapshot(snapshot: Snapshot, *, recursive=False):
|
||||||
def destroy(full_name, *, recursive=False):
|
if not isinstance(snapshot, Snapshot):
|
||||||
# TODO condition must be "begins with"
|
raise TypeError("Can only destroy snapshots.")
|
||||||
# or better argument should be a ZFSPath
|
if config.local_pool_to_backup == snapshot.pool:
|
||||||
if config.local_pool_to_backup in full_name:
|
|
||||||
raise Exception(DELETE_IN_LOCAL_POOL)
|
raise Exception(DELETE_IN_LOCAL_POOL)
|
||||||
cmdline = [config.ZFS, "destroy"]
|
cmdline = [config.ZFS, "destroy"]
|
||||||
if recursive:
|
if recursive:
|
||||||
cmdline.append("-r")
|
cmdline.append("-r")
|
||||||
cmdline.append(full_name)
|
cmdline.append(str(snapshot))
|
||||||
run_command(cmdline)
|
run_command(cmdline)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -477,7 +476,7 @@ class Snapshot:
|
|||||||
return bool(search(regex, str(self._path)))
|
return bool(search(regex, str(self._path)))
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
ZFS.destroy(str(self))
|
ZFS.destroy_snapshot(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pool(self) -> str:
|
def pool(self) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user