Show disk size in instance info
authorIustin Pop <iustin@google.com>
Wed, 17 Jun 2009 10:50:39 +0000 (12:50 +0200)
committerIustin Pop <iustin@google.com>
Wed, 17 Jun 2009 12:52:05 +0000 (14:52 +0200)
The size of the instance's disk was not shown in “gnt-instance info”.
This patch adds it and formats it nicely if possible.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/cmdlib.py
scripts/gnt-instance

index 096ee71..dab9ef7 100644 (file)
@@ -5703,6 +5703,7 @@ class LUQueryInstanceData(NoHooksLU):
       "sstatus": dev_sstatus,
       "children": dev_children,
       "mode": dev.mode,
+      "size": dev.size,
       }
 
     return data
index a54672c..def14bd 100755 (executable)
@@ -998,7 +998,11 @@ def _FormatBlockDevInfo(idx, top_level, dev, static):
       txt = "disk %d" % idx
   else:
     txt = "child %d" % idx
-  d1 = ["- %s: %s" % (txt, dev["dev_type"])]
+  if isinstance(dev["size"], int):
+    nice_size = utils.FormatUnit(dev["size"], "h")
+  else:
+    nice_size = dev["size"]
+  d1 = ["- %s: %s, size %s" % (txt, dev["dev_type"], nice_size)]
   data = []
   if top_level:
     data.append(("access mode", dev["mode"]))