commit 02cff8aaa9b5517f3648d39d5a0bbc66e1873fc3
Author: Bernardo Dal Seno <bdalseno@google.com>
Date:   Sun Apr 14 16:25:45 2013 +0200

    QA: Decision about disk templates to use is more modular
    
    qa_config.IsTemplateSupported() is already used to decide which disk
    templates are supported by QA. Enabled templates now are part of that
    decision.
    
    Unit tests are updated.
    
    Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
    Reviewed-by: Guido Trotter <ultrotter@google.com>

diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index 5f1c4a8..25af5c0 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -577,21 +577,16 @@ def TestIPolicyPlainInstance():
 
 def RunInstanceTests():
   """Create and exercise instances."""
-  instance_tests = []
-  enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
-  # FIXME: Refactor this to make the code more elegant wrt to disk templates.
-  if constants.DT_PLAIN in enabled_disk_templates:
-    instance_tests.append(("instance-add-plain-disk", constants.DT_PLAIN,
-                           qa_instance.TestInstanceAddWithPlainDisk, 1))
-  if constants.DT_DRBD8 in enabled_disk_templates:
-    instance_tests.append(("instance-add-drbd-disk", constants.DT_DRBD8,
-                           qa_instance.TestInstanceAddWithDrbdDisk, 2))
-  if constants.DT_DISKLESS in enabled_disk_templates:
-    instance_tests.append(("instance-add-diskless", constants.DT_DISKLESS,
-                           qa_instance.TestInstanceAddDiskless, 1))
-  if constants.DT_FILE in enabled_disk_templates:
-    instance_tests.append(("instance-add-file", constants.DT_FILE,
-                           qa_instance.TestInstanceAddFile, 1))
+  instance_tests = [
+    ("instance-add-plain-disk", constants.DT_PLAIN,
+     qa_instance.TestInstanceAddWithPlainDisk, 1),
+    ("instance-add-drbd-disk", constants.DT_DRBD8,
+     qa_instance.TestInstanceAddWithDrbdDisk, 2),
+    ("instance-add-diskless", constants.DT_DISKLESS,
+     qa_instance.TestInstanceAddDiskless, 1),
+    ("instance-add-file", constants.DT_FILE,
+     qa_instance.TestInstanceAddFile, 1)
+    ]
 
   for (test_name, templ, create_fun, num_nodes) in instance_tests:
     if (qa_config.TestEnabled(test_name) and
diff --git a/qa/qa_config.py b/qa/qa_config.py
index e8f2789..1c6a543 100644
--- a/qa/qa_config.py
+++ b/qa/qa_config.py
@@ -412,8 +412,9 @@ class _QaConfig(object):
     """Is the given disk template supported by the current configuration?
 
     """
-    return (not self.GetExclusiveStorage() or
-            templ in constants.DTS_EXCL_STORAGE)
+    enabled = templ in self.GetEnabledDiskTemplates()
+    return enabled and (not self.GetExclusiveStorage() or
+                        templ in constants.DTS_EXCL_STORAGE)
 
   def GetVclusterSettings(self):
     """Returns settings for virtual cluster.
@@ -608,7 +609,7 @@ def GetExclusiveStorage():
 
 
 def IsTemplateSupported(templ):
-  """Wrapper for L{_QaConfig.GetExclusiveStorage}.
+  """Wrapper for L{_QaConfig.IsTemplateSupported}.
 
   """
   return GetConfig().IsTemplateSupported(templ)
diff --git a/test/data/qa-minimal-nodes-instances-only.json b/test/data/qa-minimal-nodes-instances-only.json
index 38b51b5..6a5578e 100644
--- a/test/data/qa-minimal-nodes-instances-only.json
+++ b/test/data/qa-minimal-nodes-instances-only.json
@@ -4,6 +4,12 @@
   "disk": ["1G", "512M"],
   "disk-growth": ["2G", "768M"],
 
+  "enabled-disk-templates": [
+    "plain",
+    "drbd",
+    "diskless"
+  ],
+
   "nodes": [
     {
       "# Master node": null,
diff --git a/test/py/qa.qa_config_unittest.py b/test/py/qa.qa_config_unittest.py
index 5e41558..bb27dde 100755
--- a/test/py/qa.qa_config_unittest.py
+++ b/test/py/qa.qa_config_unittest.py
@@ -308,8 +308,13 @@ class TestQaConfig(unittest.TestCase):
       self.config.SetExclusiveStorage(value)
       self.assertEqual(self.config.GetExclusiveStorage(), bool(value))
 
+  def testIsTemplateSupported(self):
+    enabled_dts = self.config.GetEnabledDiskTemplates()
+    for e_s in [False, True]:
+      self.config.SetExclusiveStorage(e_s)
       for template in constants.DISK_TEMPLATES:
-        if value and template not in constants.DTS_EXCL_STORAGE:
+        if (template not in enabled_dts or
+            e_s and template not in constants.DTS_EXCL_STORAGE):
           self.assertFalse(self.config.IsTemplateSupported(template))
         else:
           self.assertTrue(self.config.IsTemplateSupported(template))
