diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-07-20 15:58:49 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-07-25 20:00:45 -0400 |
| commit | 1d0362929d2bbb39a5665b0d0ce9972ca66c643b (patch) | |
| tree | 32be2f7116052c8c055a332c7adc10863d9e91d8 /nova/compute | |
| parent | 94018d1f753d62ba75f3262f2c2fcdb1ee7f731b (diff) | |
Send a full instance via rpc for suspend_instance.
Change the suspend_instance method of the compute rpc API to take a full
instance over rpc instead of just the instance UUID. This cuts down on
database access needed by nova-compute.
Part of blueprint no-db-messaging.
Change-Id: If881fb419a52a2486b2e7b85b4d58a17f72c48a6
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 17 | ||||
| -rw-r--r-- | nova/compute/rpcapi.py | 7 |
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', |
