From eedc99de10c1771685034489b1b63e45e4232869 Mon Sep 17 00:00:00 2001
From: Manuel Franceschini <manuel.franceschini@gmail.com>
Date: Mon, 31 Mar 2008 10:57:58 +0000
Subject: [PATCH] Add lvm-storage check when creating instances

This adds a check to fail instance creation if lvm-storage is disabled
(cluster-wide). If lvm-storage is disabled (by initializing the cluster
with --no-lvm-storage) only instances with disk template in frozenset
DTS_NOT_LVM are allowed to create.

Reviewed-by: iustinp
---
 lib/cmdlib.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 9cbe8ab05..1712c88fc 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -2853,6 +2853,11 @@ class LUCreateInstance(LogicalUnit):
       raise errors.OpPrereqError("Invalid instance creation mode '%s'" %
                                  self.op.mode)
 
+    if (not self.cfg.GetVGName() and
+        self.op.disk_template not in constants.DTS_NOT_LVM):
+      raise errors.OpPrereqError("Cluster does not support lvm-based"
+                                 " instances")
+
     if self.op.mode == constants.INSTANCE_IMPORT:
       src_node = getattr(self.op, "src_node", None)
       src_path = getattr(self.op, "src_path", None)
-- 
GitLab