diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 80282df551c26f767bbc0117c2b1e68c25ef40c4..9855aedb15d7848a60351d26eebf48e72dcebe32 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -10154,6 +10154,14 @@ class LUInstanceCreate(LogicalUnit): for nic in self.op.nics: utils.ForceDictType(nic, constants.INIC_PARAMS_TYPES) + cluster = self.cfg.GetClusterInfo() + if not self.op.disk_template in cluster.enabled_disk_templates: + raise errors.OpPrereqError("Cannot create an instance with disk template" + " '%s', because it is not enabled in the" + " cluster. Enabled disk templates are: %s." % + (self.op.disk_template, + ",".join(cluster.enabled_disk_templates))) + # check disks. parameter names and consistent adopt/no-adopt strategy has_adopt = has_no_adopt = False for disk in self.op.disks: