Make nova-network use FixedIP object for disassociations
This makes nova-network mananger use the FixedIP object for disassociating IPs. Related to blueprint nova-network-objects Change-Id: Ia0a38bbd31cc22095893bff89bcaa402a9bc2722
This commit is contained in:
parent
8bc9586056
commit
79121d9a11
nova
@ -795,7 +795,7 @@ class NetworkManager(manager.Manager):
|
||||
# case that this is a race condition, we
|
||||
# will just get a warn in lease or release.
|
||||
if not fixed_ip.leased:
|
||||
self.db.fixed_ip_disassociate(context, address)
|
||||
fixed_ip.disassociate()
|
||||
return self.get_instance_nw_info(context, instance_id,
|
||||
rxtx_factor, host)
|
||||
raise exception.FixedIpNotFoundForSpecificInstance(
|
||||
@ -956,8 +956,7 @@ class NetworkManager(manager.Manager):
|
||||
context, address)
|
||||
if (instance_uuid == fixed_ip_ref.instance_uuid and
|
||||
not fixed_ip_ref.leased):
|
||||
self.db.fixed_ip_disassociate(context, address)
|
||||
|
||||
fixed_ip_ref.disassociate()
|
||||
else:
|
||||
# We can't try to free the IP address so just call teardown
|
||||
self._teardown_network_on_host(context, network)
|
||||
@ -1000,7 +999,7 @@ class NetworkManager(manager.Manager):
|
||||
fixed_ip.address,
|
||||
{'leased': False})
|
||||
if not fixed_ip.allocated:
|
||||
self.db.fixed_ip_disassociate(context, address)
|
||||
fixed_ip.disassociate()
|
||||
|
||||
@staticmethod
|
||||
def _convert_int_args(kwargs):
|
||||
@ -1513,7 +1512,7 @@ class FlatManager(NetworkManager):
|
||||
"""Returns a fixed ip to the pool."""
|
||||
super(FlatManager, self).deallocate_fixed_ip(context, address, host,
|
||||
teardown)
|
||||
self.db.fixed_ip_disassociate(context, address)
|
||||
fixed_ip_obj.FixedIP.disassociate_by_address(context, address)
|
||||
|
||||
def _setup_network_on_host(self, context, network):
|
||||
"""Setup Network on this host."""
|
||||
|
@ -1525,7 +1525,8 @@ class CommonNetworkTestCase(test.TestCase):
|
||||
], manager.deallocate_fixed_ip_calls)
|
||||
|
||||
@mock.patch('nova.db.fixed_ip_get_by_instance')
|
||||
def test_remove_fixed_ip_from_instance(self, get):
|
||||
@mock.patch('nova.db.fixed_ip_disassociate')
|
||||
def test_remove_fixed_ip_from_instance(self, disassociate, get):
|
||||
manager = fake_network.FakeNetworkManager()
|
||||
get.return_value = [
|
||||
dict(test_fixed_ip.fake_fixed_ip, **x)
|
||||
@ -1536,6 +1537,7 @@ class CommonNetworkTestCase(test.TestCase):
|
||||
'10.0.0.1')
|
||||
|
||||
self.assertEqual(manager.deallocate_called, '10.0.0.1')
|
||||
disassociate.assert_called_once_with(self.context, '10.0.0.1')
|
||||
|
||||
@mock.patch('nova.db.fixed_ip_get_by_instance')
|
||||
def test_remove_fixed_ip_from_instance_bad_input(self, get):
|
||||
|
Loading…
x
Reference in New Issue
Block a user