Merge "Pass context in l3 flavor notifications" into stable/rocky
This commit is contained in:
commit
bf4498296e
|
@ -195,7 +195,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
self._core_plugin.delete_port(
|
||||
context, port_id, l3_port_check=False)
|
||||
registry.notify(resources.FLOATING_IP, events.AFTER_DELETE,
|
||||
self, **fips[0])
|
||||
self, context=context, **fips[0])
|
||||
|
||||
def _get_dead_floating_port_candidates(self, context):
|
||||
filters = {'device_id': ['PENDING'],
|
||||
|
@ -515,6 +515,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
registry.notify(resources.ROUTER_GATEWAY,
|
||||
events.AFTER_CREATE,
|
||||
self._create_gw_port,
|
||||
context=context,
|
||||
gw_ips=ext_ips,
|
||||
network_id=new_network_id,
|
||||
router_id=router_id)
|
||||
|
@ -1538,7 +1539,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
floatingip.floating_port_id,
|
||||
l3_port_check=False)
|
||||
registry.notify(resources.FLOATING_IP, events.AFTER_DELETE,
|
||||
self, **floatingip_dict)
|
||||
self, context=context, **floatingip_dict)
|
||||
return floatingip_dict
|
||||
|
||||
@db_api.retry_if_session_inactive()
|
||||
|
|
|
@ -1943,6 +1943,22 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||
network_id=n['network']['id'],
|
||||
subnets=[])
|
||||
|
||||
def test_router_add_gateway_notifications(self):
|
||||
call_count_total = 3
|
||||
with self.router() as r:
|
||||
with self.network() as n:
|
||||
self._set_net_external(n['network']['id'])
|
||||
with mock.patch.object(registry, 'notify') as notify:
|
||||
self._add_external_gateway_to_router(
|
||||
r['router']['id'], n['network']['id'])
|
||||
self.assertEqual(call_count_total, notify.call_count)
|
||||
expected = [mock.call(
|
||||
resources.ROUTER_GATEWAY,
|
||||
events.AFTER_CREATE, mock.ANY,
|
||||
context=mock.ANY, gw_ips=mock.ANY,
|
||||
network_id=mock.ANY, router_id=mock.ANY)]
|
||||
notify.assert_has_calls(expected)
|
||||
|
||||
def test_router_remove_interface_inuse_returns_409(self):
|
||||
with self.router() as r:
|
||||
with self.subnet() as s:
|
||||
|
@ -3754,6 +3770,36 @@ class L3AgentDbTestCaseBase(L3NatTestCaseMixin):
|
|||
registry.unsubscribe(fake_method, resources.FLOATING_IP,
|
||||
events.PRECOMMIT_CREATE)
|
||||
|
||||
def test_floatingip_delete_after_event(self):
|
||||
fake_method = mock.Mock()
|
||||
try:
|
||||
registry.subscribe(fake_method, resources.FLOATING_IP,
|
||||
events.AFTER_DELETE)
|
||||
with self.subnet(cidr='11.0.0.0/24') as public_sub:
|
||||
self._set_net_external(public_sub['subnet']['network_id'])
|
||||
f = self._make_floatingip(self.fmt,
|
||||
public_sub['subnet']['network_id'],
|
||||
port_id=None,
|
||||
fixed_ip=None,
|
||||
set_context=True)
|
||||
self._delete('floatingips', f['floatingip']['id'])
|
||||
fake_method.assert_called_once_with(
|
||||
resources.FLOATING_IP, events.AFTER_DELETE, mock.ANY,
|
||||
context=mock.ANY, description=mock.ANY,
|
||||
dns_domain=mock.ANY, dns_name=mock.ANY,
|
||||
fixed_ip_address=f['floatingip']['fixed_ip_address'],
|
||||
floating_ip_address=f['floatingip']['floating_ip_address'],
|
||||
floating_network_id=f['floatingip']['floating_network_id'],
|
||||
id=f['floatingip']['id'],
|
||||
port_id=f['floatingip']['port_id'],
|
||||
project_id=f['floatingip']['project_id'],
|
||||
router_id=f['floatingip']['router_id'],
|
||||
status=f['floatingip']['status'],
|
||||
tenant_id=f['floatingip']['tenant_id'])
|
||||
finally:
|
||||
registry.unsubscribe(fake_method, resources.FLOATING_IP,
|
||||
events.AFTER_DELETE)
|
||||
|
||||
def test_router_create_precommit_event(self):
|
||||
nset = lambda *a, **k: setattr(k['router_db'], 'name', 'hello')
|
||||
registry.subscribe(nset, resources.ROUTER, events.PRECOMMIT_CREATE)
|
||||
|
|
|
@ -1887,6 +1887,23 @@ class TestMl2DvrPortsV2(TestMl2PortsV2):
|
|||
def test_delete_port_with_floatingip_notifies_l3_plugin(self):
|
||||
self.test_delete_port_notifies_l3_plugin(floating_ip=True)
|
||||
|
||||
def test_delete_port_with_floatingip_create_precommit_event(self):
|
||||
fake_method = mock.Mock()
|
||||
with self.port(device_owner='network:floatingip') as port:
|
||||
try:
|
||||
registry.subscribe(fake_method, resources.FLOATING_IP,
|
||||
events.PRECOMMIT_DELETE)
|
||||
port_id = port['port']['id']
|
||||
self.plugin.delete_port(self.context, port_id)
|
||||
fake_method.assert_called_once_with(
|
||||
resources.FLOATING_IP, events.PRECOMMIT_DELETE, mock.ANY,
|
||||
bind=mock.ANY, bindings=mock.ANY, context=mock.ANY,
|
||||
id=mock.ANY, levels=mock.ANY, network=mock.ANY,
|
||||
port=mock.ANY, port_db=mock.ANY)
|
||||
finally:
|
||||
registry.unsubscribe(fake_method, resources.FLOATING_IP,
|
||||
events.PRECOMMIT_DELETE)
|
||||
|
||||
def test_concurrent_csnat_port_delete(self):
|
||||
plugin = directory.get_plugin(plugin_constants.L3)
|
||||
r = plugin.create_router(
|
||||
|
|
Loading…
Reference in New Issue