diff --git a/nova/network/manager.py b/nova/network/manager.py index c6155f2a635..4fa4d475df3 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -179,7 +179,7 @@ def _rpc_allocate_fixed_ip(self, context, instance_id, network_id, perform network lookup on the far side of rpc. """ network = self.db.network_get(context, network_id) - self.allocate_fixed_ip(context, instance_id, network, **kwargs) + return self.allocate_fixed_ip(context, instance_id, network, **kwargs) class FloatingIP(object): diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index dbf934e6761..32502eafa9a 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -731,6 +731,39 @@ def test_create_networks_many(self): self.assertTrue(manager.create_networks(*args)) +class TestRPCFixedManager(network_manager.RPCAllocateFixedIP, + network_manager.NetworkManager): + """Dummy manager that implements RPCAllocateFixedIP""" + + +class RPCAllocateTestCase(test.TestCase): + """Tests nova.network.manager.RPCAllocateFixedIP""" + def setUp(self): + super(RPCAllocateTestCase, self).setUp() + self.rpc_fixed = TestRPCFixedManager() + self.context = context.RequestContext('fake', 'fake') + + def test_rpc_allocate(self): + """Test to verify bug 855030 doesn't resurface. + + Mekes sure _rpc_allocate_fixed_ip returns a value so the call + returns properly and the greenpool completes.""" + address = '10.10.10.10' + + def fake_allocate(*args, **kwargs): + return address + + def fake_network_get(*args, **kwargs): + return {} + + self.stubs.Set(self.rpc_fixed, 'allocate_fixed_ip', fake_allocate) + self.stubs.Set(self.rpc_fixed.db, 'network_get', fake_network_get) + rval = self.rpc_fixed._rpc_allocate_fixed_ip(self.context, + 'fake_instance', + 'fake_network') + self.assertEqual(rval, address) + + class TestFloatingIPManager(network_manager.FloatingIP, network_manager.NetworkManager): """Dummy manager that implements FloatingIP"""