From 0ea861546a4badaf9e1ac0f508348de7a04e0dd0 Mon Sep 17 00:00:00 2001
From: Klaus Aehlig <aehlig@google.com>
Date: Wed, 3 Apr 2013 17:16:09 +0200
Subject: [PATCH] Restrict instance move to templates based on local files

Moving an instance is done by copying over the disks. Restrict
this to disk templates that are copyable. This avoids accidental
use on, e.g., the sharedfile template.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>
---
 lib/cmdlib.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 3bf374235..3b8663d82 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -8388,6 +8388,10 @@ class LUInstanceMove(LogicalUnit):
     assert self.instance is not None, \
       "Cannot retrieve locked instance %s" % self.op.instance_name
 
+    if instance.disk_template not in constants.DTS_COPYABLE:
+      raise errors.OpPrereqError("Disk template %s not suitable for copying" %
+                                 instance.disk_template, errors.ECODE_STATE)
+
     node = self.cfg.GetNodeInfo(self.op.target_node)
     assert node is not None, \
       "Cannot retrieve locked node %s" % self.op.target_node
-- 
GitLab