Commit 19d7f90a authored by Guido Trotter's avatar Guido Trotter
Browse files

LUExportInstance: snapshot all disks

Rather than just snapshotting the "sda" disk, we'll snapshot all of the
instance disks. If we can't snapshot a disk for any reason we'll log an
error and proceed anyway: in this case the resulting export will miss a
disk. This also changes all the warning messages to self.LogWarning().

Reviewed-by: iustinp
parent e9e9263d
...@@ -1436,12 +1436,13 @@ def FinalizeExport(instance, snap_disks): ...@@ -1436,12 +1436,13 @@ def FinalizeExport(instance, snap_disks):
disk_count = 0 disk_count = 0
for disk_count, disk in enumerate(snap_disks): for disk_count, disk in enumerate(snap_disks):
config.set(constants.INISECT_INS, 'disk%d_ivname' % disk_count, if disk:
('%s' % disk.iv_name)) config.set(constants.INISECT_INS, 'disk%d_ivname' % disk_count,
config.set(constants.INISECT_INS, 'disk%d_dump' % disk_count, ('%s' % disk.iv_name))
('%s' % disk.physical_id[1])) config.set(constants.INISECT_INS, 'disk%d_dump' % disk_count,
config.set(constants.INISECT_INS, 'disk%d_size' % disk_count, ('%s' % disk.physical_id[1]))
('%d' % disk.size)) config.set(constants.INISECT_INS, 'disk%d_size' % disk_count,
('%d' % disk.size))
config.set(constants.INISECT_INS, 'disk_count' , '%d' % disk_count) config.set(constants.INISECT_INS, 'disk_count' , '%d' % disk_count)
cff = os.path.join(destdir, constants.EXPORT_CONF_FILE) cff = os.path.join(destdir, constants.EXPORT_CONF_FILE)
......
...@@ -4874,19 +4874,19 @@ class LUExportInstance(LogicalUnit): ...@@ -4874,19 +4874,19 @@ class LUExportInstance(LogicalUnit):
try: try:
for disk in instance.disks: for disk in instance.disks:
if disk.iv_name == "sda": # new_dev_name will be a snapshot of an lvm leaf of the one we passed
# new_dev_name will be a snapshot of an lvm leaf of the one we passed new_dev_name = self.rpc.call_blockdev_snapshot(src_node, disk)
new_dev_name = self.rpc.call_blockdev_snapshot(src_node, disk)
if not new_dev_name: if not new_dev_name:
logging.error("Could not snapshot block device %s on node %s", self.LogWarning("Could not snapshot block device %s on node %s",
disk.logical_id[1], src_node) disk.logical_id[1], src_node)
else: snap_disks.append(False)
new_dev = objects.Disk(dev_type=constants.LD_LV, size=disk.size, else:
logical_id=(vgname, new_dev_name), new_dev = objects.Disk(dev_type=constants.LD_LV, size=disk.size,
physical_id=(vgname, new_dev_name), logical_id=(vgname, new_dev_name),
iv_name=disk.iv_name) physical_id=(vgname, new_dev_name),
snap_disks.append(new_dev) iv_name=disk.iv_name)
snap_disks.append(new_dev)
finally: finally:
if self.op.shutdown and instance.status == "up": if self.op.shutdown and instance.status == "up":
...@@ -4898,17 +4898,19 @@ class LUExportInstance(LogicalUnit): ...@@ -4898,17 +4898,19 @@ class LUExportInstance(LogicalUnit):
cluster_name = self.cfg.GetClusterName() cluster_name = self.cfg.GetClusterName()
for dev in snap_disks: for dev in snap_disks:
if not self.rpc.call_snapshot_export(src_node, dev, dst_node.name, if dev:
instance, cluster_name): if not self.rpc.call_snapshot_export(src_node, dev, dst_node.name,
logging.error("Could not export block device %s from node %s to" instance, cluster_name):
" node %s", dev.logical_id[1], src_node, dst_node.name) self.LogWarning("Could not export block device %s from node %s to"
if not self.rpc.call_blockdev_remove(src_node, dev): " node %s", dev.logical_id[1], src_node,
logging.error("Could not remove snapshot block device %s from node" dst_node.name)
" %s", dev.logical_id[1], src_node) if not self.rpc.call_blockdev_remove(src_node, dev):
self.LogWarning("Could not remove snapshot block device %s from node"
" %s", dev.logical_id[1], src_node)
if not self.rpc.call_finalize_export(dst_node.name, instance, snap_disks): if not self.rpc.call_finalize_export(dst_node.name, instance, snap_disks):
logging.error("Could not finalize export for instance %s on node %s", self.LogWarning("Could not finalize export for instance %s on node %s",
instance.name, dst_node.name) instance.name, dst_node.name)
nodelist = self.cfg.GetNodeList() nodelist = self.cfg.GetNodeList()
nodelist.remove(dst_node.name) nodelist.remove(dst_node.name)
...@@ -4921,8 +4923,8 @@ class LUExportInstance(LogicalUnit): ...@@ -4921,8 +4923,8 @@ class LUExportInstance(LogicalUnit):
for node in exportlist: for node in exportlist:
if instance.name in exportlist[node]: if instance.name in exportlist[node]:
if not self.rpc.call_export_remove(node, instance.name): if not self.rpc.call_export_remove(node, instance.name):
logging.error("Could not remove older export for instance %s" self.LogWarning("Could not remove older export for instance %s"
" on node %s", instance.name, node) " on node %s", instance.name, node)
class LURemoveExport(NoHooksLU): class LURemoveExport(NoHooksLU):
......
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