Skip to content

Commit

Permalink
use object directly instead of the foreigh key to update master db ob…
Browse files Browse the repository at this point in the history
…ject.

Bug #1064235

Change-Id: I74fe3e758681c40590de87c82fd093224d329f51
  • Loading branch information
gongysh committed Oct 23, 2012
1 parent 12aa05c commit 66e99de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion quantum/db/l3_db.py
Expand Up @@ -213,7 +213,8 @@ def _update_router_gw_info(self, context, router_id, info):
raise q_exc.BadRequest(resource='router', msg=msg)

with context.session.begin(subtransactions=True):
router.update({'gw_port_id': gw_port['id']})
router.gw_port = self._get_port(context.elevated(),
gw_port['id'])
context.session.add(router)

def delete_router(self, context, id):
Expand Down
15 changes: 15 additions & 0 deletions quantum/tests/unit/test_l3_plugin.py
Expand Up @@ -557,6 +557,21 @@ def test_router_add_interface_no_data(self):
expected_code=exc.
HTTPBadRequest.code)

def test_create_router_with_gwinfo(self):
with self.subnet() as s:
self._set_net_external(s['subnet']['network_id'])
data = {'router': {'tenant_id': _uuid()}}
data['router']['name'] = 'router1'
data['router']['external_gateway_info'] = {
'network_id': s['subnet']['network_id']}
router_req = self.new_create_request('routers', data, 'json')
res = router_req.get_response(self.ext_api)
router = self.deserialize('json', res)
self.assertEquals(
s['subnet']['network_id'],
router['router']['external_gateway_info']['network_id'])
self._delete('routers', router['router']['id'])

def test_router_add_gateway(self):
with self.router() as r:
with self.subnet() as s:
Expand Down

0 comments on commit 66e99de

Please sign in to comment.