summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2011-11-28 14:42:38 -0800
committerVishvananda Ishaya <vishvananda@gmail.com>2011-11-28 15:19:41 -0800
commitcabdc3b1f64b7f022a1c62a4cebce54a2deba807 (patch)
tree1b3d2aeb81e9a87691c81806daf6e6ca8a8206d1
parent9c2e69b4966895fe04edb16158f0199956fda657 (diff)
downloadnova-cabdc3b1f64b7f022a1c62a4cebce54a2deba807.tar.gz
nova-cabdc3b1f64b7f022a1c62a4cebce54a2deba807.tar.xz
nova-cabdc3b1f64b7f022a1c62a4cebce54a2deba807.zip
Makes rpc_allocate_fixed_ip return properly
* Fixes bug 855030 * Includes test Change-Id: If5b874fb0e4abd567445e67141d61942866cc5ec
-rw-r--r--nova/network/manager.py2
-rw-r--r--nova/tests/test_network.py33
2 files changed, 34 insertions, 1 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 96d6dee00..955cca0ce 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -180,7 +180,7 @@ class RPCAllocateFixedIP(object):
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 3b043e793..2fac63244 100644
--- a/nova/tests/test_network.py
+++ b/nova/tests/test_network.py
@@ -1001,6 +1001,39 @@ class CommonNetworkTestCase(test.TestCase):
self.assertEqual(res[0]['instance_id'], _vifs[2]['instance_id'])
+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"""