Commit d101b7be authored by Thomas Thrainer's avatar Thomas Thrainer

Unset LV name if no LVM disk templates are enabled

If there are no LVM based disk templates enabled in QA, reset the LV
name after the corresponding gnt-cluster modify tests. Otherwise
gnt-cluster verify would complain about the missing volume group.

Also make sure that no disk templates requiring LVM are ever enabled
without actually providing a LV name.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 0c2cfb97
......@@ -425,13 +425,14 @@ def _RestoreEnabledDiskTemplates():
other tests.
"""
cmd = ["gnt-cluster", "modify", "--enabled-disk-templates=%s" %
",".join(qa_config.GetEnabledDiskTemplates())]
if utils.IsLvmEnabled(qa_config.GetEnabledDiskTemplates()):
vgname = qa_config.get("vg-name", constants.DEFAULT_VG)
AssertCommand(
["gnt-cluster", "modify",
"--enabled-disk-templates=%s" %
",".join(qa_config.GetEnabledDiskTemplates()),
"--vg-name=%s" % vgname],
fail=False)
cmd.append("--vg-name=%s" % vgname)
AssertCommand(cmd, fail=False)
def _TestClusterModifyDiskTemplatesArguments(default_disk_template,
......@@ -568,7 +569,7 @@ def _TestClusterModifyUsedDiskTemplate(instance_template,
new_disk_templates = list(set(enabled_disk_templates)
- set([instance_template]))
if not new_disk_templates:
new_disk_templates = list(set(constants.DISK_TEMPLATES)
new_disk_templates = list(set([constants.DT_DISKLESS, constants.DT_BLOCK])
- set([instance_template]))
AssertCommand(
["gnt-cluster", "modify",
......@@ -580,6 +581,10 @@ def _TestClusterModifyUsedDiskTemplate(instance_template,
def _TestClusterModifyUnusedDiskTemplate(instance_template):
"""Tests that unused disk templates can be disabled safely."""
all_disk_templates = constants.DISK_TEMPLATES
if not utils.IsLvmEnabled(qa_config.GetEnabledDiskTemplates()):
all_disk_templates = list(set(all_disk_templates) -
set(utils.GetLvmDiskTemplates()))
AssertCommand(
["gnt-cluster", "modify",
"--enabled-disk-templates=%s" %
......
......@@ -1047,11 +1047,14 @@ def TestInstanceCreationRestrictedByDiskTemplates():
CreateInstanceByDiskTemplate(nodes, disk_template, fail=True)
elif (len(enabled_disk_templates) == 1):
# If only one disk template is enabled in the QA config, we have to enable
# some of the disabled disk templates in order to test if the disabling the
# only enabled disk template prohibits creating instances of that template.
# some other templates in order to test if the disabling the only enabled
# disk template prohibits creating instances of that template.
other_disk_templates = list(
set([constants.DT_DISKLESS, constants.DT_BLOCK]) -
set(enabled_disk_templates))
AssertCommand(["gnt-cluster", "modify",
"--enabled-disk-template=%s" %
",".join(disabled_disk_templates)],
",".join(other_disk_templates)],
fail=False)
CreateInstanceByDiskTemplate(nodes, enabled_disk_templates[0], fail=True)
else:
......
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