From 83d4ba5eab52d512d25f64cbbcdf8daf69f09978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Wed, 16 May 2012 14:14:10 +0200 Subject: [PATCH] gnt-instance info: Rework beparams listings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch reworks the beparams listing to the new style. However, due to this process the naming of the fields with mixed casing changed to lowercase and is therefore not 100% compatible with the previous versions. As "memory" is marked deprecated and sort of default we merge that just into the actual dict, which leads to the following output: - maxmem: 128 - memory: default (128) - minmem: 128 Instead of: - maxmem: 128 - minmem: 128 - memory: 128 Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/client/gnt_instance.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index a263a8b71..c6dfd69e3 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -25,6 +25,7 @@ # W0614: Unused import %s from wildcard import (since we need cli) # C0103: Invalid name gnt-instance +import copy import itertools import simplejson import logging @@ -1249,23 +1250,12 @@ def ShowInstanceConfig(opts, args): FormatParameterDict(buf, instance["hv_instance"], instance["hv_actual"], level=2) buf.write(" Hardware:\n") - buf.write(" - VCPUs: %s\n" % - compat.TryToRoman(instance["be_actual"][constants.BE_VCPUS], - convert=opts.roman_integers)) - buf.write(" - maxmem: %sMiB\n" % - compat.TryToRoman(instance["be_actual"][constants.BE_MAXMEM], - convert=opts.roman_integers)) - buf.write(" - minmem: %sMiB\n" % - compat.TryToRoman(instance["be_actual"][constants.BE_MINMEM], - convert=opts.roman_integers)) # deprecated "memory" value, kept for one version for compatibility # TODO(ganeti 2.7) remove. - buf.write(" - memory: %sMiB\n" % - compat.TryToRoman(instance["be_actual"][constants.BE_MAXMEM], - convert=opts.roman_integers)) - buf.write(" - %s: %s\n" % - (constants.BE_ALWAYS_FAILOVER, - instance["be_actual"][constants.BE_ALWAYS_FAILOVER])) + be_actual = copy.deepcopy(instance["be_actual"]) + be_actual["memory"] = be_actual[constants.BE_MAXMEM] + FormatParameterDict(buf, instance["be_instance"], be_actual, level=2) + # TODO(ganeti 2.7) rework the NICs as well buf.write(" - NICs:\n") for idx, (ip, mac, mode, link) in enumerate(instance["nics"]): buf.write(" - nic/%d: MAC: %s, IP: %s, mode: %s, link: %s\n" % -- GitLab