summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py17
-rw-r--r--nova/compute/rpcapi.py7
2 files changed, 14 insertions, 10 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 9ebfe496b..368556dea 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -297,7 +297,7 @@ def _get_additional_capabilities():
class ComputeManager(manager.SchedulerDependentManager):
"""Manages the running instances from creation to destruction."""
- RPC_API_VERSION = '1.5'
+ RPC_API_VERSION = '1.6'
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
@@ -1783,22 +1783,23 @@ class ComputeManager(manager.SchedulerDependentManager):
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@checks_instance_lock
@wrap_instance_fault
- def suspend_instance(self, context, instance_uuid):
+ def suspend_instance(self, context, instance=None, instance_uuid=None):
"""Suspend the given instance."""
context = context.elevated()
- instance_ref = self.db.instance_get_by_uuid(context, instance_uuid)
+ if not instance:
+ instance = self.db.instance_get_by_uuid(context, instance_uuid)
- LOG.audit(_('Suspending'), context=context, instance=instance_ref)
- self.driver.suspend(instance_ref)
+ LOG.audit(_('Suspending'), context=context, instance=instance)
+ self.driver.suspend(instance)
- current_power_state = self._get_power_state(context, instance_ref)
+ current_power_state = self._get_power_state(context, instance)
self._instance_update(context,
- instance_ref['uuid'],
+ instance['uuid'],
power_state=current_power_state,
vm_state=vm_states.SUSPENDED,
task_state=None)
- self._notify_about_instance_usage(context, instance_ref, 'suspend')
+ self._notify_about_instance_usage(context, instance, 'suspend')
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@checks_instance_lock
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index d5de04452..c893bb0d5 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -62,6 +62,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.4 - Remove instance_uuid, add instance argument to reboot_instance()
1.5 - Remove instance_uuid, add instance argument to pause_instance(),
unpause_instance()
+ 1.6 - Remove instance_uuid, add instance argument to suspend_instance()
'''
BASE_RPC_API_VERSION = '1.0'
@@ -355,9 +356,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
topic=_compute_topic(self.topic, ctxt, None, instance))
def suspend_instance(self, ctxt, instance):
+ instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('suspend_instance',
- instance_uuid=instance['uuid']),
- topic=_compute_topic(self.topic, ctxt, None, instance))
+ instance=instance_p),
+ topic=_compute_topic(self.topic, ctxt, None, instance),
+ version='1.6')
def terminate_instance(self, ctxt, instance):
self.cast(ctxt, self.make_msg('terminate_instance',