5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
25 """This module implements the "zfs holds" subcommand.
26 The only public interface is the zfs.holds.do_holds() function."""
39 """Implements the "zfs holds" subcommand."""
44 parser.exit("zfs: error: " + msg)
48 u = _("""holds [-r] <snapshot> ...""")
50 parser = optparse.OptionParser(usage=u, prog="zfs")
52 parser.add_option("-r", action="store_true", dest="recursive",
53 help=_("list holds recursively"))
55 (options, args) = parser.parse_args(sys.argv[2:])
58 usage(_("missing snapshot argument"))
60 fields = ("name", "tag", "timestamp")
64 t = zfs.table.Table(fields, rjustfields)
65 for ds in zfs.dataset.snapshots_fromcmdline(args, options.recursive):
67 for tag, tm in ds.get_holds().iteritems():
68 val = {"name": ds.name, "tag": tag,
69 "timestamp": time.ctime(tm)}
70 t.addline(ds.name, val)
75 raise zfs.util.ZFSError(errno.ENOENT, _("no matching datasets"))