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

cmdlib: Convert instance import to new style



Use instance data transfer utility to import instances.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 4fcb1b59
......@@ -6809,18 +6809,30 @@ class LUCreateInstance(LogicalUnit):
elif self.op.mode == constants.INSTANCE_IMPORT:
feedback_fn("* running the instance OS import scripts...")
src_node = self.op.src_node
src_images = self.src_images
cluster_name = self.cfg.GetClusterName()
# FIXME: pass debug option from opcode to backend
import_result = self.rpc.call_instance_os_import(pnode_name, iobj,
src_node, src_images,
cluster_name,
self.op.debug_level)
msg = import_result.fail_msg
if msg:
self.LogWarning("Error while importing the disk images for instance"
" %s on node %s: %s" % (instance, pnode_name, msg))
transfers = []
for idx, image in enumerate(self.src_images):
if not image:
continue
# 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], idx),
None)
transfers.append(dt)
import_result = \
masterd.instance.TransferInstanceData(self, feedback_fn,
self.op.src_node, pnode_name,
self.pnode.secondary_ip,
iobj, transfers)
if not compat.all(import_result):
self.LogWarning("Some disks for instance %s on node %s were not"
" imported successfully" % (instance, pnode_name))
else:
# also checked in the prereq part
raise errors.ProgrammerError("Unknown OS initialization mode '%s'"
......
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