From 1a1296c87bb6a66839c09150bd6f0cfff82ebf19 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 30 Jun 2010 18:19:30 +0100
Subject: [PATCH] Fix check in gnt-instance modify -t

Currently when changing the instance disks the instance status (which
must be down) is only checked if the target status is among the mirrored
ones. This is incorrect: the instance must be down either way, even if
the desired final status is non-mirrored.

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

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 6ce84133c..05f26497d 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -8407,13 +8407,13 @@ class LUSetInstanceParams(LogicalUnit):
                                    " %s to %s" % (instance.disk_template,
                                                   self.op.disk_template),
                                    errors.ECODE_INVAL)
+      _CheckInstanceDown(self, instance, "cannot change disk template")
       if self.op.disk_template in constants.DTS_NET_MIRROR:
         _CheckNodeOnline(self, self.op.remote_node)
         _CheckNodeNotDrained(self, self.op.remote_node)
         disks = [{"size": d.size} for d in instance.disks]
         required = _ComputeDiskSize(self.op.disk_template, disks)
         _CheckNodesFreeDisk(self, [self.op.remote_node], required)
-        _CheckInstanceDown(self, instance, "cannot change disk template")
 
     # hvparams processing
     if self.op.hvparams:
-- 
GitLab