From: Eoghan Glynn Date: Tue, 26 Mar 2013 16:27:05 +0000 (+0000) Subject: Add expected IDs to router.interface.* notifications X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=1daf927c9df046c17a8c3f07350f60cf488a4215;p=openstack-build%2Fneutron-build.git Add expected IDs to router.interface.* notifications Fixes bug 1160431 The router.interface.{create|delete} notifications are intended to be consumed by ceilometer, but did not include the router or tenant IDs in the RPC message payload. Ceilometer requires both these data for metering purposes. The missing UUIDs are now provided in the notifications. Change-Id: I1ca6e1d5377100a0549293e0bdff0182711c750f --- diff --git a/quantum/db/l3_db.py b/quantum/db/l3_db.py index e7e4849af..48e202f57 100644 --- a/quantum/db/l3_db.py +++ b/quantum/db/l3_db.py @@ -365,7 +365,9 @@ class L3_NAT_db_mixin(l3.RouterPluginBase): context, routers, 'add_router_interface', {'network_id': port['network_id'], 'subnet_id': subnet_id}) - info = {'port_id': port['id'], + info = {'id': router_id, + 'tenant_id': subnet['tenant_id'], + 'port_id': port['id'], 'subnet_id': port['fixed_ips'][0]['subnet_id']} notifier_api.notify(context, notifier_api.publisher_id('network'), @@ -402,6 +404,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase): port_id=port_id, subnet_id=interface_info['subnet_id']) subnet_id = port_db['fixed_ips'][0]['subnet_id'] + subnet = self._get_subnet(context, subnet_id) self._confirm_router_interface_not_in_use( context, router_id, subnet_id) _network_id = port_db['network_id'] @@ -439,13 +442,15 @@ class L3_NAT_db_mixin(l3.RouterPluginBase): context, routers, 'remove_router_interface', {'network_id': _network_id, 'subnet_id': subnet_id}) + info = {'id': router_id, + 'tenant_id': subnet['tenant_id'], + 'port_id': port_id, + 'subnet_id': subnet_id} notifier_api.notify(context, notifier_api.publisher_id('network'), 'router.interface.delete', notifier_api.CONF.default_notification_level, - {'router.interface': - {'port_id': port_id, - 'subnet_id': subnet_id}}) + {'router.interface': info}) def _get_floatingip(self, context, id): try: diff --git a/quantum/tests/unit/test_l3_plugin.py b/quantum/tests/unit/test_l3_plugin.py index 703686b24..df3af357c 100644 --- a/quantum/tests/unit/test_l3_plugin.py +++ b/quantum/tests/unit/test_l3_plugin.py @@ -669,6 +669,18 @@ class L3NatDBTestCase(L3NatTestCaseBase): set(n['event_type'] for n in test_notifier.NOTIFICATIONS), set(exp_notifications)) + for n in test_notifier.NOTIFICATIONS: + if n['event_type'].startswith('router.interface.'): + payload = n['payload']['router.interface'] + self.assertIn('id', payload) + self.assertEquals(payload['id'], r['router']['id']) + self.assertIn('tenant_id', payload) + stid = s['subnet']['tenant_id'] + # tolerate subnet tenant deliberately to '' in the + # nicira metadata access case + self.assertTrue(payload['tenant_id'] == stid or + payload['tenant_id'] == '') + def test_router_add_interface_subnet_with_bad_tenant_returns_404(self): with mock.patch('quantum.context.Context.to_dict') as tdict: tenant_id = _uuid()