Revision 007a2f3e lib/backend.py

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

  

Also available in: Unified diff