Remove superflous loop in instance queries
authorHelga Velroyen <helgav@google.com>
Thu, 10 Jul 2014 07:59:33 +0000 (09:59 +0200)
committerHelga Velroyen <helgav@google.com>
Thu, 10 Jul 2014 08:13:40 +0000 (10:13 +0200)
This patch fixes a piece of convoluted code in the
implementation of instance queries. There was an
unecessarily nested loop, which in case of ongoing
migrations, could throw a key error. This fixes
issue 875.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/cmdlib/instance_query.py

index 2d66acd..5415b89 100644 (file)
@@ -137,8 +137,8 @@ class InstanceQuery(QueryBase):
             if inst_name in insts_by_name:
               instance = insts_by_name[inst_name]
               if instance.primary_node == node_uuid:
-                for iname in result.payload:
-                  live_data[insts_by_name[iname].uuid] = result.payload[iname]
+                live_data[insts_by_name[inst_name].uuid] = \
+                  result.payload[inst_name]
               else:
                 wrongnode_inst_uuids.add(instance.uuid)
             else: