From 0b2de75812246d6055d3bc2b0f62bc2d77cdb040 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 10 Sep 2008 17:07:03 +0000
Subject: [PATCH] Add an atomic ConfigWrite.GetAllInstanceInfo()

In order to be able to query instance without locking them, we need the
same atomic query of multiple instances as for nodes.

Reviewed-by: ultrotter
---
 lib/config.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/config.py b/lib/config.py
index f1c9bf228..f939ecff9 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -469,6 +469,19 @@ class ConfigWriter:
     """
     return self._UnlockedGetInstanceInfo(instance_name)
 
+  @locking.ssynchronized(_config_lock, shared=1)
+  def GetAllInstancesInfo(self):
+    """Get the configuration of all instances.
+
+    @rtype: dict
+    @returns: dict of (instance, instance_info), where instance_info is what
+              would GetInstanceInfo return for the node
+
+    """
+    my_dict = dict([(node, self._UnlockedGetInstanceInfo(node))
+                    for node in self._UnlockedGetInstanceList()])
+    return my_dict
+
   @locking.ssynchronized(_config_lock)
   def AddNode(self, node):
     """Add a node to the configuration.
-- 
GitLab