From c98162a7fc0fa9225d7ce22b42f43a62a9efb153 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 17 Jun 2009 12:50:39 +0200 Subject: [PATCH] Show disk size in instance info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 1 + scripts/gnt-instance | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 096ee718a..dab9ef728 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -5703,6 +5703,7 @@ class LUQueryInstanceData(NoHooksLU): "sstatus": dev_sstatus, "children": dev_children, "mode": dev.mode, + "size": dev.size, } return data diff --git a/scripts/gnt-instance b/scripts/gnt-instance index a54672c90..def14bd7c 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -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"])) -- GitLab