Properly add the UUID to all the disks
authorMichele Tartara <mtartara@google.com>
Thu, 25 Jul 2013 14:00:17 +0000 (14:00 +0000)
committerMichele Tartara <mtartara@google.com>
Thu, 25 Jul 2013 15:24:54 +0000 (15:24 +0000)
Starting from Ganeti 2.8 all the disks need to have a UUID.
A function for adding a UUID automatically to disks was present, but it didn't
consider disks with children (like DRBD).

The function is modified to work recursively.

Partially fixes Issue 510.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

lib/config.py

index 38316ad..ec93244 100644 (file)
@@ -446,12 +446,23 @@ class ConfigWriter:
     return lvnames
 
   def _AllDisks(self):
-    """Compute the list of all Disks.
+    """Compute the list of all Disks (recursively, including children).
 
     """
+    def DiskAndAllChildren(disk):
+      """Returns a list containing the given disk and all of his children.
+
+      """
+      disks = [disk]
+      if disk.children:
+        for child_disk in disk.children:
+          disks.extend(DiskAndAllChildren(child_disk))
+      return disks
+
     disks = []
     for instance in self._config_data.instances.values():
-      disks.extend(instance.disks)
+      for disk in instance.disks:
+        disks.extend(DiskAndAllChildren(disk))
     return disks
 
   def _AllNICs(self):