jceel / py-libzfs

Python libzfs bindings
16 stars 8 forks source link

Optionally auto-create ancestors of nested datasets #19

Closed gronke closed 7 years ago

gronke commented 7 years ago

Allows the creation of nested datasets including missing ancestors. This behavior is known as the zfs create -p flag.

# zfs list | grep -c foo
0

Python 3.6.1 (default, Apr 17 2017, 19:51:49) 
[GCC 4.2.1 Compatible FreeBSD Clang 4.0.0 (tags/RELEASE_400/final 297347)] on freebsd11
Type "help", "copyright", "credits" or "license" for more information.
>>> import libzfs
>>> zfs = libzfs.ZFS()
>>> pool = zfs.get('tank')
>>> pool.create('tank/foo/bar', {}, libzfs.DatasetType.FILESYSTEM, 0, True)
>>>

# zfs list | grep -c foo
2

# zfs list | grep foo
tank/foo                              176K  128M     88K  /tank/foo
tank/foo/bar                           88K  128M     88K  /tank/foo/bar

The default remains not to auto-create ancestor datasets.

gronke commented 7 years ago

@jceel thanks for your review! Your feedback is addressed now.

jceel commented 7 years ago

@gronke Are you sure this works? :) I'm pretty sure you can't raise exceptions inside nogil block. Un-indenting lines 1795 and 1796 by one level seems to be needed.

gronke commented 7 years ago

right! of course.. fixed now

jceel commented 7 years ago

thank you! 🎉

skarekrow commented 7 years ago

Yay!