summaryrefslogtreecommitdiff
path: root/usr/src/lib/pyzfs
diff options
context:
space:
mode:
authorChris Kirby <chris.kirby@sun.com>2009-08-06 09:10:03 -0600
committerChris Kirby <chris.kirby@sun.com>2009-08-06 09:10:03 -0600
commitd7747cbcf0e2da91e8d0e3dfd6d3ac45da469773 (patch)
treec95681cc1c65ea88b29a1423d4d4e4bcee096aba /usr/src/lib/pyzfs
parent9a4611f412a6b1f7a0bc7d53d2bb046a95daa4bc (diff)
downloadillumos-joyent-d7747cbcf0e2da91e8d0e3dfd6d3ac45da469773.tar.gz
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Diffstat (limited to 'usr/src/lib/pyzfs')
-rw-r--r--usr/src/lib/pyzfs/common/dataset.py8
-rw-r--r--usr/src/lib/pyzfs/common/holds.py4
2 files changed, 10 insertions, 2 deletions
diff --git a/usr/src/lib/pyzfs/common/dataset.py b/usr/src/lib/pyzfs/common/dataset.py
index f3adc5c364..3e8223bd95 100644
--- a/usr/src/lib/pyzfs/common/dataset.py
+++ b/usr/src/lib/pyzfs/common/dataset.py
@@ -213,12 +213,16 @@ class Dataset(object):
def snapshots_fromcmdline(dsnames, recursive):
for dsname in dsnames:
- ds = Dataset(dsname)
if not "@" in dsname:
raise zfs.util.ZFSError(errno.EINVAL,
_("cannot open %s") % dsname,
_("operation only applies to snapshots"))
- yield ds
+ try:
+ ds = Dataset(dsname)
+ yield ds
+ except zfs.util.ZFSError, e:
+ if not recursive or e.errno != errno.ENOENT:
+ raise
if recursive:
(base, snapname) = dsname.split('@')
parent = Dataset(base)
diff --git a/usr/src/lib/pyzfs/common/holds.py b/usr/src/lib/pyzfs/common/holds.py
index 93db4a15e6..a2ee38f4e8 100644
--- a/usr/src/lib/pyzfs/common/holds.py
+++ b/usr/src/lib/pyzfs/common/holds.py
@@ -61,8 +61,10 @@ def do_holds():
fields = ("name", "tag", "timestamp")
rjustfields = ()
printing = False
+ gotone = False
t = zfs.table.Table(fields, rjustfields)
for ds in zfs.dataset.snapshots_fromcmdline(args, options.recursive):
+ gotone = True
for tag, tm in ds.get_holds().iteritems():
val = {"name": ds.name, "tag": tag,
"timestamp": time.ctime(tm)}
@@ -70,3 +72,5 @@ def do_holds():
printing = True
if printing:
t.printme()
+ elif not gotone:
+ raise zfs.util.ZFSError(errno.ENOENT, _("no matching datasets"))