diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-07-31 16:07:57 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-08-01 12:22:53 -0400 |
| commit | 0a956de32c2fa24cf00461803914fe3ffba2b492 (patch) | |
| tree | d84154411e8103b38e86a972203c89e0f681ea5e /nova/compute | |
| parent | a1834b70461a961dbe5adfe5aa54a555c9a0bda0 (diff) | |
Send a full instance in terminate_instance.
Change the terminate_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.
This is the final change for instances in rpcapi.py. \o/
Unfortunately, I discovered that the scheduler isn't properly using
rpc API versioning when talking to compute nodes, so some of the methods
used by the scheduler still need some love.
Part of blueprint no-db-messaging.
Change-Id: Ic62450346ea90b9a6d64e282e992a21a4dd6ab64
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 18 | ||||
| -rw-r--r-- | nova/compute/rpcapi.py | 8 |
2 files changed, 16 insertions, 10 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index f49563871..4540b76cf 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -272,7 +272,7 @@ def _get_image_meta(context, image_ref): class ComputeManager(manager.SchedulerDependentManager): """Manages the running instances from creation to destruction.""" - RPC_API_VERSION = '1.36' + RPC_API_VERSION = '1.37' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -900,21 +900,23 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @checks_instance_lock @wrap_instance_fault - def terminate_instance(self, context, instance_uuid): + def terminate_instance(self, context, instance=None, instance_uuid=None): """Terminate an instance on this host.""" @utils.synchronized(instance_uuid) - def do_terminate_instance(): + def do_terminate_instance(instance, instance_uuid): elevated = context.elevated() - instance = self.db.instance_get_by_uuid(elevated, instance_uuid) + if not instance: + instance = self.db.instance_get_by_uuid(elevated, + instance_uuid) try: self._delete_instance(context, instance) except exception.InstanceTerminationFailure as error: msg = _('%s. Setting instance vm_state to ERROR') - LOG.error(msg % error, instance_uuid=instance_uuid) - self._set_instance_error_state(context, instance_uuid) + LOG.error(msg % error, instance=instance) + self._set_instance_error_state(context, instance['uuid']) except exception.InstanceNotFound as e: - LOG.warn(e, instance_uuid=instance_uuid) - do_terminate_instance() + LOG.warn(e, instance=instance) + do_terminate_instance(instance, instance_uuid) @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 c71b6193e..526654d9f 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -112,6 +112,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): unrescue_instance() 1.36 - Remove instance_uuid, add instance argument to change_instance_metadata() + 1.37 - Remove instance_uuid, add instance argument to + terminate_instance() ''' BASE_RPC_API_VERSION = '1.0' @@ -459,9 +461,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): version='1.6') def terminate_instance(self, ctxt, instance): + instance_p = jsonutils.to_primitive(instance) self.cast(ctxt, self.make_msg('terminate_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.37') def unpause_instance(self, ctxt, instance): instance_p = jsonutils.to_primitive(instance) |
