Allow disk attachment to diskless instances
authorLisa Velden <velden@google.com>
Wed, 25 Nov 2015 15:00:45 +0000 (16:00 +0100)
committerLisa Velden <velden@google.com>
Thu, 26 Nov 2015 23:33:46 +0000 (00:33 +0100)
As only DRBD disks can be associated to more nodes than the instance
where we want to attach the disk to, we have to change the check for
associated nodes, too.

Signed-off-by: Lisa Velden <velden@google.com>
Reviewed-by: Oleg Ponomarev <oponomarev@google.com>

lib/cmdlib/instance_set_params.py

index 12d573a..7efb103 100644 (file)
@@ -390,15 +390,15 @@ class LUInstanceSetParams(LogicalUnit):
 
     disk = self.GenericGetDiskInfo(uuid, name)
     instance_template = self.cfg.GetInstanceDiskTemplate(self.instance.uuid)
-    if (disk.dev_type != instance_template or
-        instance_template == constants.DT_DISKLESS):
+    if (disk.dev_type != instance_template and
+        instance_template != constants.DT_DISKLESS):
       raise errors.OpPrereqError("Instance has '%s' template while disk has"
                                  " '%s' template" %
                                  (instance_template, disk.dev_type),
                                  errors.ECODE_INVAL)
 
     instance_nodes = self.cfg.GetInstanceNodes(self.instance.uuid)
-    if not set(disk.nodes).issubset(set(instance_nodes)):
+    if not set(instance_nodes).issubset(set(disk.nodes)):
       raise errors.OpPrereqError("Disk nodes are %s while the instance's nodes"
                                  " are %s" %
                                  (disk.nodes, instance_nodes),