This property returns the nodes covered by a disk.

Signed-off-by: Ilias Tsitsimpis <[email protected]>
---
 lib/objects.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/objects.py b/lib/objects.py
index 874951e..2a4290d 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -537,6 +537,23 @@ class Disk(ConfigObject):
                # is sent to, and should not be persisted.
                ["dynamic_params"])
 
+  def _ComputeAllNodes(self):
+    """Compute the list of all nodes covered by a device and its children."""
+    nodes = list()
+
+    if self.dev_type in constants.DTS_DRBD:
+      nodea, nodeb = self.logical_id[:2]
+      nodes.append(nodea)
+      nodes.append(nodeb)
+    if self.children:
+      for child in self.children:
+        nodes.extend(child.all_nodes)
+
+    return tuple(set(nodes))
+
+  all_nodes = property(_ComputeAllNodes, None, None,
+                       "List of names of all the nodes of a disk")
+
   def CreateOnSecondary(self):
     """Test if this device needs to be created on a secondary node."""
     return self.dev_type in (constants.DT_DRBD8, constants.DT_PLAIN)
-- 
1.9.1

Reply via email to