diff --git a/quantum/agent/dhcp_agent.py b/quantum/agent/dhcp_agent.py index 333fa86c34..fda604cd86 100644 --- a/quantum/agent/dhcp_agent.py +++ b/quantum/agent/dhcp_agent.py @@ -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.""" diff --git a/quantum/agent/l3_agent.py b/quantum/agent/l3_agent.py index d8f3eaf2f4..9e45f2cad4 100644 --- a/quantum/agent/l3_agent.py +++ b/quantum/agent/l3_agent.py @@ -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 diff --git a/quantum/tests/unit/test_dhcp_agent.py b/quantum/tests/unit/test_dhcp_agent.py index b109f12e66..fbc6f03fcf 100644 --- a/quantum/tests/unit/test_dhcp_agent.py +++ b/quantum/tests/unit/test_dhcp_agent.py @@ -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')