From 3fa93523c9d817712a2d14248ae3488f8d2a39d5 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Thu, 18 Sep 2008 11:13:10 +0000 Subject: [PATCH] Apply filter properly in LUQuery{Nodes, Instances} Currently when not locking all nodes/instances are returned, regardless if the user asked only for some of them. With this patch we return to the previous behaviour: - if no names are specified return info on all current ones - if some names are specified and are not found give an error - otherwise return only info on the specified names Reviewed-by: iustinp --- lib/cmdlib.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index e4f143d3b..3c8638745 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1457,6 +1457,12 @@ class LUQueryNodes(NoHooksLU): all_info = self.cfg.GetAllNodesInfo() if self.do_locking: nodenames = self.acquired_locks[locking.LEVEL_NODE] + elif self.wanted != locking.ALL_SET: + nodenames = self.wanted + missing = set(nodenames).difference(all_info.keys()) + if missing: + raise self.OpExecError( + "Some nodes were removed before retrieving their data: %s" % missing) else: nodenames = all_info.keys() nodelist = [all_info[name] for name in nodenames] @@ -2606,6 +2612,13 @@ class LUQueryInstances(NoHooksLU): all_info = self.cfg.GetAllInstancesInfo() if self.do_locking: instance_names = self.acquired_locks[locking.LEVEL_INSTANCE] + elif self.wanted != locking.ALL_SET: + instance_names = self.wanted + missing = set(instance_names).difference(all_info.keys()) + if missing: + raise self.OpExecError( + "Some instances were removed before retrieving their data: %s" + % missing) else: instance_names = all_info.keys() instance_list = [all_info[iname] for iname in instance_names] -- GitLab