Check for _interfaces in updated_router

I am getting a stack trace when running tempest tests against FWaaS v2.
The stack trace comes from referencing updated_router['_interfaces']
when '_interfaces' is not a member of the updated_router dict.  So I add
a check for that, since the updated_router dict contents definitely did
not have anything that looked like a list of interfaces.

Needed-By: If35ca26028ddedcf1bc22dd8749cb11c69a1ccbb
Change-Id: I88be1670a42fcca4aba3b643a1c5a072ce0d1035
(cherry picked from commit 7978a95699)
This commit is contained in:
Nate Johnston 2016-09-16 15:10:08 +00:00 committed by Armando Migliaccio
parent fcb9389ae5
commit 9b86e3590f
1 changed files with 11 additions and 9 deletions

View File

@ -19,6 +19,7 @@ from neutron.common import rpc as n_rpc
from neutron import context
from neutron.plugins.common import constants as n_const
from neutron_fwaas.common import fwaas_constants as f_const
from neutron_lib import constants as lib_constants
from oslo_config import cfg
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
@ -244,15 +245,16 @@ class FWaaSL3AgentExtension(l3_agent_extension.L3AgentCoreResourceExtension):
fwg_list = self.fwplugin_rpc.get_firewall_groups_for_project(ctx)
# Apply a firewall group, as requested, to ports on the new router.
for port in updated_router['_interfaces']:
for firewall_group in fwg_list:
if (self._has_port_insertion_fields(firewall_group) and
(port['id'] in firewall_group['add-port-ids'] or
port['id'] in firewall_group['del-port-ids'])):
self._invoke_driver_for_sync_from_plugin(ctx, port,
firewall_group)
# A port can have at most one firewall group.
break
if lib_constants.INTERFACE_KEY in updated_router:
for port in updated_router[lib_constants.INTERFACE_KEY]:
for firewall_group in fwg_list:
if (self._has_port_insertion_fields(firewall_group) and
(port['id'] in firewall_group['add-port-ids'] or
port['id'] in firewall_group['del-port-ids'])):
self._invoke_driver_for_sync_from_plugin(ctx, port,
firewall_group)
# A port can have at most one firewall group.
break
def add_router(self, context, new_router):
"""Handles agent restart and router add. Fetches firewall groups from