Commit 5d55819e authored by Iustin Pop's avatar Iustin Pop
Browse files

Abstract disk template verification

This is a simple check, but we'll need it in multiple places.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 17227cd1
......@@ -542,6 +542,16 @@ def _CheckNodeNotDrained(lu, node):
def _CheckDiskTemplate(template):
"""Ensure a given disk template is valid.
if template not in constants.DISK_TEMPLATES:
msg = ("Invalid disk template name '%s', valid templates are: %s" %
(template, utils.CommaJoin(constants.DISK_TEMPLATES)))
raise errors.OpPrereqError(msg, errors.ECODE_INVAL)
def _ExpandItemName(fn, name, kind):
"""Expand an item name.
......@@ -5845,9 +5855,7 @@ class LUCreateInstance(LogicalUnit):
self.op.mode, errors.ECODE_INVAL)
# disk template and mirror node verification
if self.op.disk_template not in constants.DISK_TEMPLATES:
raise errors.OpPrereqError("Invalid disk template name",
if self.op.hypervisor is None:
self.op.hypervisor = self.cfg.GetHypervisorType()
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