Convert snapshot_export rpc to new style
authorIustin Pop <iustin@google.com>
Tue, 9 Jun 2009 09:35:56 +0000 (11:35 +0200)
committerIustin Pop <iustin@google.com>
Mon, 15 Jun 2009 16:37:23 +0000 (18:37 +0200)
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/backend.py
lib/cmdlib.py

index f2ac504..08b65aa 100644 (file)
@@ -1780,8 +1780,8 @@ def ExportSnapshot(disk, dest_node, instance, cluster_name, idx):
     os.mkdir(constants.LOG_OS_DIR, 0750)
   real_disk = _RecursiveFindBD(disk)
   if real_disk is None:
-    raise errors.BlockDeviceError("Block device '%s' is not set up" %
-                                  str(disk))
+    _Fail("Block device '%s' is not set up", disk)
+
   real_disk.Open()
 
   export_env['EXPORT_DEVICE'] = real_disk.dev_path
@@ -1810,11 +1810,10 @@ def ExportSnapshot(disk, dest_node, instance, cluster_name, idx):
   result = utils.RunCmd(command, env=export_env)
 
   if result.failed:
-    logging.error("os snapshot export command '%s' returned error: %s"
-                  " output: %s", command, result.fail_reason, result.output)
-    return False
+    _Fail("OS snapshot export command '%s' returned error: %s"
+          " output: %s", command, result.fail_reason, result.output)
 
-  return True
+  return (True, None)
 
 
 def FinalizeExport(instance, snap_disks):
index e4e7b71..4d9502f 100644 (file)
@@ -6491,10 +6491,11 @@ class LUExportInstance(LogicalUnit):
       if dev:
         result = self.rpc.call_snapshot_export(src_node, dev, dst_node.name,
                                                instance, cluster_name, idx)
-        if result.failed or not result.data:
+        msg = result.RemoteFailMsg()
+        if msg:
           self.LogWarning("Could not export block device %s from node %s to"
-                          " node %s", dev.logical_id[1], src_node,
-                          dst_node.name)
+                          " node %s: %s", dev.logical_id[1], src_node,
+                          dst_node.name, msg)
         msg = self.rpc.call_blockdev_remove(src_node, dev).RemoteFailMsg()
         if msg:
           self.LogWarning("Could not remove snapshot block device %s from node"