summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorAnthony Young <sleepsonthefloor@gmail.com>2011-01-03 08:51:35 -0800
committerAnthony Young <sleepsonthefloor@gmail.com>2011-01-03 08:51:35 -0800
commitfebe1e32d1e0441206f1645748ed216abe3e89e4 (patch)
treefe828d24fd31cb29ad623796b3e7687427a702ec /nova/compute
parent13dfb66624ca082bd5e83969213c657d2d2d1dff (diff)
parent0e88a58cf95bf9298a52d132cd1eb02f29c6bfe1 (diff)
merge in trunk
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py23
-rw-r--r--nova/compute/manager.py30
2 files changed, 53 insertions, 0 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 38b99a3e3..0658044d2 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -257,6 +257,15 @@ class ComputeAPI(base.Base):
def get_instance(self, context, instance_id):
return self.db.instance_get_by_internal_id(context, instance_id)
+ def snapshot(self, context, instance_id, name):
+ """Snapshot the given instance."""
+ instance = self.db.instance_get_by_internal_id(context, instance_id)
+ host = instance['host']
+ rpc.cast(context,
+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
+ {"method": "snapshot_instance",
+ "args": {"instance_id": instance['id'], "name": name}})
+
def reboot(self, context, instance_id):
"""Reboot the given instance."""
instance = self.db.instance_get_by_internal_id(context, instance_id)
@@ -284,6 +293,20 @@ class ComputeAPI(base.Base):
{"method": "unpause_instance",
"args": {"instance_id": instance['id']}})
+ def get_diagnostics(self, context, instance_id):
+ """Retrieve diagnostics for the given instance."""
+ instance = self.db.instance_get_by_internal_id(context, instance_id)
+ host = instance["host"]
+ return rpc.call(context,
+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
+ {"method": "get_diagnostics",
+ "args": {"instance_id": instance["id"]}})
+
+ def get_actions(self, context, instance_id):
+ """Retrieve actions for the given instance."""
+ instance = self.db.instance_get_by_internal_id(context, instance_id)
+ return self.db.instance_get_actions(context, instance["id"])
+
def suspend(self, context, instance_id):
"""suspend the instance with instance_id"""
instance = self.db.instance_get_by_internal_id(context, instance_id)
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 5f237eda9..882b000ef 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -225,6 +225,27 @@ class ComputeManager(manager.Manager):
self._update_state(context, instance_id)
@exception.wrap_exception
+ def snapshot_instance(self, context, instance_id, name):
+ """Snapshot an instance on this server."""
+ context = context.elevated()
+ instance_ref = self.db.instance_get(context, instance_id)
+
+ #NOTE(sirp): update_state currently only refreshes the state field
+ # if we add is_snapshotting, we will need this refreshed too,
+ # potentially?
+ self._update_state(context, instance_id)
+
+ logging.debug(_('instance %s: snapshotting'), instance_ref['name'])
+ if instance_ref['state'] != power_state.RUNNING:
+ logging.warn(_('trying to snapshot a non-running '
+ 'instance: %s (state: %s excepted: %s)'),
+ instance_ref['internal_id'],
+ instance_ref['state'],
+ power_state.RUNNING)
+
+ self.driver.snapshot(instance_ref, name)
+
+ @exception.wrap_exception
def rescue_instance(self, context, instance_id):
"""Rescue an instance on this server."""
context = context.elevated()
@@ -297,6 +318,15 @@ class ComputeManager(manager.Manager):
result))
@exception.wrap_exception
+ def get_diagnostics(self, context, instance_id):
+ """Retrieve diagnostics for an instance on this server."""
+ instance_ref = self.db.instance_get(context, instance_id)
+
+ if instance_ref["state"] == power_state.RUNNING:
+ logging.debug(_("instance %s: retrieving diagnostics"),
+ instance_ref["internal_id"])
+ return self.driver.get_diagnostics(instance_ref)
+
def suspend_instance(self, context, instance_id):
"""suspend the instance with instance_id"""
context = context.elevated()