From 27263c472347a6af7a6335722ebb6f3eea06a671 Mon Sep 17 00:00:00 2001
From: Helga Velroyen <helgav@google.com>
Date: Fri, 22 Mar 2013 11:31:46 +0100
Subject: [PATCH] gnt-cluster modify: limit storage type consistency check

This fixes the currently broken Q&A. The consistency check
for storage types is now only run when the 'enabled_storage_types'
are actually changed by 'gnt-cluster modify'.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/cmdlib.py | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 0e6fb066b..1c0ad2109 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -4437,20 +4437,21 @@ class LUClusterSetParams(LogicalUnit):
        are still in use by some instances.
 
     """
-    cluster = self.cfg.GetClusterInfo()
-    instances = self.cfg.GetAllInstancesInfo()
-
-    storage_types_to_remove = set(cluster.enabled_storage_types) \
-      - set(self.op.enabled_storage_types)
-    for instance in instances.itervalues():
-      storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[
-                       instance.disk_template]
-      if storage_type in storage_types_to_remove:
-        raise errors.OpPrereqError("Cannot disable storage type '%s',"
-                                   " because instance '%s' is using disk"
-                                   " template '%s'." %
-                                   (storage_type, instance.name,
-                                    instance.disk_template))
+    if self.op.enabled_storage_types:
+      cluster = self.cfg.GetClusterInfo()
+      instances = self.cfg.GetAllInstancesInfo()
+
+      storage_types_to_remove = set(cluster.enabled_storage_types) \
+        - set(self.op.enabled_storage_types)
+      for instance in instances.itervalues():
+        storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[
+                         instance.disk_template]
+        if storage_type in storage_types_to_remove:
+          raise errors.OpPrereqError("Cannot disable storage type '%s',"
+                                     " because instance '%s' is using disk"
+                                     " template '%s'." %
+                                     (storage_type, instance.name,
+                                      instance.disk_template))
 
   def Exec(self, feedback_fn):
     """Change the parameters of the cluster.
-- 
GitLab