Commit 3fa93523 authored by Guido Trotter's avatar Guido Trotter
Browse files

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
parent c2c2a903
......@@ -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)
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)
instance_names = all_info.keys()
instance_list = [all_info[iname] for iname in instance_names]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment