Commit e194129a authored by Stephen Shirley's avatar Stephen Shirley Committed by Guido Trotter
Browse files

lvmstrap: Change diskinfo to use GenerateTable



This way the produced table is formatted nicely.
Signed-off-by: default avatarStephen Shirley <diamond@google.com>
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent e1876432
......@@ -46,6 +46,7 @@ import time
from ganeti.utils import RunCmd
from ganeti import constants
from ganeti import cli
USAGE = ("\tlvmstrap diskinfo\n"
"\tlvmstrap [--vgname=NAME] [--allow-removable]"
......@@ -487,8 +488,15 @@ def ShowDiskInfo(opts):
dlist = GetDiskList(opts)
print "------- Disk information -------"
print ("%5s %7s %4s %5s %-10s %s" %
("Name", "Size[M]", "Used", "Mount", "LVM?", "Info"))
headers = {
"name": "Name",
"size": "Size[M]",
"used": "Used",
"mount": "Mount",
"lvm": "LVM?",
"info": "Info"
}
fields = ["name", "size", "used", "mount", "lvm", "info"]
flatlist = []
# Flatten the [(disk, [partition,...]), ...] list
......@@ -501,6 +509,7 @@ def ShowDiskInfo(opts):
for partname, partsize, partdev in parts:
flatlist.append((partname, partsize, partdev, ""))
strlist = []
for name, size, dev, in_use in flatlist:
mp, vgname, fileinfo = DevInfo(name, dev, mounts)
if mp is None:
......@@ -515,8 +524,15 @@ def ShowDiskInfo(opts):
if len(name) > 3:
# Indent partitions
name = " %s" % name
print ("%-5s %7.2f %-4s %-5s %-10s %s" %
(name, float(size) / 1024 / 1024, in_use, mp, lvminfo, fileinfo))
strlist.append([name, "%.2f" % (float(size) / 1024 / 1024),
in_use, mp, lvminfo, fileinfo])
data = cli.GenerateTable(headers, fields, None,
strlist, numfields=["size"])
for line in data:
print line
def CheckReread(name):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment