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(): ...@@ -425,13 +425,14 @@ def _RestoreEnabledDiskTemplates():
other tests. other tests.
""" """
vgname = qa_config.get("vg-name", constants.DEFAULT_VG) cmd = ["gnt-cluster", "modify", "--enabled-disk-templates=%s" %
AssertCommand( ",".join(qa_config.GetEnabledDiskTemplates())]
["gnt-cluster", "modify",
"--enabled-disk-templates=%s" % if utils.IsLvmEnabled(qa_config.GetEnabledDiskTemplates()):
",".join(qa_config.GetEnabledDiskTemplates()), vgname = qa_config.get("vg-name", constants.DEFAULT_VG)
"--vg-name=%s" % vgname], cmd.append("--vg-name=%s" % vgname)
fail=False)
AssertCommand(cmd, fail=False)
def _TestClusterModifyDiskTemplatesArguments(default_disk_template, def _TestClusterModifyDiskTemplatesArguments(default_disk_template,
...@@ -568,7 +569,7 @@ def _TestClusterModifyUsedDiskTemplate(instance_template, ...@@ -568,7 +569,7 @@ def _TestClusterModifyUsedDiskTemplate(instance_template,
new_disk_templates = list(set(enabled_disk_templates) new_disk_templates = list(set(enabled_disk_templates)
- set([instance_template])) - set([instance_template]))
if not new_disk_templates: 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])) - set([instance_template]))
AssertCommand( AssertCommand(
["gnt-cluster", "modify", ["gnt-cluster", "modify",
...@@ -580,6 +581,10 @@ def _TestClusterModifyUsedDiskTemplate(instance_template, ...@@ -580,6 +581,10 @@ def _TestClusterModifyUsedDiskTemplate(instance_template,
def _TestClusterModifyUnusedDiskTemplate(instance_template): def _TestClusterModifyUnusedDiskTemplate(instance_template):
"""Tests that unused disk templates can be disabled safely.""" """Tests that unused disk templates can be disabled safely."""
all_disk_templates = constants.DISK_TEMPLATES 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( AssertCommand(
["gnt-cluster", "modify", ["gnt-cluster", "modify",
"--enabled-disk-templates=%s" % "--enabled-disk-templates=%s" %
......
...@@ -1047,11 +1047,14 @@ def TestInstanceCreationRestrictedByDiskTemplates(): ...@@ -1047,11 +1047,14 @@ def TestInstanceCreationRestrictedByDiskTemplates():
CreateInstanceByDiskTemplate(nodes, disk_template, fail=True) CreateInstanceByDiskTemplate(nodes, disk_template, fail=True)
elif (len(enabled_disk_templates) == 1): elif (len(enabled_disk_templates) == 1):
# If only one disk template is enabled in the QA config, we have to enable # 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 # some other templates in order to test if the disabling the only enabled
# only enabled disk template prohibits creating instances of that template. # 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", AssertCommand(["gnt-cluster", "modify",
"--enabled-disk-template=%s" % "--enabled-disk-template=%s" %
",".join(disabled_disk_templates)], ",".join(other_disk_templates)],
fail=False) fail=False)
CreateInstanceByDiskTemplate(nodes, enabled_disk_templates[0], fail=True) CreateInstanceByDiskTemplate(nodes, enabled_disk_templates[0], fail=True)
else: 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