Use instance data transfer utility to import instances.
Signed-off-by: Michael Hanselmann <[email protected]>
---
lib/cmdlib.py | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index a8423f2..0be297e 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -6628,18 +6628,24 @@ 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 image:
+ transfers.append(("disk/%s" % idx,
+ constants.IEIO_FILE, (image, ),
+ constants.IEIO_SCRIPT, (iobj.disks[idx], idx),
+ None, None))
+
+ import_result = TransferInstanceData(self, feedback_fn,
+ self.op.src_node, pnode_name,
+ self.pnode.secondary_ip,
+ iobj, transfers)
+ if not utils.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'"
--
1.7.0.4
--
To unsubscribe, reply using "remove me" as the subject.