Commit 87812fd3 authored by Iustin Pop's avatar Iustin Pop
Browse files

Convert blockdev_snapshot rpc to new result style



This also slightly changes the code in cmdlib that uses it for more
clarity.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 3efa9051
......@@ -1743,13 +1743,12 @@ def BlockdevSnapshot(disk):
r_dev = _RecursiveFindBD(disk)
if r_dev is not None:
# let's stay on the safe side and ask for the full size, for now
return r_dev.Snapshot(disk.size)
return True, r_dev.Snapshot(disk.size)
else:
return None
_Fail("Cannot find block device %s", disk)
else:
raise errors.ProgrammerError("Cannot snapshot non-lvm block device"
" '%s' of type '%s'" %
(disk.unique_id, disk.dev_type))
_Fail("Cannot snapshot non-lvm block device '%s' of type '%s'",
disk.unique_id, disk.dev_type)
def ExportSnapshot(disk, dest_node, instance, cluster_name, idx):
......
......@@ -6462,16 +6462,17 @@ class LUExportInstance(LogicalUnit):
try:
for disk in instance.disks:
# 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)
if new_dev_name.failed or not new_dev_name.data:
self.LogWarning("Could not snapshot block device %s on node %s",
disk.logical_id[1], src_node)
# result.payload will be a snapshot of an lvm leaf of the one we passed
result = self.rpc.call_blockdev_snapshot(src_node, disk)
msg = result.RemoteFailMsg()
if msg:
self.LogWarning("Could not snapshot block device %s on node %s: %s",
disk.logical_id[1], src_node, msg)
snap_disks.append(False)
else:
disk_id = (vgname, result.payload)
new_dev = objects.Disk(dev_type=constants.LD_LV, size=disk.size,
logical_id=(vgname, new_dev_name.data),
physical_id=(vgname, new_dev_name.data),
logical_id=disk_id, physical_id=disk_id,
iv_name=disk.iv_name)
snap_disks.append(new_dev)
......
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