summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-08-31 18:36:38 +0000
committerGerrit Code Review <review@openstack.org>2012-08-31 18:36:38 +0000
commit882b483f8ec7efc5c4f4981dfc300b643e252548 (patch)
treedd432af3b42905066083d31116f3010fbde24b4b /nova
parentb2791c504e6cb8d00ed2f4a5c1a94b2ce968dd14 (diff)
parentcda9b490eb601fe846061720c5c66a46dc74048b (diff)
Merge "Fix deallocate_fixed_ip invocation"
Diffstat (limited to 'nova')
-rw-r--r--nova/network/manager.py3
-rw-r--r--nova/tests/fake_network.py4
-rw-r--r--nova/tests/network/test_manager.py16
3 files changed, 22 insertions, 1 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py
index dfd6ca2ff..f2af017df 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -1000,7 +1000,8 @@ 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'])
+ self.deallocate_fixed_ip(context, fixed_ip['address'],
+ host=kwargs.get('host'))
# deallocate vifs (mac addresses)
self.db.virtual_interface_delete_by_instance(read_deleted_context,
diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py
index ede005840..25ec5c070 100644
--- a/nova/tests/fake_network.py
+++ b/nova/tests/fake_network.py
@@ -143,8 +143,12 @@ class FakeNetworkManager(network_manager.NetworkManager):
def __init__(self):
self.db = self.FakeDB()
self.deallocate_called = None
+ self.deallocate_fixed_ip_calls = []
+ # TODO(matelakat) method signature should align with the faked one's
def deallocate_fixed_ip(self, context, address=None, host=None):
+ self.deallocate_fixed_ip_calls.append((context, address, host))
+ # TODO(matelakat) use the deallocate_fixed_ip_calls instead
self.deallocate_called = address
def _create_fixed_ips(self, context, network_id, fixed_cidr=None):
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py
index 5ae8cf81c..bfe8d7a3b 100644
--- a/nova/tests/network/test_manager.py
+++ b/nova/tests/network/test_manager.py
@@ -1063,6 +1063,22 @@ class CommonNetworkTestCase(test.TestCase):
def fake_create_fixed_ips(self, context, network_id, fixed_cidr=None):
return None
+ def test_deallocate_for_instance_passes_host_info(self):
+ manager = fake_network.FakeNetworkManager()
+ db = manager.db
+ db.instance_get = lambda _x, _y: dict(uuid='ignoreduuid')
+ db.virtual_interface_delete_by_instance = lambda _x, _y: None
+ ctx = context.RequestContext('igonre', 'igonre')
+
+ db.fixed_ip_get_by_instance = lambda x, y: [dict(address='1.2.3.4')]
+
+ manager.deallocate_for_instance(
+ ctx, instance_id='ignore', host='somehost')
+
+ self.assertEquals([
+ (ctx, '1.2.3.4', 'somehost')
+ ], manager.deallocate_fixed_ip_calls)
+
def test_remove_fixed_ip_from_instance(self):
manager = fake_network.FakeNetworkManager()
manager.remove_fixed_ip_from_instance(self.context, 99, HOST,