Commit bfbffd55 authored by Helga Velroyen's avatar Helga Velroyen

GenerateDiskTemplate: Proper check for valid disk templates

This patch makes an FileStorageError to be risen with a
proper error message instead of just an assertion in case
the given disk template is not a valid disk template at
all.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 8520f4b9
......@@ -1079,7 +1079,11 @@ def CheckDiskTemplateEnabled(cluster, disk_template):
"""
assert disk_template is not None
assert disk_template in constants.DISK_TEMPLATES
if disk_template not in constants.DISK_TEMPLATES:
raise errors.OpPrereqError("'%s' is not a valid disk template."
" Valid disk templates are: %s" %
(disk_template,
",".join(constants.DISK_TEMPLATES)))
if not disk_template in cluster.enabled_disk_templates:
raise errors.OpPrereqError("Disk template '%s' is not enabled in cluster."
" Enabled disk templates are: %s" %
......
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