Merge "Support multiple external networks in L3 agent"

This commit is contained in:
Zuul 2019-05-28 23:00:36 +00:00 committed by Gerrit Code Review
commit e7629fc1c5
2 changed files with 8 additions and 26 deletions

View File

@ -36,7 +36,6 @@ from oslo_utils import excutils
from oslo_utils import timeutils
from osprofiler import profiler
from neutron._i18n import _
from neutron.agent.common import resource_processing_queue as queue
from neutron.agent.common import utils as common_utils
from neutron.agent.l3 import dvr
@ -418,12 +417,10 @@ class L3NATAgent(ha.AgentMixin,
except oslo_messaging.RemoteError as e:
with excutils.save_and_reraise_exception() as ctx:
if e.exc_type == 'TooManyExternalNetworks':
# At this point we know gateway_external_network_id is not
# defined. Since there are more than one external network,
# we will handle all of them
ctx.reraise = False
msg = _(
"The 'gateway_external_network_id' option must be "
"configured for this agent as Neutron has more than "
"one external network.")
raise Exception(msg)
def _create_router(self, router_id, router):
kwargs = {

View File

@ -24,7 +24,6 @@ import netaddr
from neutron_lib.agent import constants as agent_consts
from neutron_lib.api.definitions import portbindings
from neutron_lib import constants as lib_constants
from neutron_lib import exceptions as exc
from neutron_lib.exceptions import l3 as l3_exc
from oslo_config import cfg
from oslo_log import log
@ -2955,12 +2954,11 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
'external_gateway_info': {'network_id': 'aaa'}}
agent.router_info = {}
self.plugin_api.get_external_network_id.side_effect = (
exc.TooManyExternalNetworks())
self.assertRaises(exc.TooManyExternalNetworks,
agent._process_router_if_compatible,
router)
self.assertNotIn(router['id'], agent.router_info)
e = oslo_messaging.RemoteError()
e.exc_type = 'TooManyExternalNetworks'
agent.plugin_rpc.get_external_network_id.side_effect = e
agent._process_router_if_compatible(router)
self.assertIn(router['id'], agent.router_info)
def test_process_router_if_compatible_with_ext_net_in_conf(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
@ -2978,19 +2976,6 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
router)
self.assertNotIn(router['id'], agent.router_info)
def test_process_router_if_compatible_with_no_bridge_no_ext_net(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
self.plugin_api.get_external_network_id.return_value = 'aaa'
router = {'id': _uuid(),
'routes': [],
'admin_state_up': True,
'external_gateway_info': {'network_id': 'aaa'}}
agent.router_info = {}
agent._process_router_if_compatible(router)
self.assertIn(router['id'], agent.router_info)
def test_nonexistent_interface_driver(self):
self.conf.set_override('interface_driver', None)
self.assertRaises(SystemExit, l3_agent.L3NATAgent,