Merge "Raise an exception if no router_id provided"
This commit is contained in:
commit
86feb8e4a8
@ -195,8 +195,8 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
|
|||||||
self.root_helper = config.get_root_helper(self.conf)
|
self.root_helper = config.get_root_helper(self.conf)
|
||||||
self.router_info = {}
|
self.router_info = {}
|
||||||
|
|
||||||
if not self.conf.interface_driver:
|
self._check_config_params()
|
||||||
raise SystemExit(_('An interface driver must be specified'))
|
|
||||||
try:
|
try:
|
||||||
self.driver = importutils.import_object(
|
self.driver = importutils.import_object(
|
||||||
self.conf.interface_driver,
|
self.conf.interface_driver,
|
||||||
@ -221,6 +221,20 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
|
|||||||
self.rpc_loop.start(interval=RPC_LOOP_INTERVAL)
|
self.rpc_loop.start(interval=RPC_LOOP_INTERVAL)
|
||||||
super(L3NATAgent, self).__init__(conf=self.conf)
|
super(L3NATAgent, self).__init__(conf=self.conf)
|
||||||
|
|
||||||
|
def _check_config_params(self):
|
||||||
|
"""Check items in configuration files.
|
||||||
|
|
||||||
|
Check for required and invalid configuration items.
|
||||||
|
The actual values are not verified for correctness.
|
||||||
|
"""
|
||||||
|
if not self.conf.interface_driver:
|
||||||
|
raise SystemExit(_('An interface driver must be specified'))
|
||||||
|
|
||||||
|
if not self.conf.use_namespaces and not self.conf.router_id:
|
||||||
|
msg = _('Router id is required if not using namespaces.')
|
||||||
|
LOG.error(msg)
|
||||||
|
raise SystemExit(msg)
|
||||||
|
|
||||||
def _destroy_router_namespaces(self, only_router_id=None):
|
def _destroy_router_namespaces(self, only_router_id=None):
|
||||||
"""Destroy router namespaces on the host to eliminate all stale
|
"""Destroy router namespaces on the host to eliminate all stale
|
||||||
linux devices, iptables rules, and namespaces.
|
linux devices, iptables rules, and namespaces.
|
||||||
|
@ -43,6 +43,7 @@ class TestBasicRouterOperations(base.BaseTestCase):
|
|||||||
self.conf.register_opts(l3_agent.L3NATAgent.OPTS)
|
self.conf.register_opts(l3_agent.L3NATAgent.OPTS)
|
||||||
agent_config.register_root_helper(self.conf)
|
agent_config.register_root_helper(self.conf)
|
||||||
self.conf.register_opts(interface.OPTS)
|
self.conf.register_opts(interface.OPTS)
|
||||||
|
self.conf.set_override('router_id', 'fake_id')
|
||||||
self.conf.set_override('interface_driver',
|
self.conf.set_override('interface_driver',
|
||||||
'neutron.agent.linux.interface.NullDriver')
|
'neutron.agent.linux.interface.NullDriver')
|
||||||
self.conf.root_helper = 'sudo'
|
self.conf.root_helper = 'sudo'
|
||||||
@ -646,6 +647,16 @@ class TestBasicRouterOperations(base.BaseTestCase):
|
|||||||
'-p tcp -m tcp --dport 80 -j REDIRECT --to-port 8775')
|
'-p tcp -m tcp --dport 80 -j REDIRECT --to-port 8775')
|
||||||
self.assertEqual([rules], agent.metadata_nat_rules())
|
self.assertEqual([rules], agent.metadata_nat_rules())
|
||||||
|
|
||||||
|
def test_router_id_specified_in_conf(self):
|
||||||
|
self.conf.set_override('use_namespaces', False)
|
||||||
|
self.conf.set_override('router_id', '')
|
||||||
|
self.assertRaises(SystemExit, l3_agent.L3NATAgent,
|
||||||
|
HOSTNAME, self.conf)
|
||||||
|
|
||||||
|
self.conf.set_override('router_id', '1234')
|
||||||
|
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||||
|
self.assertEqual(['1234'], agent._router_ids())
|
||||||
|
|
||||||
|
|
||||||
class TestL3AgentEventHandler(base.BaseTestCase):
|
class TestL3AgentEventHandler(base.BaseTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user