From 38156f68fc8a0622f2082305557ac647e6a291ef Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 25 Nov 2010 13:40:30 +0000
Subject: [PATCH] Fix per-vg checks in instance disk conversion

Since we now have just two possibilities (plaint to drbd or drbd to
plain), we can assume (+an assert) that we come from LVM and access
directly logical_id[0] for the VG on which it is stored.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/cmdlib.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 7cc79431b..21c49dc66 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -9264,7 +9264,10 @@ class LUSetInstanceParams(LogicalUnit):
                                      self.op.remote_node, errors.ECODE_STATE)
         _CheckNodeOnline(self, self.op.remote_node)
         _CheckNodeNotDrained(self, self.op.remote_node)
-        disks = [{"size": d.size, "vg": d.vg} for d in instance.disks]
+        # FIXME: here we assume that the old instance type is DT_PLAIN
+        assert instance.disk_template == constants.DT_PLAIN
+        disks = [{"size": d.size, "vg": d.logical_id[0]}
+                 for d in instance.disks]
         required = _ComputeDiskSizePerVG(self.op.disk_template, disks)
         _CheckNodesFreeDiskPerVG(self, [self.op.remote_node], required)
 
-- 
GitLab