]> www.infradead.org Git - users/dhowells/kafs-utils.git/commitdiff
Implement "vos partinfo"
authorDavid Howells <dhowells@redhat.com>
Wed, 9 Apr 2014 16:24:28 +0000 (17:24 +0100)
committerDavid Howells <dhowells@redhat.com>
Wed, 9 Apr 2014 16:27:03 +0000 (17:27 +0100)
Signed-off-by: David Howells <dhowells@redhat.com>
suite/commands/vos/partinfo.py [new file with mode: 0644]

diff --git a/suite/commands/vos/partinfo.py b/suite/commands/vos/partinfo.py
new file mode 100644 (file)
index 0000000..281b95b
--- /dev/null
@@ -0,0 +1,68 @@
+#
+# AFS Volume management toolkit: Report information on partitions
+# -*- coding: utf-8 -*-
+#
+
+__copyright__ = """
+Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
+Written by David Howells (dhowells@redhat.com)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public Licence version 2 as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public Licence for more details.
+
+You should have received a copy of the GNU General Public Licence
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+
+from afs.argparse import *
+import kafs
+
+help = "Report the available and total space on a partition"
+
+command_arguments = [
+    [ "server",         get_volserver,          "rs",         "<machine name>" ],
+    [ "partition",      get_partition_id,       "os",         "<partition name>" ],
+    [ "summary",        get_dummy,              "fn" ],
+    [ "cell",           get_cell,               "os",         "<cell name>" ],
+    [ "noauth",         get_auth,               "fn" ],
+    [ "localauth",      get_auth,               "fn" ],
+    [ "verbose",        get_dummy,              "fn" ],
+    [ "encrypt",        get_dummy,              "fn" ],
+    [ "noresolve",      get_dummy,              "fn" ],
+]
+
+cant_combine_arguments = [
+    ( "cell",           "localauth" ),
+    ( "noauth",         "localauth" ),
+]
+
+description = r"""
+Report the available and total space on a partition
+"""
+
+def main(params):
+    cell = params["cell"]
+    vol_conn = cell.open_volume_server(params["server"], params)
+
+    ret = kafs.VOLSER_AFSVolListPartitions(vol_conn)
+    partitions = ret.partIDs.partIds
+
+    for i in partitions:
+        if i != 0xffffffff:
+            if i < 26:
+                partname = "/vicep{:c}".format(i + 97)
+            else:
+                partname = "/vicep{:c}{:c}".format(i / 26 + 97, i % 26 + 97)
+
+            ret = kafs.VOLSER_AFSVolPartitionInfo(vol_conn, partname)
+            part = ret.partition
+
+            print("Free space on partition", part.name + ":",
+                  part.free, "K blocks out of total", part.totalUsable)