diff options
author | Dan Smith <danms@us.ibm.com> | 2013-02-21 15:09:29 -0500 |
---|---|---|
committer | Dan Smith <danms@us.ibm.com> | 2013-02-26 09:57:43 -0500 |
commit | 394c693e359ed4f19cc2f7d975b1f9ee5500b7f6 (patch) | |
tree | 59e3b02ed9efb2883fd5c373e62bef4b025d4262 /nova/tests | |
parent | cdf5e432de2cf1c0c5466470a6a0bccf999fcdd4 (diff) | |
download | nova-394c693e359ed4f19cc2f7d975b1f9ee5500b7f6.tar.gz nova-394c693e359ed4f19cc2f7d975b1f9ee5500b7f6.tar.xz nova-394c693e359ed4f19cc2f7d975b1f9ee5500b7f6.zip |
Make allocate_for_instance() return only info about ports allocated
Previously, the compute manager was filtering the results based on the
port id that the user requested. However, if they do not pass one (which
is valid) then we can not do the filter and we fail. This makes the
allocation function do the filtering, which should not affect the normal
use case where it is only called once, since all the ports returned were
allocated at that time.
The manager filter behavior is thus removed and a test is added to
verify that the allocate method does the right thing the second time
around.
This fixes the fallout found after fixing the actual cause of bug 1131264
Change-Id: I8f3af96051268503596007491af365e8ce28f5b3
Diffstat (limited to 'nova/tests')
-rw-r--r-- | nova/tests/network/test_quantumv2.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/nova/tests/network/test_quantumv2.py b/nova/tests/network/test_quantumv2.py index a168e451f..47798e70d 100644 --- a/nova/tests/network/test_quantumv2.py +++ b/nova/tests/network/test_quantumv2.py @@ -227,6 +227,7 @@ class TestQuantumv2(test.TestCase): 'port_id': self.port_data2[1]['id'], 'fixed_ip_address': fixed_ip_address, 'router_id': 'router_id1'} + self._returned_nw_info = [] def tearDown(self): self.addCleanup(CONF.reset) @@ -457,13 +458,14 @@ class TestQuantumv2(test.TestCase): api.get_instance_nw_info(mox.IgnoreArg(), self.instance, networks=nets, - conductor_api=mox.IgnoreArg()).AndReturn(None) + conductor_api=mox.IgnoreArg()).AndReturn( + self._returned_nw_info) self.mox.ReplayAll() return api def _allocate_for_instance(self, net_idx=1, **kwargs): api = self._stub_allocate_for_instance(net_idx, **kwargs) - api.allocate_for_instance(self.context, self.instance, **kwargs) + return api.allocate_for_instance(self.context, self.instance, **kwargs) def test_allocate_for_instance_1(self): # Allocate one port in one network env. @@ -646,6 +648,14 @@ class TestQuantumv2(test.TestCase): self.context, self.instance, requested_networks=[(None, None, None)]) + def test_allocate_for_instance_second_time(self): + # Make sure that allocate_for_instance only returns ports that it + # allocated during _that_ run. + new_port = {'id': 'fake'} + self._returned_nw_info = self.port_data1 + [new_port] + nw_info = self._allocate_for_instance() + self.assertEqual(nw_info, [new_port]) + def _deallocate_for_instance(self, number): port_data = number == 1 and self.port_data1 or self.port_data2 self.moxed_client.list_ports( |