Merge "use payloads for all SUBNETPOOL_ADDRESS_SCOPE events"
This commit is contained in:
commit
f3810d0da3
@ -1207,11 +1207,11 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
|
|
||||||
if address_scope_changed:
|
if address_scope_changed:
|
||||||
# Notify about the update of subnetpool's address scope
|
# Notify about the update of subnetpool's address scope
|
||||||
kwargs = {'context': context, 'subnetpool_id': id}
|
registry.publish(resources.SUBNETPOOL_ADDRESS_SCOPE,
|
||||||
registry.notify(resources.SUBNETPOOL_ADDRESS_SCOPE,
|
events.AFTER_UPDATE,
|
||||||
events.AFTER_UPDATE,
|
self.update_subnetpool,
|
||||||
self.update_subnetpool,
|
payload=events.DBEventPayload(
|
||||||
**kwargs)
|
context, resource_id=id))
|
||||||
|
|
||||||
for key in ['min_prefixlen', 'max_prefixlen', 'default_prefixlen']:
|
for key in ['min_prefixlen', 'max_prefixlen', 'default_prefixlen']:
|
||||||
updated['key'] = str(updated[key])
|
updated['key'] = str(updated[key])
|
||||||
|
@ -1965,9 +1965,9 @@ class L3RpcNotifierMixin(object):
|
|||||||
@registry.receives(resources.SUBNETPOOL_ADDRESS_SCOPE,
|
@registry.receives(resources.SUBNETPOOL_ADDRESS_SCOPE,
|
||||||
[events.AFTER_UPDATE])
|
[events.AFTER_UPDATE])
|
||||||
def _notify_subnetpool_address_scope_update(resource, event,
|
def _notify_subnetpool_address_scope_update(resource, event,
|
||||||
trigger, **kwargs):
|
trigger, payload=None):
|
||||||
context = kwargs['context']
|
context = payload.context
|
||||||
subnetpool_id = kwargs['subnetpool_id']
|
subnetpool_id = payload.resource_id
|
||||||
|
|
||||||
router_ids = l3_obj.RouterPort.get_router_ids_by_subnetpool(
|
router_ids = l3_obj.RouterPort.get_router_ids_by_subnetpool(
|
||||||
context, subnetpool_id)
|
context, subnetpool_id)
|
||||||
|
@ -241,10 +241,10 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
|||||||
@mock.patch.object(directory, 'get_plugin')
|
@mock.patch.object(directory, 'get_plugin')
|
||||||
def test_subscribe_address_scope_of_subnetpool(self, gp):
|
def test_subscribe_address_scope_of_subnetpool(self, gp):
|
||||||
l3_db.L3RpcNotifierMixin()
|
l3_db.L3RpcNotifierMixin()
|
||||||
registry.notify(resources.SUBNETPOOL_ADDRESS_SCOPE,
|
registry.publish(resources.SUBNETPOOL_ADDRESS_SCOPE,
|
||||||
events.AFTER_UPDATE, mock.ANY,
|
events.AFTER_UPDATE, mock.ANY,
|
||||||
context=mock.MagicMock(),
|
payload=events.DBEventPayload(
|
||||||
subnetpool_id='fake_id')
|
mock.MagicMock(), resource_id='fake_id'))
|
||||||
self.assertTrue(gp.return_value.notify_routers_updated.called)
|
self.assertTrue(gp.return_value.notify_routers_updated.called)
|
||||||
|
|
||||||
def test__check_and_get_fip_assoc_with_extra_association_no_change(self):
|
def test__check_and_get_fip_assoc_with_extra_association_no_change(self):
|
||||||
|
@ -388,7 +388,7 @@ class TestSubnetPoolsWithAddressScopes(AddressScopeTestCase):
|
|||||||
subnet = self.deserialize(self.fmt,
|
subnet = self.deserialize(self.fmt,
|
||||||
req.get_response(self.api))
|
req.get_response(self.api))
|
||||||
|
|
||||||
with mock.patch.object(registry, 'notify') as notify:
|
with mock.patch.object(registry, 'publish') as publish:
|
||||||
plugin = db_base_plugin_v2.NeutronDbPluginV2()
|
plugin = db_base_plugin_v2.NeutronDbPluginV2()
|
||||||
plugin.is_address_scope_owned_by_tenant = mock.Mock(
|
plugin.is_address_scope_owned_by_tenant = mock.Mock(
|
||||||
return_value=True)
|
return_value=True)
|
||||||
@ -408,15 +408,17 @@ class TestSubnetPoolsWithAddressScopes(AddressScopeTestCase):
|
|||||||
if as_change:
|
if as_change:
|
||||||
self.assertEqual(bar_as_id,
|
self.assertEqual(bar_as_id,
|
||||||
updated_sp['address_scope_id'])
|
updated_sp['address_scope_id'])
|
||||||
notify.assert_called_once_with(
|
publish.assert_called_once_with(
|
||||||
resources.SUBNETPOOL_ADDRESS_SCOPE,
|
resources.SUBNETPOOL_ADDRESS_SCOPE,
|
||||||
events.AFTER_UPDATE,
|
events.AFTER_UPDATE,
|
||||||
plugin.update_subnetpool, context=ctx,
|
plugin.update_subnetpool, payload=mock.ANY)
|
||||||
subnetpool_id=subnetpool_id)
|
payload = publish.mock_calls[0][2]['payload']
|
||||||
|
self.assertEqual(ctx, payload.context)
|
||||||
|
self.assertEqual(subnetpool_id, payload.resource_id)
|
||||||
else:
|
else:
|
||||||
self.assertEqual(foo_as_id,
|
self.assertEqual(foo_as_id,
|
||||||
updated_sp['address_scope_id'])
|
updated_sp['address_scope_id'])
|
||||||
self.assertFalse(notify.called)
|
self.assertFalse(publish.called)
|
||||||
|
|
||||||
def test_update_subnetpool_address_scope_notify(self):
|
def test_update_subnetpool_address_scope_notify(self):
|
||||||
self._test_update_subnetpool_address_scope_notify()
|
self._test_update_subnetpool_address_scope_notify()
|
||||||
|
@ -3623,7 +3623,8 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
|||||||
router['router']['id'], {'subnet_id': subnet['subnet']['id']})
|
router['router']['id'], {'subnet_id': subnet['subnet']['id']})
|
||||||
l3_db.L3RpcNotifierMixin._notify_subnetpool_address_scope_update(
|
l3_db.L3RpcNotifierMixin._notify_subnetpool_address_scope_update(
|
||||||
mock.ANY, mock.ANY, mock.ANY,
|
mock.ANY, mock.ANY, mock.ANY,
|
||||||
context=admin_ctx, subnetpool_id=subnetpool_id)
|
payload=events.DBEventPayload(
|
||||||
|
admin_ctx, resource_id=subnetpool_id))
|
||||||
chk_method.assert_called_with(admin_ctx, [router['router']['id']])
|
chk_method.assert_called_with(admin_ctx, [router['router']['id']])
|
||||||
|
|
||||||
def test_janitor_clears_orphaned_floatingip_port(self):
|
def test_janitor_clears_orphaned_floatingip_port(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user