Skip to content

Commit

Permalink
Makes rpc_allocate_fixed_ip return properly
Browse files Browse the repository at this point in the history
 * Fixes bug 855030
 * Includes test

Change-Id: If5b874fb0e4abd567445e67141d61942866cc5ec
  • Loading branch information
vishvananda committed Nov 28, 2011
1 parent d0b0f76 commit 1e3b88b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nova/network/manager.py
Expand Up @@ -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):
Expand Down
33 changes: 33 additions & 0 deletions nova/tests/test_network.py
Expand Up @@ -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"""
Expand Down

0 comments on commit 1e3b88b

Please sign in to comment.