Commit 3473fb81 authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Use raw disks in import/export when OS scripts are absent



When an instance does not have OS scripts because, for example, it has
an OS image, then the import/export should not try to run the OS
scripts.  Instead, it should use raw import/export.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 6646c1f5
......@@ -1552,11 +1552,17 @@ class LUInstanceCreate(LogicalUnit):
if not image:
continue
if iobj.os:
dst_io = constants.IEIO_SCRIPT
dst_ioargs = ((iobj.disks[idx], iobj), idx)
else:
dst_io = constants.IEIO_RAW_DISK
dst_ioargs = (iobj.disks[idx], iobj)
# FIXME: pass debug option from opcode to backend
dt = masterd.instance.DiskTransfer("disk/%s" % idx,
constants.IEIO_FILE, (image, ),
constants.IEIO_SCRIPT,
((iobj.disks[idx], iobj), idx),
dst_io, dst_ioargs,
None)
transfers.append(dt)
......
......@@ -1244,9 +1244,16 @@ class ExportInstanceHelper:
finished_fn = compat.partial(self._TransferFinished, idx)
if instance.os:
src_io = constants.IEIO_SCRIPT
src_ioargs = ((dev, instance), idx)
else:
src_io = constants.IEIO_RAW_DISK
src_ioargs = (dev, instance)
# FIXME: pass debug option from opcode to backend
dt = DiskTransfer("snapshot/%s" % idx,
constants.IEIO_SCRIPT, ((dev, instance), idx),
src_io, src_ioargs,
constants.IEIO_FILE, (path, ),
finished_fn)
transfers.append(dt)
......@@ -1305,11 +1312,18 @@ class ExportInstanceHelper:
compress=compress,
ipv6=ipv6)
if instance.os:
src_io = constants.IEIO_SCRIPT
src_ioargs = ((dev, instance), idx)
else:
src_io = constants.IEIO_RAW_DISK
src_ioargs = (dev, instance)
self._feedback_fn("Sending disk %s to %s:%s" % (idx, host, port))
finished_fn = compat.partial(self._TransferFinished, idx)
ieloop.Add(DiskExport(self._lu, instance.primary_node,
opts, host, port, instance, "disk%d" % idx,
constants.IEIO_SCRIPT, ((dev, instance), idx),
src_io, src_ioargs,
timeouts, cbs, private=(idx, finished_fn)))
ieloop.Run()
......@@ -1493,9 +1507,16 @@ def RemoteImport(lu, feedback_fn, instance, pnode, source_x509_ca,
compress=compress,
ipv6=ipv6)
if instance.os:
src_io = constants.IEIO_SCRIPT
src_ioargs = ((dev, instance), idx)
else:
src_io = constants.IEIO_RAW_DISK
src_ioargs = (dev, instance)
ieloop.Add(DiskImport(lu, instance.primary_node, opts, instance,
"disk%d" % idx,
constants.IEIO_SCRIPT, ((dev, instance), idx),
src_io, src_ioargs,
timeouts, cbs, private=(idx, )))
ieloop.Run()
......
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