Merge "BSN: Add network to ext_gw_info sent to backend"

This commit is contained in:
Jenkins 2014-12-03 16:00:53 +00:00 committed by Gerrit Code Review
commit 06e131a23f
2 changed files with 23 additions and 1 deletions

View File

@ -96,7 +96,12 @@ class L3RestProxy(cplugin.NeutronRestProxyV2Base,
new_router = super(L3RestProxy,
self).update_router(context, router_id, router)
router = self._map_state_and_status(new_router)
# look up the network on this side to save an expensive query on
# the backend controller.
if router and router.get('external_gateway_info'):
router['external_gateway_info']['network'] = self.get_network(
context.elevated(),
router['external_gateway_info']['network_id'])
# update router on network controller
self.servers.rest_update_router(tenant_id, router, router_id)

View File

@ -137,6 +137,23 @@ class RouterDBTestCase(RouterDBTestBase,
# remove extra port created
self._delete('ports', p2['port']['id'])
def test_add_network_to_ext_gw_backend_body(self):
plugin_obj = manager.NeutronManager.get_plugin()
with contextlib.nested(
self.network(), self.router()
) as (n1, r1):
with self.subnet(network=n1, cidr='10.10.10.10/24') as s1:
self._set_net_external(s1['subnet']['network_id'])
with mock.patch.object(plugin_obj.servers,
'rest_update_router') as upmock:
self._add_external_gateway_to_router(r1['router']['id'],
n1['network']['id'])
router_body = upmock.mock_calls[0][1][1]
self.assertEqual(
plugin_obj.get_network(context.get_admin_context(),
n1['network']['id']),
router_body['external_gateway_info']['network'])
def test_multi_tenant_flip_alllocation(self):
tenant1_id = _uuid()
tenant2_id = _uuid()