Revision 74c47259

b/daemons/ganeti-noded
241 241
    dest_node = params[1]
242 242
    instance = objects.Instance.FromDict(params[2])
243 243
    cluster_name = params[3]
244
    return backend.ExportSnapshot(disk, dest_node, instance, cluster_name)
244
    dev_idx = params[4]
245
    return backend.ExportSnapshot(disk, dest_node, instance,
246
                                  cluster_name, dev_idx)
245 247

  
246 248
  @staticmethod
247 249
  def perspective_finalize_export(params):
b/lib/backend.py
1331 1331
                                 (disk.unique_id, disk.dev_type))
1332 1332

  
1333 1333

  
1334
def ExportSnapshot(disk, dest_node, instance, cluster_name):
1334
def ExportSnapshot(disk, dest_node, instance, cluster_name, idx):
1335 1335
  """Export a block device snapshot to a remote node.
1336 1336

  
1337
  Args:
1338
    disk: the snapshot block device
1339
    dest_node: the node to send the image to
1340
    instance: instance being exported
1341

  
1342
  Returns:
1343
    True if successful, False otherwise.
1337
  @type disk: L{objects.Disk}
1338
  @param disk: the description of the disk to export
1339
  @type dest_node: str
1340
  @param dest_node: the destination node to export to
1341
  @type instance: L{objects.Instance}
1342
  @param instance: the instance object to whom the disk belongs
1343
  @type cluster_name: str
1344
  @param cluster_name: the cluster name, needed for SSH hostalias
1345
  @type idx: int
1346
  @param idx: the index of the disk in the instance's disk list,
1347
      used to export to the OS scripts environment
1348
  @rtype: bool
1349
  @return: the success of the operation
1344 1350

  
1345 1351
  """
1346 1352
  export_env = OSEnvironment(instance)
......
1359 1365
  real_disk.Open()
1360 1366

  
1361 1367
  export_env['EXPORT_DEVICE'] = real_disk.dev_path
1368
  export_env['EXPORT_INDEX'] = str(idx)
1362 1369

  
1363 1370
  destdir = os.path.join(constants.EXPORT_DIR, instance.name + ".new")
1364 1371
  destfile = disk.physical_id[1]
......
1512 1519
                                                       destcmd)
1513 1520
      command = '|'.join([utils.ShellQuoteArgs(remotecmd), comprcmd, impcmd])
1514 1521
      import_env['IMPORT_DEVICE'] = import_env['DISK_%d_PATH' % idx]
1522
      import_env['IMPORT_INDEX'] = str(idx)
1515 1523
      result = utils.RunCmd(command, env=import_env)
1516 1524
      if result.failed:
1517 1525
        logging.error("disk import command '%s' returned error: %s"
b/lib/cmdlib.py
4912 4912
    # TODO: check for size
4913 4913

  
4914 4914
    cluster_name = self.cfg.GetClusterName()
4915
    for dev in snap_disks:
4915
    for idx, dev in enumerate(snap_disks):
4916 4916
      if dev:
4917 4917
        if not self.rpc.call_snapshot_export(src_node, dev, dst_node.name,
4918
                                             instance, cluster_name):
4918
                                             instance, cluster_name, idx):
4919 4919
          self.LogWarning("Could not export block device %s from node %s to"
4920 4920
                          " node %s", dev.logical_id[1], src_node,
4921 4921
                          dst_node.name)
b/lib/rpc.py
787 787
    return c.GetResults().get(node, False)
788 788

  
789 789
  def call_snapshot_export(self, node, snap_bdev, dest_node, instance,
790
                           cluster_name):
790
                           cluster_name, idx):
791 791
    """Request the export of a given snapshot.
792 792

  
793 793
    This is a single-node call.
794 794

  
795 795
    """
796 796
    params = [snap_bdev.ToDict(), dest_node,
797
              self._InstDict(instance), cluster_name]
797
              self._InstDict(instance), cluster_name, idx]
798 798
    c = Client("snapshot_export", params)
799 799
    self._ConnectNode(c, node)
800 800
    c.Run()

Also available in: Unified diff