Use super to make _build_routers_list safer
This switches _build_routers_list to call 'super' in both of the override cases so we aren't sensitive to class ordering. Change-Id: I2f8b54826918280cf63d69a6d34bfc4b358b3b6a Related-Bug: #1695101
This commit is contained in:
parent
803f7b8544
commit
73776facdc
|
@ -591,22 +591,18 @@ class _DVRAgentInterfaceMixin(object):
|
|||
|
||||
def _build_routers_list(self, context, routers, gw_ports):
|
||||
# Perform a single query up front for all routers
|
||||
routers = super(_DVRAgentInterfaceMixin, self)._build_routers_list(
|
||||
context, routers, gw_ports)
|
||||
if not routers:
|
||||
return []
|
||||
router_ids = [r['id'] for r in routers]
|
||||
binding_objs = rb_obj.RouterL3AgentBinding.get_objects(
|
||||
context, router_id=router_ids)
|
||||
bindings = dict((b.router_id, b) for b in binding_objs)
|
||||
|
||||
for rtr in routers:
|
||||
gw_port_id = rtr['gw_port_id']
|
||||
# Collect gw ports only if available
|
||||
if gw_port_id and gw_ports.get(gw_port_id):
|
||||
rtr['gw_port'] = gw_ports[gw_port_id]
|
||||
if 'enable_snat' in rtr[l3.EXTERNAL_GW_INFO]:
|
||||
rtr['enable_snat'] = (
|
||||
rtr[l3.EXTERNAL_GW_INFO]['enable_snat'])
|
||||
|
||||
binding = bindings.get(rtr['id'])
|
||||
if not binding:
|
||||
rtr['gw_port_host'] = None
|
||||
|
@ -963,10 +959,6 @@ class _DVRAgentInterfaceMixin(object):
|
|||
return update_port
|
||||
|
||||
|
||||
# NOTE: The order in which the parent classes are inherited sometimes
|
||||
# determines the functions defined in those classes to be executed.
|
||||
# So any new classes that overrides a function in the parent class should
|
||||
# be added before the parent class.
|
||||
class L3_NAT_with_dvr_db_mixin(_DVRAgentInterfaceMixin,
|
||||
DVRResourceOperationHandler,
|
||||
l3_attrs_db.ExtraAttributesMixin,
|
||||
|
|
|
@ -79,6 +79,8 @@ class L3_NAT_dbonly_mixin(l3_db.L3_NAT_dbonly_mixin):
|
|||
return cfg.CONF.enable_snat_by_default
|
||||
|
||||
def _build_routers_list(self, context, routers, gw_ports):
|
||||
routers = super(L3_NAT_dbonly_mixin, self)._build_routers_list(
|
||||
context, routers, gw_ports)
|
||||
for rtr in routers:
|
||||
gw_port_id = rtr['gw_port_id']
|
||||
# Collect gw ports only if available
|
||||
|
|
Loading…
Reference in New Issue