Revision e557bae9

b/daemons/ganeti-noded
365 365
    """
366 366
    inst_s = params[0]
367 367
    inst = objects.Instance.FromDict(inst_s)
368
    return backend.InstanceOsAdd(inst)
368
    reinstall = params[1]
369
    return backend.InstanceOsAdd(inst, reinstall)
369 370

  
370 371
  @staticmethod
371 372
  def perspective_instance_run_rename(params):
b/lib/backend.py
673 673
  return output
674 674

  
675 675

  
676
def InstanceOsAdd(instance):
676
def InstanceOsAdd(instance, reinstall):
677 677
  """Add an OS to an instance.
678 678

  
679 679
  @type instance: L{objects.Instance}
680 680
  @param instance: Instance whose OS is to be installed
681
  @type reinstall: boolean
682
  @param reinstall: whether this is an instance reinstall
681 683
  @rtype: boolean
682 684
  @return: the success of the operation
683 685

  
......
693 695
              (os_name, os_dir, os_err))
694 696

  
695 697
  create_env = OSEnvironment(instance)
698
  if reinstall:
699
    create_env['INSTANCE_REINSTALL'] = "1"
696 700

  
697 701
  logfile = "%s/add-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os,
698 702
                                     instance.name, int(time.time()))
b/lib/cmdlib.py
2995 2995
    _StartInstanceDisks(self, inst, None)
2996 2996
    try:
2997 2997
      feedback_fn("Running the instance OS create scripts...")
2998
      result = self.rpc.call_instance_os_add(inst.primary_node, inst)
2998
      result = self.rpc.call_instance_os_add(inst.primary_node, inst, True)
2999 2999
      msg = result.RemoteFailMsg()
3000 3000
      if msg:
3001 3001
        raise errors.OpExecError("Could not install OS for instance %s"
......
4763 4763
    if iobj.disk_template != constants.DT_DISKLESS:
4764 4764
      if self.op.mode == constants.INSTANCE_CREATE:
4765 4765
        feedback_fn("* running the instance OS create scripts...")
4766
        result = self.rpc.call_instance_os_add(pnode_name, iobj)
4766
        result = self.rpc.call_instance_os_add(pnode_name, iobj, False)
4767 4767
        msg = result.RemoteFailMsg()
4768 4768
        if msg:
4769 4769
          raise errors.OpExecError("Could not add os for instance %s"
b/lib/rpc.py
524 524
    return self._SingleNodeCall(node, "instance_reboot",
525 525
                                [self._InstDict(instance), reboot_type])
526 526

  
527
  def call_instance_os_add(self, node, inst):
527
  def call_instance_os_add(self, node, inst, reinstall):
528 528
    """Installs an OS on the given instance.
529 529

  
530 530
    This is a single-node call.
531 531

  
532 532
    """
533 533
    return self._SingleNodeCall(node, "instance_os_add",
534
                                [self._InstDict(inst)])
534
                                [self._InstDict(inst), reinstall])
535 535

  
536 536
  def call_instance_run_rename(self, node, inst, old_name):
537 537
    """Run the OS rename script for an instance.
b/man/ganeti-os-interface.sgml
215 215
      according to this name. It can configure the IP statically or
216 216
      not, depending on the deployment environment.</para>
217 217

  
218
      <para>The <envar>INSTANCE_REINSTALL</envar> variable is set to '1' when
219
      this create request is reinstalling and existing instance, rather than
220
      creating one anew. This can be used, for example, to preserve some
221
      data in the old instance in an os-specific way.</para>
222

  
218 223
    </refsect2>
219 224

  
220 225
    <refsect2>

Also available in: Unified diff