diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 51e3941e6ad6cd12303f08a29663a444ccaf8663..2af052b2749b19fb8230f6102560a257e45b6212 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -6391,9 +6391,10 @@ class LUCreateInstance(LogicalUnit): raise errors.OpPrereqError("Either all disks are adopted or none is", errors.ECODE_INVAL) if has_adopt: - if self.op.disk_template != constants.DT_PLAIN: - raise errors.OpPrereqError("Disk adoption is only supported for the" - " 'plain' disk template", + if self.op.disk_template not in constants.DTS_MAY_ADOPT: + raise errors.OpPrereqError("Disk adoption is not supported for the" + " '%s' disk template" % + self.op.disk_template, errors.ECODE_INVAL) if self.op.iallocator is not None: raise errors.OpPrereqError("Disk adoption not allowed with an" diff --git a/lib/constants.py b/lib/constants.py index 1f91ce54d7abfed4267f8d120d8cf781ba7e0f6a..b7cda08d960911a8ab7d81ff31bcb0f9bf11ed5f 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -325,6 +325,9 @@ DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE]) # the set of disk templates which can be grown DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE]) +# the set of disk templates that allow adoption +DTS_MAY_ADOPT = frozenset([DT_PLAIN]) + # logical disk types LD_LV = "lvm" LD_DRBD8 = "drbd8"