From 7e1394dc49c3baf46029d55e3b1568fc996346e5 Mon Sep 17 00:00:00 2001
From: Alexander Schreiber <als@google.com>
Date: Thu, 11 Oct 2007 13:39:28 +0000
Subject: [PATCH] Infrastructure for detailed instance restarts, part one

The beginning of the infrastructure for detailed instance restarts. Does
not affect behaviour if code yet.

Reviewed-by: iustinp
---
 lib/hypervisor.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/hypervisor.py b/lib/hypervisor.py
index 4669c626c..04737add1 100644
--- a/lib/hypervisor.py
+++ b/lib/hypervisor.py
@@ -73,6 +73,10 @@ class BaseHypervisor(object):
     """Stop an instance."""
     raise NotImplementedError
 
+  def RebootInstance(self, instance):
+    """Reboot an instance."""
+    raise NotImplementedError
+
   def ListInstances(self):
     """Get the list of running instances."""
     raise NotImplementedError
@@ -277,6 +281,14 @@ class XenHypervisor(BaseHypervisor):
       raise HypervisorError("Failed to stop instance %s: %s" %
                             (instance.name, result.fail_reason))
 
+  def RebootInstance(self, instance):
+    """Reboot an instance."""
+    result = utils.RunCmd(["xm", "reboot", instance.name])
+
+    if result.failed:
+      raise HypervisorError("Failed to reboot instance %s: %s" %
+                            (instance.name, result.fail_reason))
+
   def GetNodeInfo(self):
     """Return information about the node.
 
@@ -438,6 +450,14 @@ class FakeHypervisor(BaseHypervisor):
                             (instance.name, "not running"))
     utils.RemoveFile(file_name)
 
+  def RebootInstance(self, instance):
+    """Reboot an instance.
+
+    For the fake hypervisor, this does nothing.
+
+    """
+    return
+
   def GetNodeInfo(self):
     """Return information about the node.
 
-- 
GitLab