From 32b0346eb40a94ec6def3eed01e9424b0c660c53 Mon Sep 17 00:00:00 2001 From: Yun Mao Date: Thu, 23 Aug 2012 16:37:42 -0400 Subject: Fix deallocate_fixed_ip() call by unifying signature deallocate_fixed_ip() is defined in 3 classes with incompatible signatures: RPCAllocateFixedIP: deallocate_fixed_ip(self, context, address, host, **kwargs) NetworkManager: deallocate_fixed_ip(self, context, address, **kwargs) FlatManager: deallocate_fixed_ip(self, context, address, **kwargs) There is a non-trivial multiple inheritance relationship among them. The complication leads to incorrect function call signatures (see bug 1024789). The kwargs magic is also never used, and discarded during rpc calls anyway. This patch makes the call signature exactly the same for all deallocate_fixed_ip() definitions, drops kwargs and fixes bug 1024789. Change-Id: I9c139810d4a5c93fa9f50b89a07bfe44e73e6c8a --- nova/network/manager.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index c1f3a6418..20120406e 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -228,7 +228,7 @@ class RPCAllocateFixedIP(object): network = self._get_network_by_id(context, network_id) return self.allocate_fixed_ip(context, instance_id, network, **kwargs) - def deallocate_fixed_ip(self, context, address, host, **kwargs): + def deallocate_fixed_ip(self, context, address, host=None): """Call the superclass deallocate_fixed_ip if i'm the correct host otherwise call to the correct host""" fixed_ip = self.db.fixed_ip_get_by_address(context, address) @@ -998,7 +998,7 @@ class NetworkManager(manager.SchedulerDependentManager): context=read_deleted_context) # deallocate fixed ips for fixed_ip in fixed_ips: - self.deallocate_fixed_ip(context, fixed_ip['address'], **kwargs) + self.deallocate_fixed_ip(context, fixed_ip['address']) # deallocate vifs (mac addresses) self.db.virtual_interface_delete_by_instance(read_deleted_context, @@ -1269,7 +1269,7 @@ class NetworkManager(manager.SchedulerDependentManager): self._setup_network_on_host(context, network) return address - def deallocate_fixed_ip(self, context, address, **kwargs): + def deallocate_fixed_ip(self, context, address, host=None): """Returns a fixed ip to the pool.""" fixed_ip_ref = self.db.fixed_ip_get_by_address(context, address) vif_id = fixed_ip_ref['virtual_interface_id'] @@ -1733,10 +1733,9 @@ class FlatManager(NetworkManager): self.allocate_fixed_ip(context, instance_id, network, address=address) - def deallocate_fixed_ip(self, context, address, **kwargs): + def deallocate_fixed_ip(self, context, address, host=None): """Returns a fixed ip to the pool.""" - super(FlatManager, self).deallocate_fixed_ip(context, address, - **kwargs) + super(FlatManager, self).deallocate_fixed_ip(context, address) self.db.fixed_ip_disassociate(context, address) def _setup_network_on_host(self, context, network): -- cgit