Open mexicarne opened 8 years ago
Hi,
Yes, it's not supported as a single call at the moment. However, you can trivially implement it by leveraging ds.dependents iterator:
>>> import libzfs
>>> z = libzfs.ZFS()
>>> ds = z.get_dataset('tank')
>>> ds
<libzfs.ZFSDataset name 'tank' type 'FILESYSTEM'>
>>> list(ds.dependents)
[<libzfs.ZFSSnapshot name 'tank/foo@auto-20160420.0905'>, <libzfs.ZFSSnapshot name 'tank/foo@auto-20160420.0908'>, <libzfs.ZFSSnapshot name 'tank/foo@auto-20160420.0911'>, <libzfs.ZFSSnapshot name 'tank/foo@auto-20160420.0906'>, <libzfs.ZFSSnapshot name 'tank/foo@auto-20160420.0910'>, <libzfs.ZFSSnapshot name 'tank/foo@auto-20160420.0909'>, <libzfs.ZFSSnapshot name 'tank/foo@auto-20160420.0907'>, <libzfs.ZFSDataset name 'tank/foo' type 'FILESYSTEM'>, <libzfs.ZFSDataset name 'tank/bar' type 'FILESYSTEM'>, <libzfs.ZFSDataset name 'tank/nfs' type 'FILESYSTEM'>]
>>>
Dependencies list is already sorted in the way that allows you to just iterate over it and issue .delete()
for each object.
Thanks, will try. Can we please keep this issue open as a feature request? We have recursive argument for ZFSSnapshot's destroy() method, and it looks like something similar can be done for ZFSDataset's delete() method.
Sadly, dependents iterator not in FreeBSD port yet. I asked @williambr already to update the port.
AttributeError: 'libzfs.ZFSDataset' object has no attribute 'dependents'
Is this something we still need to do? Just checking back as this issue is a bit old now..
Yes, I think that delete() call of Dataset object need to have recursive argument out of the box like we have for ZFSSnapshot's destroy() call. I'm not sure I can do it myself, so just prefer it to just hang here so @jceel or somebody else can add this feature.
Hello,
if I understand correctly, right now there is no possibility to remove dataset with all it snapshots in one run. I'm trying something like that:
And I got 'dataset is busy' exception.
delete() for dataset doesn't support recursive argument, so we have no direct equivalent for
zfs destroy -r dataset/with/snapshots
. Would you please provide support for this? Or I getting something wrong?