Commit 3da6e141 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Consistency checks for config wrt disk templates



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: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarMichele Tartara <mtarara@google.com>
parent 6f665bf7
......@@ -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",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment