From 694e2444fb746646b9bef14edd8ac37fef8e2df6 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Thu, 4 Oct 2007 10:41:28 +0000 Subject: [PATCH] Fix OS Diagnose in light of the new OS Search path (Part One). As of now only the last OS was taken into consideration by diagnose, fix by storing them all and displaying for now only the first. Also display the source path for valid OSes. Reviewed-by: imsnah --- scripts/gnt-os | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/gnt-os b/scripts/gnt-os index 155485fbc..909d508f5 100755 --- a/scripts/gnt-os +++ b/scripts/gnt-os @@ -91,7 +91,9 @@ def DiagnoseOS(opts, args): os_name = obj.args[0] if os_name not in all_os: all_os[os_name] = {} - all_os[os_name][node_name] = obj + if node_name not in all_os[os_name]: + all_os[os_name][node_name] = [] + all_os[os_name][node_name].append(obj) max_name = len('Name') if all_os: @@ -107,11 +109,12 @@ def DiagnoseOS(opts, args): nodes_valid = [] nodes_bad = {} for node_name in node_data: - nos = all_os[os_name].get(node_name, None) - if isinstance(nos, objects.OS): - nodes_valid.append(node_name) - elif isinstance(nos, errors.InvalidOS): - nodes_bad[node_name] = nos.args[1] + if node_name in all_os[os_name]: + nos = all_os[os_name][node_name] + if isinstance(nos[0], objects.OS): + nodes_valid.append(node_name) + elif isinstance(nos[0], errors.InvalidOS): + nodes_bad[node_name] = nos[0].args[1] else: nodes_bad[node_name] = "os dir not found" @@ -121,10 +124,12 @@ def DiagnoseOS(opts, args): status = "invalid" else: status = "partial valid" + logger.ToStdout(format % (max_name, os_name, max_node, status, "")) nodes_valid = utils.NiceSort(nodes_valid) for node_name in nodes_valid: - logger.ToStdout(format % (max_name, "", max_node, node_name, "valid")) + logger.ToStdout(format % (max_name, "", max_node, node_name, + "valid (%s)" % all_os[os_name][node_name][0].path)) nbk = utils.NiceSort(nodes_bad.keys()) for node_name in nbk: logger.ToStdout(format % (max_name, "", max_node, -- GitLab