Commit 069dcc86 authored by Iustin Pop's avatar Iustin Pop

Enable LUQueryInstances to work with a given list of instances

As per the changes to LUQueryNodes, the QueryInstances LU is modified to
accept a list of instances for which to compute and return information.

Reviewed-by: imsnah
parent 4a72cc75
......@@ -2091,7 +2091,7 @@ class LUQueryInstances(NoHooksLU):
"""Logical unit for querying instances.
"""
_OP_REQP = ["output_fields"]
_OP_REQP = ["output_fields", "names"]
def CheckPrereq(self):
"""Check prerequisites.
......@@ -2107,11 +2107,13 @@ class LUQueryInstances(NoHooksLU):
dynamic=self.dynamic_fields,
selected=self.op.output_fields)
self.wanted = _GetWantedInstances(self, self.op.names)
def Exec(self, feedback_fn):
"""Computes the list of nodes and their attributes.
"""
instance_names = utils.NiceSort(self.cfg.GetInstanceList())
instance_names = self.wanted
instance_list = [self.cfg.GetInstanceInfo(iname) for iname
in instance_names]
......
......@@ -202,7 +202,7 @@ class OpDeactivateInstanceDisks(OpCode):
class OpQueryInstances(OpCode):
"""Compute the list of instances."""
OP_ID = "OP_INSTANCE_QUERY"
__slots__ = ["output_fields"]
__slots__ = ["output_fields", "names"]
class OpQueryInstanceData(OpCode):
......
......@@ -41,7 +41,7 @@ def ListInstances(opts, args):
else:
selected_fields = opts.output.split(",")
op = opcodes.OpQueryInstances(output_fields=selected_fields)
op = opcodes.OpQueryInstances(output_fields=selected_fields, names=[])
output = SubmitOpCode(op)
if not opts.no_headers:
......
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