Commit 112050d9 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix instance creation

This patch fixes the diskless and drbd/file based instances. Sorry :(

Reviewed-by: ultrotter
parent 1cb8d376
......@@ -3171,6 +3171,7 @@ def _GenerateDiskTemplate(lu, template_name,
for s in ("data", "meta")
])
for idx, disk in enumerate(disk_info):
disk_index = idx + base_index
disk_dev = _GenerateDRBD8Branch(lu, primary_node, remote_node,
disk["size"], names[idx*2:idx*2+2],
"disk/%d" % disk_index,
......@@ -3181,7 +3182,7 @@ def _GenerateDiskTemplate(lu, template_name,
raise errors.ProgrammerError("Wrong template configuration")
for idx, disk in enumerate(disk_info):
disk_index = idx + base_index
disk_dev = objects.Disk(dev_type=constants.LD_FILE, size=disk["size"],
iv_name="disk/%d" % disk_index,
logical_id=(file_driver,
......
......@@ -306,11 +306,14 @@ def AddInstance(opts, args):
# default of one nic, all auto
nics = [{}]
if not opts.disks and opts.disk_template != constants.DT_DISKLESS:
raise errors.OpPrereqError("No disk information specified")
elif opts.disks and opts.disk_template == constants.DT_DISKLESS:
raise errors.OpPrereqError("Diskless instance but disk information passeD")
if opts.disk_template == constants.DT_DISKLESS:
if opts.disks:
raise errors.OpPrereqError("Diskless instance but disk"
" information passed")
disks = []
else:
if not opts.disks:
raise errors.OpPrereqError("No disk information specified")
try:
disk_max = max(int(didx[0])+1 for didx in opts.disks)
except ValueError, err:
......
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