From 1dabc0629e642aab6076fc0ca4e7f9698341a797 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Tue, 10 Sep 2013 15:38:16 -0700 Subject: [PATCH] Register an extend_dict function for ext_gw_mode extension Bug 1223585wq Use dict extension methods instead of overriding make_router_dict in order to make this extension consistent with all the others. Change-Id: I94fa7e70e5a869963ec4dfa9de85c8d922976843 --- neutron/db/l3_gwmode_db.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/neutron/db/l3_gwmode_db.py b/neutron/db/l3_gwmode_db.py index a9866992a9b..91489274a4f 100644 --- a/neutron/db/l3_gwmode_db.py +++ b/neutron/db/l3_gwmode_db.py @@ -19,6 +19,7 @@ import sqlalchemy as sa +from neutron.db import db_base_plugin_v2 from neutron.db import l3_db from neutron.extensions import l3 from neutron.openstack.common import log as logging @@ -35,14 +36,16 @@ setattr(l3_db.Router, 'enable_snat', class L3_NAT_db_mixin(l3_db.L3_NAT_db_mixin): """Mixin class to add configurable gateway modes.""" - def _make_router_dict(self, router, fields=None, process_extensions=True): - res = super(L3_NAT_db_mixin, self)._make_router_dict( - router, process_extensions=process_extensions) - if router['gw_port_id']: - nw_id = router.gw_port['network_id'] - res[EXTERNAL_GW_INFO] = {'network_id': nw_id, - 'enable_snat': router.enable_snat} - return self._fields(res, fields) + # Register dict extend functions for ports and networks + db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs( + l3.ROUTERS, ['_extend_router_dict_gw_mode']) + + def _extend_router_dict_gw_mode(seld, router_res, router_db): + if router_db.gw_port_id: + nw_id = router_db.gw_port['network_id'] + router_res[EXTERNAL_GW_INFO] = { + 'network_id': nw_id, + 'enable_snat': router_db.enable_snat} def _update_router_gw_info(self, context, router_id, info, router=None): # Load the router only if necessary