From 069dcc8621d219134bf93441f92774d42ec0c4cc Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 14 Sep 2007 09:54:22 +0000 Subject: [PATCH] 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 --- lib/cmdlib.py | 6 ++++-- lib/opcodes.py | 2 +- scripts/gnt-instance | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 1a1dcc857..e8379d64a 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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] diff --git a/lib/opcodes.py b/lib/opcodes.py index b75600c8b..c306ec39f 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -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): diff --git a/scripts/gnt-instance b/scripts/gnt-instance index bfbf59f7b..a408d74e3 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -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: -- GitLab