summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrey Morris <trey.morris@rackspace.com>2010-12-09 16:41:35 +0000
committerTrey Morris <trey.morris@rackspace.com>2010-12-09 16:41:35 +0000
commit5f72a004dee0cb8de3f2daee1976fa978f6e51f3 (patch)
tree1f5e13c9eb91e5895a3cb8bdf370e8947fa31763
parentcc83aa52086f1472a97914b36f7c4ef7ebb52750 (diff)
downloadnova-5f72a004dee0cb8de3f2daee1976fa978f6e51f3.tar.gz
nova-5f72a004dee0cb8de3f2daee1976fa978f6e51f3.tar.xz
nova-5f72a004dee0cb8de3f2daee1976fa978f6e51f3.zip
pause from compute.manager <-> xenapi
-rw-r--r--nova/compute/manager.py32
-rw-r--r--nova/virt/xenapi/vmops.py20
-rw-r--r--nova/virt/xenapi_conn.py8
3 files changed, 60 insertions, 0 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index dd8d41129..c0339a71f 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -194,6 +194,38 @@ class ComputeManager(manager.Manager):
yield self.driver.unrescue(instance_ref)
self._update_state(context, instance_id)
+ @defer.inlineCallbacks
+ @exception.wrap_exception
+ def pause_instance(self, context, instance_id):
+ """Pause an instance on this server."""
+ context = context.elevated()
+ instance_ref = self.db.instance_get(context, instance_id)
+
+ logging.debug('instance %s: pausing',
+ instance_ref['internal_id'])
+ self.db.instance_set_state(context,
+ instance_id,
+ power_state.NOSTATE,
+ 'pausing')
+ yield self.driver.pause(instance_ref)
+ self._update_state(context, instance_id)
+
+ @defer.inlineCallbacks
+ @exception.wrap_exception
+ def resume_instance(self, context, instance_id):
+ """Resume a paused instance on this server."""
+ context = context.elevated()
+ instance_ref = self.db.instance_get(context, instance_id)
+
+ logging.debug('instance %s: resuming',
+ instance_ref['internal_id'])
+ self.db.instance_set_state(context,
+ instance_id,
+ power_state.NOSTATE,
+ 'resume')
+ yield self.driver.resume(instance_ref)
+ self._update_state(context, instance_id)
+
@exception.wrap_exception
def get_console_output(self, context, instance_id):
"""Send the console output for an instance."""
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index d36cdaea5..353e83873 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -120,6 +120,26 @@ class VMOps(object):
except XenAPI.Failure, exc:
logging.warn(exc)
+ @defer.inlineCallbacks
+ def pause(self, instance):
+ """ Pause VM instance """
+ instance_name = instance.name
+ vm = yield VMHelper.lookup(self._session, instance_name)
+ if vm is None:
+ raise Exception('instance not present %s' % instance_name)
+ task = yield self._session.call_xenapi('Async.VM.pause', vm)
+ yield self._session.wait_for_task(task)
+
+ @defer.inlineCallbacks
+ def unpause(self, instance):
+ """ Unpause VM instance """
+ instance_name = instance.name
+ vm = yield VMHelper.lookup(self._session, instance_name)
+ if vm is None:
+ raise Exception('instance not present %s' % instance_name)
+ task = yield self._session.call_xenapi('Async.VM.unpause', vm)
+ yield self._session.wait_for_task(task)
+
def get_info(self, instance_id):
""" Return data about VM instance """
vm = VMHelper.lookup_blocking(self._session, instance_id)
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index 26b30bf92..df405e75f 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -122,6 +122,14 @@ class XenAPIConnection(object):
""" Destroy VM instance """
self._vmops.destroy(instance)
+ def pause(self, instance):
+ """ Pause VM instance """
+ self._vmops.pause(instance)
+
+ def unpause(self, instance):
+ """ Unpause paused VM instance """
+ self._vmops.unpause(instance)
+
def get_info(self, instance_id):
""" Return data about VM instance """
return self._vmops.get_info(instance_id)