Commit 4fcb1b59 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cmdlib: Convert instance export to new style

With this change, exports of several disks will occur in parallel. Error
handling has also been improved.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarRené Nussbaumer <>
parent 5d97d6dd
...@@ -46,6 +46,9 @@ from ganeti import serializer ...@@ -46,6 +46,9 @@ from ganeti import serializer
from ganeti import ssconf from ganeti import ssconf
from ganeti import uidpool from ganeti import uidpool
from ganeti import compat from ganeti import compat
from ganeti import masterd
import ganeti.masterd.instance # pylint: disable-msg=W0611
class LogicalUnit(object): class LogicalUnit(object):
...@@ -9015,7 +9018,6 @@ class LUExportInstance(LogicalUnit): ...@@ -9015,7 +9018,6 @@ class LUExportInstance(LogicalUnit):
try: try:
# per-disk results # per-disk results
dresults = []
removed_snaps = [False] * len(instance.disks) removed_snaps = [False] * len(instance.disks)
snap_disks = None snap_disks = None
...@@ -9038,28 +9040,36 @@ class LUExportInstance(LogicalUnit): ...@@ -9038,28 +9040,36 @@ class LUExportInstance(LogicalUnit):
# TODO: check for size # TODO: check for size
cluster_name = self.cfg.GetClusterName() def _TransferFinished(idx):
for idx, dev in enumerate(snap_disks): logging.debug("Transfer %s finished", idx)
feedback_fn("Exporting snapshot %s from %s to %s" %
(idx, src_node,
if dev:
# FIXME: pass debug from opcode to backend
result = self.rpc.call_snapshot_export(src_node, dev,,
instance, cluster_name,
idx, self.op.debug_level)
msg = result.fail_msg
if msg:
self.LogWarning("Could not export disk/%s from node %s to"
" node %s: %s", idx, src_node,, msg)
# Remove snapshot
if self._RemoveSnapshot(feedback_fn, snap_disks, idx): if self._RemoveSnapshot(feedback_fn, snap_disks, idx):
removed_snaps[idx] = True removed_snaps[idx] = True
dresults.append(False) transfers = []
for idx, dev in enumerate(snap_disks):
if not dev:
path = utils.PathJoin(constants.EXPORT_DIR, "" %,
finished_fn = compat.partial(_TransferFinished, idx)
# FIXME: pass debug option from opcode to backend
dt = masterd.instance.DiskTransfer("snapshot/%s" % idx,
constants.IEIO_SCRIPT, (dev, idx),
constants.IEIO_FILE, (path, ),
# Actually export data
dresults = \
masterd.instance.TransferInstanceData(self, feedback_fn,
instance, transfers)
assert len(dresults) == len(instance.disks) assert len(dresults) == len(instance.disks)
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