summaryrefslogtreecommitdiff
path: root/usr/src/lib/pyzfs
diff options
context:
space:
mode:
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"))