Commit ccfa86ba authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cli: Replace hardcoded strings with constants

Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent c352b0a9
......@@ -2045,7 +2045,7 @@ def GenericInstanceCreate(mode, opts, args):
raise errors.OpPrereqError("Please use either the '--disk' or"
" '-s' option")
if opts.sd_size is not None:
opts.disks = [(0, {"size": opts.sd_size})]
opts.disks = [(0, {constants.IDISK_SIZE: opts.sd_size})]
if opts.disks:
......@@ -2060,20 +2060,21 @@ def GenericInstanceCreate(mode, opts, args):
if not isinstance(ddict, dict):
msg = "Invalid disk/%d value: expected dict, got %s" % (didx, ddict)
raise errors.OpPrereqError(msg)
elif "size" in ddict:
if "adopt" in ddict:
elif constants.IDISK_SIZE in ddict:
if constants.IDISK_ADOPT in ddict:
raise errors.OpPrereqError("Only one of 'size' and 'adopt' allowed"
" (disk %d)" % didx)
ddict["size"] = utils.ParseUnit(ddict["size"])
ddict[constants.IDISK_SIZE] = \
except ValueError, err:
raise errors.OpPrereqError("Invalid disk size for disk %d: %s" %
(didx, err))
elif "adopt" in ddict:
elif constants.IDISK_ADOPT in ddict:
if mode == constants.INSTANCE_IMPORT:
raise errors.OpPrereqError("Disk adoption not allowed for instance"
" import")
ddict["size"] = 0
ddict[constants.IDISK_SIZE] = 0
raise errors.OpPrereqError("Missing size or adoption source for"
" disk %d" % didx)
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