From 94a02bb5541fc7378da1f382665847e1f6cff684 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Fri, 9 Jan 2009 14:26:37 +0000 Subject: [PATCH] Fix gnt-os for offline nodes We shouldn't query offline nodes in gnt-os. This patch adds an utility function to ConfigWriter that returns the names of online nodes and uses it in LUDiagnoseOS to query only the good nodes. Reviewed-by: imsnah --- lib/cmdlib.py | 6 ++++-- lib/config.py | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 61b1980..b7b2fa8 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1587,10 +1587,12 @@ class LUDiagnoseOS(NoHooksLU): """ node_list = self.acquired_locks[locking.LEVEL_NODE] - node_data = self.rpc.call_os_diagnose(node_list) + valid_nodes = [node for node in self.cfg.GetOnlineNodeList() + if node in node_list] + node_data = self.rpc.call_os_diagnose(valid_nodes) if node_data == False: raise errors.OpExecError("Can't gather the list of OSes") - pol = self._DiagnoseByOS(node_list, node_data) + pol = self._DiagnoseByOS(valid_nodes, node_data) output = [] for os_name, os_data in pol.iteritems(): row = [] diff --git a/lib/config.py b/lib/config.py index 5fd410b..986b03a 100644 --- a/lib/config.py +++ b/lib/config.py @@ -787,6 +787,15 @@ class ConfigWriter: return self._UnlockedGetNodeList() @locking.ssynchronized(_config_lock, shared=1) + def GetOnlineNodeList(self): + """Return the list of nodes which are online. + + """ + all_nodes = [self._UnlockedGetNodeInfo(node) + for node in self._UnlockedGetNodeList()] + return [node.name for node in all_nodes if not node.offline] + + @locking.ssynchronized(_config_lock, shared=1) def GetAllNodesInfo(self): """Get the configuration of all nodes. -- 1.7.10.4