Add a way to export all node information at once
authorIustin Pop <iustin@google.com>
Wed, 10 Sep 2008 11:02:45 +0000 (11:02 +0000)
committerIustin Pop <iustin@google.com>
Wed, 10 Sep 2008 11:02:45 +0000 (11:02 +0000)
The patch adds a new function to export all node information at once
(i.e. atomically with respect to the configuration lock).

Reviewed-by: ultrotter

lib/config.py

index adf57f3..510ddd4 100644 (file)
@@ -539,6 +539,19 @@ class ConfigWriter:
     return self._UnlockedGetNodeList()
 
   @locking.ssynchronized(_config_lock, shared=1)
+  def GetAllNodesInfo(self):
+    """Get the configuration of all nodes.
+
+    @rtype: dict
+    @returns: dict of (node, node_info), where node_info is what
+              would GetNodeInfo return for the node
+
+    """
+    my_dict = dict([(node, self._UnlockedGetNodeInfo(node))
+                    for node in self._UnlockedGetNodeList()])
+    return my_dict
+
+  @locking.ssynchronized(_config_lock, shared=1)
   def DumpConfig(self):
     """Return the entire configuration of the cluster.
     """