From d7747cbcf0e2da91e8d0e3dfd6d3ac45da469773 Mon Sep 17 00:00:00 2001 From: Chris Kirby Date: Thu, 6 Aug 2009 09:10:03 -0600 Subject: 6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot --- usr/src/lib/pyzfs/common/dataset.py | 8 ++++++-- usr/src/lib/pyzfs/common/holds.py | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'usr/src/lib/pyzfs') 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")) -- cgit v1.2.3