Add CREATE_PRECOMMIT notification for Floating IPs
This patch is adding a CREATE_PRECOMMIT notification for floating ips. Before it was possible to register a callback for that (no errors) but the notification would never be sent because the code was simple not in place. Closes-Bug: #1736201 Change-Id: If901d4d54118a6343597ab2ad075b6a2399ea62c
This commit is contained in:
parent
c3ab39a279
commit
98dfdc24bb
|
@ -1309,6 +1309,11 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
dns_data = self._process_dns_floatingip_create_precommit(
|
||||
context, floatingip_dict, fip)
|
||||
|
||||
registry.notify(resources.FLOATING_IP, events.PRECOMMIT_CREATE,
|
||||
self, context=context, floatingip=fip,
|
||||
floatingip_id=fip_id,
|
||||
floatingip_db=floatingip_db)
|
||||
|
||||
self._core_plugin.update_port(context.elevated(), external_port['id'],
|
||||
{'port': {'device_id': fip_id}})
|
||||
registry.notify(resources.FLOATING_IP,
|
||||
|
|
|
@ -3591,6 +3591,21 @@ class L3AgentDbTestCaseBase(L3NatTestCaseMixin):
|
|||
def test_floatingips_op_agent(self):
|
||||
self._test_notify_op_agent(self._test_floatingips_op_agent)
|
||||
|
||||
def test_floatingips_create_precommit_event(self):
|
||||
fake_method = mock.Mock()
|
||||
try:
|
||||
registry.subscribe(fake_method, resources.FLOATING_IP,
|
||||
events.PRECOMMIT_CREATE)
|
||||
with self.floatingip_with_assoc() as f:
|
||||
fake_method.assert_called_once_with(
|
||||
resources.FLOATING_IP, events.PRECOMMIT_CREATE, mock.ANY,
|
||||
context=mock.ANY, floatingip=mock.ANY,
|
||||
floatingip_id=f['floatingip']['id'],
|
||||
floatingip_db=mock.ANY)
|
||||
finally:
|
||||
registry.unsubscribe(fake_method, resources.FLOATING_IP,
|
||||
events.PRECOMMIT_CREATE)
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue