Merge "Register an extend_dict function for ext_gw_mode extension"

This commit is contained in:
Jenkins 2013-09-11 07:16:50 +00:00 committed by Gerrit Code Review
commit f5108594c2

View File

@ -19,6 +19,7 @@
import sqlalchemy as sa import sqlalchemy as sa
from neutron.db import db_base_plugin_v2
from neutron.db import l3_db from neutron.db import l3_db
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.openstack.common import log as logging 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): class L3_NAT_db_mixin(l3_db.L3_NAT_db_mixin):
"""Mixin class to add configurable gateway modes.""" """Mixin class to add configurable gateway modes."""
def _make_router_dict(self, router, fields=None, process_extensions=True): # Register dict extend functions for ports and networks
res = super(L3_NAT_db_mixin, self)._make_router_dict( db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(
router, process_extensions=process_extensions) l3.ROUTERS, ['_extend_router_dict_gw_mode'])
if router['gw_port_id']:
nw_id = router.gw_port['network_id'] def _extend_router_dict_gw_mode(seld, router_res, router_db):
res[EXTERNAL_GW_INFO] = {'network_id': nw_id, if router_db.gw_port_id:
'enable_snat': router.enable_snat} nw_id = router_db.gw_port['network_id']
return self._fields(res, fields) 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): def _update_router_gw_info(self, context, router_id, info, router=None):
# Load the router only if necessary # Load the router only if necessary