Revision 3360026f

b/lib/cmdlib/instance.py
38 38
from ganeti import objects
39 39
from ganeti import pathutils
40 40
from ganeti import serializer
41
from ganeti import ssh
42 41
import ganeti.rpc.node as rpc
43 42
from ganeti import utils
44 43

  
......
1492 1491
    disk_abort = False
1493 1492

  
1494 1493
    if not self.adopt_disks and os_image is not None:
1495
      master = self.cfg.GetMasterNode()
1496

  
1497
      if not utils.IsUrl(os_image) and master != self.pnode.uuid:
1498
        ssh_port = self.pnode.ndparams.get(constants.ND_SSH_PORT)
1499
        srun = ssh.SshRunner(self.cfg.GetClusterName())
1500
        srun.CopyFileToNode(self.pnode.name, ssh_port, os_image)
1501

  
1502 1494
      feedback_fn("* imaging instance disks...")
1503 1495
      try:
1504 1496
        ImageDisks(self, iobj, os_image)
b/lib/cmdlib/instance_operation.py
33 33
from ganeti import hypervisor
34 34
from ganeti import locking
35 35
from ganeti import objects
36
from ganeti import ssh
37 36
from ganeti import utils
38 37
from ganeti.cmdlib.base import LogicalUnit, NoHooksLU
39 38
from ganeti.cmdlib.common import INSTANCE_ONLINE, INSTANCE_DOWN, \
......
359 358
    result.Raise("Could not install OS for instance '%s' on node '%s'" %
360 359
                 (instance.name, self.cfg.GetNodeName(instance.primary_node)))
361 360

  
362
  def _ReinstallOSImage(self, instance, os_image):
363
    """Reinstall OS image on an instance.
364

  
365
    @type instance: L{objects.Instance}
366
    @param instance: instance on which the OS image should be installed
367

  
368
    @type os_image: string
369
    @param os_image: OS image URL or absolute file path
370

  
371
    @rtype: NoneType
372
    @return: None
373
    @raise errors.OpExecError: in case of failure
374

  
375
    """
376
    master = self.cfg.GetMasterNode()
377
    pnode = self.cfg.GetNodeInfo(instance.primary_node)
378

  
379
    if not utils.IsUrl(os_image) and master != pnode.uuid:
380
      ssh_port = pnode.ndparams.get(constants.ND_SSH_PORT)
381
      srun = ssh.SshRunner(self.cfg.GetClusterName())
382
      srun.CopyFileToNode(pnode.name, ssh_port, os_image)
383

  
384
    ImageDisks(self, instance, os_image)
385

  
386 361
  def Exec(self, feedback_fn):
387 362
    """Reinstall the instance.
388 363

  
......
411 386
      StartInstanceDisks(self, self.instance, None)
412 387
      try:
413 388
        if os_image:
414
          self._ReinstallOSImage(self.instance, os_image)
389
          ImageDisks(self, self.instance, os_image)
415 390

  
416 391
        if os_type:
417 392
          self._ReinstallOSScripts(self.instance, self.osparams,

Also available in: Unified diff