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
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