Merge branch 'stable-2.6' into devel-2.6
[ganeti-local] / lib / bdev.py
index ee31220..1d85867 100644 (file)
@@ -1058,7 +1058,7 @@ class BaseDRBD(BlockDev): # pylint: disable=W0223
   def _CheckMetaSize(meta_device):
     """Check if the given meta device looks like a valid one.
 
-    This currently only check the size, which must be around
+    This currently only checks the size, which must be around
     128MiB.
 
     """
@@ -1098,10 +1098,10 @@ class DRBD8(BaseDRBD):
   doesn't do anything to the supposed peer. If you need a fully
   connected DRBD pair, you need to use this class on both hosts.
 
-  The unique_id for the drbd device is the (local_ip, local_port,
-  remote_ip, remote_port) tuple, and it must have two children: the
-  data device and the meta_device. The meta device is checked for
-  valid size and is zeroed on create.
+  The unique_id for the drbd device is a (local_ip, local_port,
+  remote_ip, remote_port, local_minor, secret) tuple, and it must have
+  two children: the data device and the meta_device. The meta device
+  is checked for valid size and is zeroed on create.
 
   """
   _MAX_MINORS = 255
@@ -1197,7 +1197,7 @@ class DRBD8(BaseDRBD):
   def _GetShowParser(cls):
     """Return a parser for `drbd show` output.
 
-    This will either create or return an already-create parser for the
+    This will either create or return an already-created parser for the
     output of the command `drbd show`.
 
     """
@@ -1633,7 +1633,7 @@ class DRBD8(BaseDRBD):
       msg = ("Can't change syncer rate: %s - %s" %
              (result.fail_reason, result.output))
       logging.error(msg)
-      return msg
+      return [msg]
 
     return []
 
@@ -2653,6 +2653,16 @@ def _VerifyDiskType(dev_type):
     raise errors.ProgrammerError("Invalid block device type '%s'" % dev_type)
 
 
+def _VerifyDiskParams(disk):
+  """Verifies if all disk parameters are set.
+
+  """
+  missing = set(constants.DISK_LD_DEFAULTS[disk.dev_type]) - set(disk.params)
+  if missing:
+    raise errors.ProgrammerError("Block device is missing disk parameters: %s" %
+                                 missing)
+
+
 def FindDevice(disk, children):
   """Search for an existing, assembled device.
 
@@ -2667,10 +2677,8 @@ def FindDevice(disk, children):
 
   """
   _VerifyDiskType(disk.dev_type)
-  dev_params = objects.FillDict(constants.DISK_LD_DEFAULTS[disk.dev_type],
-                                disk.params)
   device = DEV_MAP[disk.dev_type](disk.physical_id, children, disk.size,
-                                  dev_params)
+                                  disk.params)
   if not device.attached:
     return None
   return device
@@ -2690,10 +2698,9 @@ def Assemble(disk, children):
 
   """
   _VerifyDiskType(disk.dev_type)
-  dev_params = objects.FillDict(constants.DISK_LD_DEFAULTS[disk.dev_type],
-                                disk.params)
+  _VerifyDiskParams(disk)
   device = DEV_MAP[disk.dev_type](disk.physical_id, children, disk.size,
-                                  dev_params)
+                                  disk.params)
   device.Assemble()
   return device
 
@@ -2709,8 +2716,7 @@ def Create(disk, children):
 
   """
   _VerifyDiskType(disk.dev_type)
-  dev_params = objects.FillDict(constants.DISK_LD_DEFAULTS[disk.dev_type],
-                                disk.params)
+  _VerifyDiskParams(disk)
   device = DEV_MAP[disk.dev_type].Create(disk.physical_id, children, disk.size,
-                                         dev_params)
+                                         disk.params)
   return device