Revision 007a2f3e

b/daemons/ganeti-noded
325 325
    return backend.StartInstance(instance, extra_args)
326 326

  
327 327
  @staticmethod
328
  def perspective_instance_reboot(params):
329
    """Reboot an instance.
330

  
331
    """
332
    instance = objects.Instance.FromDict(params[0])
333
    reboot_type = params[1]
334
    extra_args = params[2]
335
    return backend.RebootInstance(instance, reboot_type, extra_args)
336

  
337
  @staticmethod
328 338
  def perspective_instance_info(params):
329 339
    """Query instance information.
330 340

  
b/lib/backend.py
585 585
  return True
586 586

  
587 587

  
588
def RebootInstance(instance, reboot_type, extra_args):
589
  """Reboot an instance.
590

  
591
  Args:
592
    instance    - name of instance to reboot
593
    reboot_type - how to reboot [soft,hard,full]
594

  
595
  """
596
  running_instances = GetInstanceList()
597

  
598
  if instance.name not in running_instances:
599
    logger.Error("Cannot reboot instance that is not running")
600
    return False
601

  
602
  hyper = hypervisor.GetHypervisor()
603
  if reboot_type == constants.INSTANCE_REBOOT_SOFT:
604
    try:
605
      hyper.RebootInstance(instance)
606
    except errors.HypervisorError, err:
607
      logger.Error("Failed to soft reboot instance: %s" % err)
608
      return False
609
  elif reboot_type == constants.INSTANCE_REBOOT_HARD:
610
    try:
611
      ShutdownInstance(instance)
612
      StartInstance(instance, extra_args)
613
    except errors.HypervisorError, err:
614
      logger.Error("Failed to hard reboot instance: %s" % err)
615
      return False
616
  else:
617
    raise errors.ParameterError("reboot_type invalid")
618

  
619

  
620
  return True
621

  
622

  
588 623
def CreateBlockDevice(disk, size, on_primary, info):
589 624
  """Creates a block device for an instance.
590 625

  
b/lib/constants.py
117 117
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
118 118
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
119 119
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
120

  
121
# reboot types
122
INSTANCE_REBOOT_SOFT = "soft"
123
INSTANCE_REBOOT_HARD = "hard"
124
INSTANCE_REBOOT_FULL = "full"
b/lib/rpc.py
311 311
  return c.getresult().get(node, False)
312 312

  
313 313

  
314
def call_instance_reboot(node, instance, reboot_type, extra_args):
315
  """Reboots an instance.
316

  
317
  This is a single-node call.
318

  
319
  """
320
  c = Client("instance_reboot", [instance.ToDict(), reboot_type, extra_args])
321
  c.connect(node)
322
  c.run()
323
  return c.getresult().get(node, False)
324

  
325

  
314 326
def call_instance_os_add(node, inst, osdev, swapdev):
315 327
  """Installs an OS on the given instance.
316 328

  

Also available in: Unified diff