Consistency checks for config wrt disk templates
authorHelga Velroyen <helgav@google.com>
Wed, 27 Mar 2013 15:02:47 +0000 (16:02 +0100)
committerHelga Velroyen <helgav@google.com>
Thu, 11 Apr 2013 20:53:45 +0000 (22:53 +0200)
This patch adds consistency checks for the configuration regarding
disk templates. In particular, it checks that the list of enabled
disk templates is not empty, does not contain any bogus templates,
and that all instances use actually enabled disk templates.
Additionally, it fixes a small formatting issue regarding the list
of enabled hypervisors.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Michele Tartara <mtarara@google.com>

lib/config.py

index 58f6657..050cdac 100644 (file)
@@ -577,13 +577,21 @@ class ConfigWriter:
     invalid_hvs = set(cluster.enabled_hypervisors) - constants.HYPER_TYPES
     if invalid_hvs:
       result.append("enabled hypervisors contains invalid entries: %s" %
-                    invalid_hvs)
+                    utils.CommaJoin(invalid_hvs))
     missing_hvp = (set(cluster.enabled_hypervisors) -
                    set(cluster.hvparams.keys()))
     if missing_hvp:
       result.append("hypervisor parameters missing for the enabled"
                     " hypervisor(s) %s" % utils.CommaJoin(missing_hvp))
 
+    if not cluster.enabled_disk_templates:
+      result.append("enabled disk templates list doesn't have any entries")
+    invalid_disk_templates = set(cluster.enabled_disk_templates) \
+                               - constants.DISK_TEMPLATES
+    if invalid_disk_templates:
+      result.append("enabled disk templates list contains invalid entries:"
+                    " %s" % utils.CommaJoin(invalid_disk_templates))
+
     if cluster.master_node not in data.nodes:
       result.append("cluster has invalid primary node '%s'" %
                     cluster.master_node)
@@ -663,6 +671,11 @@ class ConfigWriter:
                   filled, constants.NICS_PARAMETER_TYPES)
           _helper_nic(owner, filled)
 
+      # disk template checks
+      if not instance.disk_template in data.cluster.enabled_disk_templates:
+        result.append("instance '%s' uses the disabled disk template '%s'." %
+                      (instance_name, instance.disk_template))
+
       # parameter checks
       if instance.beparams:
         _helper("instance %s" % instance.name, "beparams",