Commit ea47808a authored by Guido Trotter's avatar Guido Trotter
Browse files

Prevent mistakes using _GetWantedNodes

All the users of _GetWantedNodes have been converted to be concurrent
LUs, and thus cannot call this function with an empty list of nodes
anymore. This patch makes this restriction a part of the function
itself. This prevents mistakes in new concurrent LUs, and creates more
work for new non-concurrent LUs, which we shouldn't add anyway.

Reviewed-by: iustinp
parent 21a15682
...@@ -322,17 +322,17 @@ def _GetWantedNodes(lu, nodes): ...@@ -322,17 +322,17 @@ def _GetWantedNodes(lu, nodes):
if not isinstance(nodes, list): if not isinstance(nodes, list):
raise errors.OpPrereqError("Invalid argument type 'nodes'") raise errors.OpPrereqError("Invalid argument type 'nodes'")
if nodes: if not nodes:
wanted = [] raise errors.ProgrammerError("_GetWantedNodes should only be called with a"
" non-empty list of nodes whose name is to be expanded.")
for name in nodes: wanted = []
node = lu.cfg.ExpandNodeName(name) for name in nodes:
if node is None: node = lu.cfg.ExpandNodeName(name)
raise errors.OpPrereqError("No such node name '%s'" % name) if node is None:
wanted.append(node) raise errors.OpPrereqError("No such node name '%s'" % name)
wanted = lu.cfg.GetNodeList()
return utils.NiceSort(wanted) return utils.NiceSort(wanted)
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