+ "--enabled-disk-templates=%s,%s" %
+ (default_disk_template, default_disk_template)],
+ fail=False)
+
+
+def _TestClusterModifyUsedDiskTemplate(instance_template,
+ enabled_disk_templates):
+ """Tests that disk templates that are currently in use by instances cannot
+ be disabled on the cluster.
+
+ """
+ # If the list of enabled disk templates contains only one template
+ # we need to add some other templates, because the list of enabled disk
+ # templates can only be set to a non-empty list.
+ new_disk_templates = list(set(enabled_disk_templates)
+ - set([instance_template]))
+ if not new_disk_templates:
+ new_disk_templates = list(set(constants.DISK_TEMPLATES)
+ - set([instance_template]))
+ AssertCommand(
+ ["gnt-cluster", "modify",
+ "--enabled-disk-templates=%s" %
+ ",".join(new_disk_templates)],
+ fail=True)
+
+
+def _TestClusterModifyUnusedDiskTemplate(instance_template):
+ """Tests that unused disk templates can be disabled safely."""
+ all_disk_templates = constants.DISK_TEMPLATES
+ AssertCommand(
+ ["gnt-cluster", "modify",
+ "--enabled-disk-templates=%s" %
+ ",".join(all_disk_templates)],
+ fail=False)
+ new_disk_templates = [instance_template]
+ AssertCommand(
+ ["gnt-cluster", "modify",
+ "--enabled-disk-templates=%s" %
+ ",".join(new_disk_templates)],