Merge "Avoid dhcp agent race condition on subnet and network delete"
This commit is contained in:
commit
97308f1b78
@ -1402,6 +1402,14 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
|||||||
with context.session.begin(subtransactions=True):
|
with context.session.begin(subtransactions=True):
|
||||||
self._delete_port(context, id)
|
self._delete_port(context, id)
|
||||||
|
|
||||||
|
def delete_ports(self, context, filters):
|
||||||
|
with context.session.begin(subtransactions=True):
|
||||||
|
ports = self._get_ports_query(
|
||||||
|
context, filters=filters).with_lockmode('update')
|
||||||
|
if ports:
|
||||||
|
for port in ports:
|
||||||
|
self.delete_port(context, port['id'])
|
||||||
|
|
||||||
def _delete_port(self, context, id):
|
def _delete_port(self, context, id):
|
||||||
port = self._get_port(context, id)
|
port = self._get_port(context, id)
|
||||||
|
|
||||||
|
@ -179,10 +179,7 @@ class DhcpRpcCallbackMixin(object):
|
|||||||
{'network_id': network_id, 'host': host})
|
{'network_id': network_id, 'host': host})
|
||||||
plugin = manager.NeutronManager.get_plugin()
|
plugin = manager.NeutronManager.get_plugin()
|
||||||
filters = dict(network_id=[network_id], device_id=[device_id])
|
filters = dict(network_id=[network_id], device_id=[device_id])
|
||||||
ports = plugin.get_ports(context, filters=filters)
|
plugin.delete_ports(context, filters=filters)
|
||||||
|
|
||||||
if ports:
|
|
||||||
plugin.delete_port(context, ports[0]['id'])
|
|
||||||
|
|
||||||
def release_port_fixed_ip(self, context, **kwargs):
|
def release_port_fixed_ip(self, context, **kwargs):
|
||||||
"""Release the fixed_ip associated the subnet on a port."""
|
"""Release the fixed_ip associated the subnet on a port."""
|
||||||
|
@ -131,9 +131,9 @@ class TestDhcpRpcCallackMixin(base.BaseTestCase):
|
|||||||
device_id='devid')
|
device_id='devid')
|
||||||
|
|
||||||
self.plugin.assert_has_calls([
|
self.plugin.assert_has_calls([
|
||||||
mock.call.get_ports(mock.ANY, filters=dict(network_id=['netid'],
|
mock.call.delete_ports(mock.ANY,
|
||||||
device_id=['devid'])),
|
filters=dict(network_id=['netid'],
|
||||||
mock.call.delete_port(mock.ANY, 'port_id')])
|
device_id=['devid']))])
|
||||||
|
|
||||||
def test_release_port_fixed_ip(self):
|
def test_release_port_fixed_ip(self):
|
||||||
port_retval = dict(id='port_id', fixed_ips=[dict(subnet_id='a')])
|
port_retval = dict(id='port_id', fixed_ips=[dict(subnet_id='a')])
|
||||||
|
Loading…
Reference in New Issue
Block a user