From ccadf1ffee93f892165e8c88f82148bb4bcd1ead Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 16 Jun 2010 04:56:48 +0200 Subject: [PATCH] Simplify gnt-os diagnose output Currently, we always list the api/variants, even if these are empty. This patch changes so that we make clear distiction for empty values ("[no variants]" versus "[variants: ]"), and we only list variants and parameters when the OS API indicates they should be supported. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- scripts/gnt-os | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/scripts/gnt-os b/scripts/gnt-os index d0df8d25f..fd96cbee8 100755 --- a/scripts/gnt-os +++ b/scripts/gnt-os @@ -29,6 +29,7 @@ import sys from ganeti.cli import * +from ganeti import constants from ganeti import opcodes from ganeti import utils @@ -162,18 +163,30 @@ def DiagnoseOS(opts, args): for node_name, node_info in node_data.iteritems(): nodes_hidden[node_name] = [] if node_info: # at least one entry in the per-node list - (first_os_path, first_os_status, first_os_msg, - first_os_variants, _, first_os_api) = node_info.pop(0) - if not first_os_variants: - first_os_variants = [] - first_os_msg = ("%s (path: %s) [variants: %s] [api: %s]" % - (_OsStatus(first_os_status, first_os_msg), - first_os_path, utils.CommaJoin(first_os_variants), - utils.CommaJoin(first_os_api))) - if first_os_status: - nodes_valid[node_name] = first_os_msg + (fo_path, fo_status, fo_msg, fo_variants, + fo_params, fo_api) = node_info.pop(0) + fo_msg = "%s (path: %s)" % (_OsStatus(fo_status, fo_msg), fo_path) + if fo_api: + max_os_api = max(fo_api) + fo_msg += " [API versions: %s]" % utils.CommaJoin(fo_api) else: - nodes_bad[node_name] = first_os_msg + max_os_api = 0 + fo_msg += " [no API versions declared]" + if max_os_api >= constants.OS_API_V15: + if fo_variants: + fo_msg += " [variants: %s]" % utils.CommaJoin(fo_variants) + else: + fo_msg += " [no variants]" + if max_os_api >= constants.OS_API_V20: + if fo_params: + fo_msg += (" [parameters: %s]" % + utils.CommaJoin([v[0] for v in fo_params])) + else: + fo_msg += " [no parameters]" + if fo_status: + nodes_valid[node_name] = fo_msg + else: + nodes_bad[node_name] = fo_msg for hpath, hstatus, hmsg, _, _, _ in node_info: nodes_hidden[node_name].append(" [hidden] path: %s, status: %s" % (hpath, _OsStatus(hstatus, hmsg))) -- GitLab