Revision 3360026f lib/cmdlib/instance_operation.py
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