From 96134f9e34faf7e4be1776b24c8d8d661a23342a Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 27 Jul 2012 11:58:19 -0400 Subject: Send a full instance in remove_fixed_ip_from_instance. Change the remove_fixed_ip_from_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: Iee0daf068be9814ef0ba06a69111a45a2e198cbb --- nova/compute/manager.py | 18 ++++++++++-------- nova/compute/rpcapi.py | 8 ++++++-- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index b2c9b86f4..ef46b17b6 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.24' + RPC_API_VERSION = '1.25' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -1687,25 +1687,27 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @checks_instance_lock @wrap_instance_fault - def remove_fixed_ip_from_instance(self, context, instance_uuid, address): + def remove_fixed_ip_from_instance(self, context, address, instance=None, + instance_uuid=None): """Calls network_api to remove existing fixed_ip from instance by injecting the altered network info and resetting instance networking. """ - instance_ref = self.db.instance_get_by_uuid(context, instance_uuid) + if not instance: + instance = self.db.instance_get_by_uuid(context, instance_uuid) self._notify_about_instance_usage( - context, instance_ref, "delete_ip.start") + context, instance, "delete_ip.start") self.network_api.remove_fixed_ip_from_instance(context, - instance_ref, + instance, address) network_info = self._inject_network_info(context, - instance=instance_ref) - self.reset_network(context, instance_ref['uuid']) + instance=instance) + self.reset_network(context, instance['uuid']) self._notify_about_instance_usage( - context, instance_ref, "delete_ip.end", network_info=network_info) + context, instance, "delete_ip.end", network_info=network_info) @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 11f95f749..70f3da64c 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -92,6 +92,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): pre_live_migration() 1.24 - Remove instance_uuid, add instance argument to rebuild_instance() + 1.25 - Remove instance_uuid, add instance argument to + remove_fixed_ip_from_instance() ''' BASE_RPC_API_VERSION = '1.0' @@ -326,9 +328,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): topic=_compute_topic(self.topic, ctxt, host, None)) def remove_fixed_ip_from_instance(self, ctxt, instance, address): + instance_p = jsonutils.to_primitive(instance) self.cast(ctxt, self.make_msg('remove_fixed_ip_from_instance', - instance_uuid=instance['uuid'], address=address), - topic=_compute_topic(self.topic, ctxt, None, instance)) + instance=instance_p, address=address), + topic=_compute_topic(self.topic, ctxt, None, instance), + version='1.25') def remove_volume_connection(self, ctxt, instance, volume_id, host): return self.call(ctxt, self.make_msg('remove_volume_connection', -- cgit