Exit if DHCP agent interface_driver is not defined
Fixes bug 1130052
In addition to this:
Uses "raise SystemExit()" instaed of the exit for the L3
agent.
Change-Id: I8130745c9de62619189e158944fa9e4ed25be774
This commit is contained in:
parent
e49728fadf
commit
0fc5e29c78
@ -481,8 +481,14 @@ class DeviceManager(object):
|
||||
self.root_helper = config.get_root_helper(conf)
|
||||
self.plugin = plugin
|
||||
if not conf.interface_driver:
|
||||
LOG.error(_('You must specify an interface driver'))
|
||||
self.driver = importutils.import_object(conf.interface_driver, conf)
|
||||
raise SystemExit(_('You must specify an interface driver'))
|
||||
try:
|
||||
self.driver = importutils.import_object(conf.interface_driver,
|
||||
conf)
|
||||
except:
|
||||
msg = _("Error importing interface driver "
|
||||
"'%s'") % conf.interface_driver
|
||||
raise SystemExit(msg)
|
||||
|
||||
def get_interface_name(self, network, port=None):
|
||||
"""Return interface(device) name for use by the DHCP process."""
|
||||
|
@ -154,15 +154,15 @@ class L3NATAgent(manager.Manager):
|
||||
self.router_info = {}
|
||||
|
||||
if not self.conf.interface_driver:
|
||||
LOG.error(_('An interface driver must be specified'))
|
||||
sys.exit(1)
|
||||
raise SystemExit(_('An interface driver must be specified'))
|
||||
try:
|
||||
self.driver = importutils.import_object(self.conf.interface_driver,
|
||||
self.conf)
|
||||
except:
|
||||
LOG.exception(_("Error importing interface driver '%s'"),
|
||||
self.conf.interface_driver)
|
||||
sys.exit(1)
|
||||
msg = _("Error importing interface driver "
|
||||
"'%s'") % self.conf.interface_driver
|
||||
raise SystemExit(msg)
|
||||
|
||||
self.context = context.get_admin_context_without_session()
|
||||
self.plugin_rpc = L3PluginApi(topics.PLUGIN, host)
|
||||
self.fullsync = True
|
||||
|
@ -113,6 +113,8 @@ class TestDhcpAgent(unittest.TestCase):
|
||||
cfg.CONF.register_opts(dhcp_agent.DeviceManager.OPTS)
|
||||
cfg.CONF.register_opts(dhcp_agent.DhcpAgent.OPTS)
|
||||
cfg.CONF.register_opts(dhcp_agent.DhcpLeaseRelay.OPTS)
|
||||
cfg.CONF.set_override('interface_driver',
|
||||
'quantum.agent.linux.interface.NullDriver')
|
||||
self.driver_cls_p = mock.patch(
|
||||
'quantum.agent.dhcp_agent.importutils.import_class')
|
||||
self.driver = mock.Mock(name='driver')
|
||||
|
Loading…
Reference in New Issue
Block a user