Revision 62c9ec92

b/daemons/ganeti-noded
236 236
    disk = objects.Disk.FromDict(params[0])
237 237
    dest_node = params[1]
238 238
    instance = objects.Instance.FromDict(params[2])
239
    return backend.ExportSnapshot(disk, dest_node, instance)
239
    cluster_name = params[3]
240
    return backend.ExportSnapshot(disk, dest_node, instance, cluster_name)
240 241

  
241 242
  @staticmethod
242 243
  def perspective_finalize_export(params):
......
333 334
    """Run the import function of an OS onto a given instance.
334 335

  
335 336
    """
336
    inst_s, os_disk, swap_disk, src_node, src_image = params
337
    inst_s, os_disk, swap_disk, src_node, src_image, cluster_name = params
337 338
    inst = objects.Instance.FromDict(inst_s)
338 339
    return backend.ImportOSIntoInstance(inst, os_disk, swap_disk,
339
                                        src_node, src_image)
340
                                        src_node, src_image, cluster_name)
340 341

  
341 342
  @staticmethod
342 343
  def perspective_instance_shutdown(params):
......
425 426
    """Run a verify sequence on this node.
426 427

  
427 428
    """
428
    return backend.VerifyNode(params[0])
429
    return backend.VerifyNode(params[0], params[1])
429 430

  
430 431
  @staticmethod
431 432
  def perspective_node_start_master(params):
b/lib/backend.py
48 48
  return ssconf.SimpleConfigReader()
49 49

  
50 50

  
51
def _GetSshRunner():
52
  return ssh.SshRunner(_GetConfig().GetClusterName())
51
def _GetSshRunner(cluster_name):
52
  return ssh.SshRunner(cluster_name)
53 53

  
54 54

  
55 55
def _CleanDirectory(path, exclude=[]):
......
264 264
  return outputarray
265 265

  
266 266

  
267
def VerifyNode(what):
267
def VerifyNode(what, cluster_name):
268 268
  """Verify the status of the local node.
269 269

  
270 270
  Args:
......
294 294
    result['nodelist'] = {}
295 295
    random.shuffle(what['nodelist'])
296 296
    for node in what['nodelist']:
297
      success, message = _GetSshRunner().VerifyNodeHostname(node)
297
      success, message = _GetSshRunner(cluster_name).VerifyNodeHostname(node)
298 298
      if not success:
299 299
        result['nodelist'][node] = message
300 300
  if 'node-net-test' in what:
......
1295 1295
                                 (disk.unique_id, disk.dev_type))
1296 1296

  
1297 1297

  
1298
def ExportSnapshot(disk, dest_node, instance):
1298
def ExportSnapshot(disk, dest_node, instance, cluster_name):
1299 1299
  """Export a block device snapshot to a remote node.
1300 1300

  
1301 1301
  Args:
......
1336 1336

  
1337 1337
  destcmd = utils.BuildShellCmd("mkdir -p %s && cat > %s/%s",
1338 1338
                                destdir, destdir, destfile)
1339
  remotecmd = _GetSshRunner().BuildCmd(dest_node, constants.GANETI_RUNAS,
1340
                                       destcmd)
1339
  remotecmd = _GetSshRunner(cluster_name).BuildCmd(dest_node,
1340
                                                   constants.GANETI_RUNAS,
1341
                                                   destcmd)
1341 1342

  
1342 1343
  # all commands have been checked, so we're safe to combine them
1343 1344
  command = '|'.join([expcmd, comprcmd, utils.ShellQuoteArgs(remotecmd)])
......
1436 1437
  return config
1437 1438

  
1438 1439

  
1439
def ImportOSIntoInstance(instance, os_disk, swap_disk, src_node, src_image):
1440
def ImportOSIntoInstance(instance, os_disk, swap_disk, src_node, src_image,
1441
                         cluster_name):
1440 1442
  """Import an os image into an instance.
1441 1443

  
1442 1444
  Args:
......
1482 1484
    os.mkdir(constants.LOG_OS_DIR, 0750)
1483 1485

  
1484 1486
  destcmd = utils.BuildShellCmd('cat %s', src_image)
1485
  remotecmd = _GetSshRunner().BuildCmd(src_node, constants.GANETI_RUNAS,
1486
                                       destcmd)
1487
  remotecmd = _GetSshRunner(cluster_name).BuildCmd(src_node,
1488
                                                   constants.GANETI_RUNAS,
1489
                                                   destcmd)
1487 1490

  
1488 1491
  comprcmd = "gunzip"
1489 1492
  impcmd = utils.BuildShellCmd("(cd %s; %s -i %s -b %s -s %s &>%s)",
b/lib/cmdlib.py
748 748
      'node-net-test': [(node.name, node.primary_ip, node.secondary_ip)
749 749
                        for node in nodeinfo]
750 750
      }
751
    all_nvinfo = rpc.call_node_verify(nodelist, node_verify_param)
751
    all_nvinfo = rpc.call_node_verify(nodelist, node_verify_param,
752
                                      self.cfg.GetClusterName())
752 753
    all_rversion = rpc.call_version(nodelist)
753 754
    all_ninfo = rpc.call_node_info(nodelist, self.cfg.GetVGName())
754 755

  
......
1777 1778
      # TODO: do a node-net-test as well?
1778 1779
    }
1779 1780

  
1780
    result = rpc.call_node_verify(node_verify_list, node_verify_param)
1781
    result = rpc.call_node_verify(node_verify_list, node_verify_param,
1782
                                  self.cfg.GetClusterName())
1781 1783
    for verifier in node_verify_list:
1782 1784
      if not result[verifier]:
1783 1785
        raise errors.OpExecError("Cannot communicate with %s's node daemon"
......
3581 3583
        feedback_fn("* running the instance OS import scripts...")
3582 3584
        src_node = self.op.src_node
3583 3585
        src_image = self.src_image
3586
        cluster_name = self.cfg.GetClusterName()
3584 3587
        if not rpc.call_instance_os_import(pnode_name, iobj, "sda", "sdb",
3585
                                                src_node, src_image):
3588
                                           src_node, src_image, cluster_name):
3586 3589
          raise errors.OpExecError("Could not import os for instance"
3587 3590
                                   " %s on node %s" %
3588 3591
                                   (instance, pnode_name))
......
4830 4833

  
4831 4834
    # TODO: check for size
4832 4835

  
4836
    cluster_name = self.cfg.GetClusterName()
4833 4837
    for dev in snap_disks:
4834
      if not rpc.call_snapshot_export(src_node, dev, dst_node.name, instance):
4838
      if not rpc.call_snapshot_export(src_node, dev, dst_node.name,
4839
                                      instance, cluster_name):
4835 4840
        logger.Error("could not export block device %s from node %s to node %s"
4836 4841
                     % (dev.logical_id[1], src_node, dst_node.name))
4837 4842
      if not rpc.call_blockdev_remove(src_node, dev):
b/lib/rpc.py
346 346
  return c.getresult().get(node, False)
347 347

  
348 348

  
349
def call_node_verify(node_list, checkdict):
349
def call_node_verify(node_list, checkdict, cluster_name):
350 350
  """Request verification of given parameters.
351 351

  
352 352
  This is a multi-node call.
353 353

  
354 354
  """
355
  c = Client("node_verify", [checkdict])
355
  c = Client("node_verify", [checkdict, cluster_name])
356 356
  c.connect_list(node_list)
357 357
  c.run()
358 358
  return c.getresult()
......
652 652
  return c.getresult().get(node, False)
653 653

  
654 654

  
655
def call_snapshot_export(node, snap_bdev, dest_node, instance):
655
def call_snapshot_export(node, snap_bdev, dest_node, instance, cluster_name):
656 656
  """Request the export of a given snapshot.
657 657

  
658 658
  This is a single-node call.
659 659

  
660 660
  """
661
  params = [snap_bdev.ToDict(), dest_node, instance.ToDict()]
661
  params = [snap_bdev.ToDict(), dest_node, instance.ToDict(), cluster_name]
662 662
  c = Client("snapshot_export", params)
663 663
  c.connect(node)
664 664
  c.run()
......
698 698
  return objects.SerializableConfigParser.Loads(str(result))
699 699

  
700 700

  
701
def call_instance_os_import(node, inst, osdev, swapdev, src_node, src_image):
701
def call_instance_os_import(node, inst, osdev, swapdev,
702
                            src_node, src_image, cluster_name):
702 703
  """Request the import of a backup into an instance.
703 704

  
704 705
  This is a single-node call.
705 706

  
706 707
  """
707
  params = [inst.ToDict(), osdev, swapdev, src_node, src_image]
708
  params = [inst.ToDict(), osdev, swapdev, src_node, src_image, cluster_name]
708 709
  c = Client("instance_os_import", params)
709 710
  c.connect(node)
710 711
  c.run()

Also available in: Unified diff