Revision e194129a tools/lvmstrap
b/tools/lvmstrap | ||
---|---|---|
46 | 46 |
|
47 | 47 |
from ganeti.utils import RunCmd |
48 | 48 |
from ganeti import constants |
49 |
from ganeti import cli |
|
49 | 50 |
|
50 | 51 |
USAGE = ("\tlvmstrap diskinfo\n" |
51 | 52 |
"\tlvmstrap [--vgname=NAME] [--allow-removable]" |
... | ... | |
487 | 488 |
dlist = GetDiskList(opts) |
488 | 489 |
|
489 | 490 |
print "------- Disk information -------" |
490 |
print ("%5s %7s %4s %5s %-10s %s" % |
|
491 |
("Name", "Size[M]", "Used", "Mount", "LVM?", "Info")) |
|
491 |
headers = { |
|
492 |
"name": "Name", |
|
493 |
"size": "Size[M]", |
|
494 |
"used": "Used", |
|
495 |
"mount": "Mount", |
|
496 |
"lvm": "LVM?", |
|
497 |
"info": "Info" |
|
498 |
} |
|
499 |
fields = ["name", "size", "used", "mount", "lvm", "info"] |
|
492 | 500 |
|
493 | 501 |
flatlist = [] |
494 | 502 |
# Flatten the [(disk, [partition,...]), ...] list |
... | ... | |
501 | 509 |
for partname, partsize, partdev in parts: |
502 | 510 |
flatlist.append((partname, partsize, partdev, "")) |
503 | 511 |
|
512 |
strlist = [] |
|
504 | 513 |
for name, size, dev, in_use in flatlist: |
505 | 514 |
mp, vgname, fileinfo = DevInfo(name, dev, mounts) |
506 | 515 |
if mp is None: |
... | ... | |
515 | 524 |
if len(name) > 3: |
516 | 525 |
# Indent partitions |
517 | 526 |
name = " %s" % name |
518 |
print ("%-5s %7.2f %-4s %-5s %-10s %s" % |
|
519 |
(name, float(size) / 1024 / 1024, in_use, mp, lvminfo, fileinfo)) |
|
527 |
|
|
528 |
strlist.append([name, "%.2f" % (float(size) / 1024 / 1024), |
|
529 |
in_use, mp, lvminfo, fileinfo]) |
|
530 |
|
|
531 |
data = cli.GenerateTable(headers, fields, None, |
|
532 |
strlist, numfields=["size"]) |
|
533 |
|
|
534 |
for line in data: |
|
535 |
print line |
|
520 | 536 |
|
521 | 537 |
|
522 | 538 |
def CheckReread(name): |
Also available in: Unified diff