summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTushar Patil <tushar.vitthal.patil@gmail.com>2011-09-08 21:11:52 +0000
committerTarmac <>2011-09-08 21:11:52 +0000
commit67534d897896c2b3ebddcac9be86f669c431a7c2 (patch)
treee215e99d51543b1de84e8d7d1edd66c72688f23c
parentb48ccfdfbc42f399aaeb29e5305c3855a719b02d (diff)
parent34baac0f11ff2084caa46a533aad411988e1541e (diff)
downloadnova-67534d897896c2b3ebddcac9be86f669c431a7c2.tar.gz
nova-67534d897896c2b3ebddcac9be86f669c431a7c2.tar.xz
nova-67534d897896c2b3ebddcac9be86f669c431a7c2.zip
NetworkManager's add_fixed_ip_to_instance calls _allocate_fixed_ips without vpn or requested_networks parameters. If vpn or requested_networks is not provided to the _allocate_fixed_ips method, it throws an exception. This issue is fixed now.
-rw-r--r--nova/network/manager.py6
-rw-r--r--nova/tests/test_network.py58
2 files changed, 59 insertions, 5 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py
index a7bdcbc30..05d928fab 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -128,8 +128,8 @@ class RPCAllocateFixedIP(object):
"""Calls allocate_fixed_ip once for each network."""
green_pool = greenpool.GreenPool()
- vpn = kwargs.pop('vpn')
- requested_networks = kwargs.pop('requested_networks')
+ vpn = kwargs.get('vpn')
+ requested_networks = kwargs.get('requested_networks')
for network in networks:
address = None
@@ -904,7 +904,7 @@ class FlatManager(NetworkManager):
def _allocate_fixed_ips(self, context, instance_id, host, networks,
**kwargs):
"""Calls allocate_fixed_ip once for each network."""
- requested_networks = kwargs.pop('requested_networks')
+ requested_networks = kwargs.get('requested_networks')
for network in networks:
address = None
if requested_networks is not None:
diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py
index 2ae5a35e3..3bdcdbb65 100644
--- a/nova/tests/test_network.py
+++ b/nova/tests/test_network.py
@@ -58,7 +58,7 @@ networks = [{'id': 0,
'dns1': '192.168.0.1',
'dns2': '192.168.0.2',
'vlan': None,
- 'host': None,
+ 'host': HOST,
'project_id': 'fake_project',
'vpn_public_address': '192.168.0.2'},
{'id': 1,
@@ -78,7 +78,7 @@ networks = [{'id': 0,
'dns1': '192.168.0.1',
'dns2': '192.168.0.2',
'vlan': None,
- 'host': None,
+ 'host': HOST,
'project_id': 'fake_project',
'vpn_public_address': '192.168.1.2'}]
@@ -252,6 +252,34 @@ class FlatNetworkTestCase(test.TestCase):
self.network.validate_networks(None, requested_networks)
+ def test_add_fixed_ip_instance_without_vpn_requested_networks(self):
+ self.mox.StubOutWithMock(db, 'network_get')
+ self.mox.StubOutWithMock(db, 'network_update')
+ self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
+ self.mox.StubOutWithMock(db, 'instance_get')
+ self.mox.StubOutWithMock(db,
+ 'virtual_interface_get_by_instance_and_network')
+ self.mox.StubOutWithMock(db, 'fixed_ip_update')
+
+ db.fixed_ip_update(mox.IgnoreArg(),
+ mox.IgnoreArg(),
+ mox.IgnoreArg())
+ db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
+ mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
+
+ db.instance_get(mox.IgnoreArg(),
+ mox.IgnoreArg()).AndReturn({'security_groups':
+ [{'id': 0}]})
+ db.fixed_ip_associate_pool(mox.IgnoreArg(),
+ mox.IgnoreArg(),
+ mox.IgnoreArg()).AndReturn('192.168.0.101')
+ db.network_get(mox.IgnoreArg(),
+ mox.IgnoreArg()).AndReturn(networks[0])
+ db.network_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
+ self.mox.ReplayAll()
+ self.network.add_fixed_ip_to_instance(self.context, 1, HOST,
+ networks[0]['id'])
+
class VlanNetworkTestCase(test.TestCase):
def setUp(self):
@@ -392,6 +420,32 @@ class VlanNetworkTestCase(test.TestCase):
mox.IgnoreArg(),
mox.IgnoreArg())
+ def test_add_fixed_ip_instance_without_vpn_requested_networks(self):
+ self.mox.StubOutWithMock(db, 'network_get')
+ self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
+ self.mox.StubOutWithMock(db, 'instance_get')
+ self.mox.StubOutWithMock(db,
+ 'virtual_interface_get_by_instance_and_network')
+ self.mox.StubOutWithMock(db, 'fixed_ip_update')
+
+ db.fixed_ip_update(mox.IgnoreArg(),
+ mox.IgnoreArg(),
+ mox.IgnoreArg())
+ db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
+ mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
+
+ db.instance_get(mox.IgnoreArg(),
+ mox.IgnoreArg()).AndReturn({'security_groups':
+ [{'id': 0}]})
+ db.fixed_ip_associate_pool(mox.IgnoreArg(),
+ mox.IgnoreArg(),
+ mox.IgnoreArg()).AndReturn('192.168.0.101')
+ db.network_get(mox.IgnoreArg(),
+ mox.IgnoreArg()).AndReturn(networks[0])
+ self.mox.ReplayAll()
+ self.network.add_fixed_ip_to_instance(self.context, 1, HOST,
+ networks[0]['id'])
+
class CommonNetworkTestCase(test.TestCase):