From aebd5eca41be7b1556aa0c64b6911748e49307ad Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 9 Apr 2014 17:24:28 +0100 Subject: [PATCH] Implement "vos partinfo" Signed-off-by: David Howells --- suite/commands/vos/partinfo.py | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 suite/commands/vos/partinfo.py diff --git a/suite/commands/vos/partinfo.py b/suite/commands/vos/partinfo.py new file mode 100644 index 0000000..281b95b --- /dev/null +++ b/suite/commands/vos/partinfo.py @@ -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", "" ], + [ "partition", get_partition_id, "os", "" ], + [ "summary", get_dummy, "fn" ], + [ "cell", get_cell, "os", "" ], + [ "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) -- 2.49.0