From 3da6e141274cc233732aa7e0e8b5b743b79400a7 Mon Sep 17 00:00:00 2001 From: Helga Velroyen <helgav@google.com> Date: Wed, 27 Mar 2013 16:02:47 +0100 Subject: [PATCH] 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: Helga Velroyen <helgav@google.com> Reviewed-by: Michele Tartara <mtarara@google.com> --- lib/config.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/config.py b/lib/config.py index 58f665764..050cdacef 100644 --- a/lib/config.py +++ b/lib/config.py @@ -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", -- GitLab