diff --git a/etc/l3_agent.ini b/etc/l3_agent.ini index 15941638d30..3d379f7e242 100644 --- a/etc/l3_agent.ini +++ b/etc/l3_agent.ini @@ -58,6 +58,12 @@ # setup.cfg for entry points included with the neutron source. # prefix_delegation_driver = dibbler +# Service to handle DHCPv6 Prefix delegation. +# pd_dhcp_driver = dibbler + +# Location to store IPv6 RA config files +# ra_confs = $state_path/ra + # Indicates that this L3 agent should also handle routers that do not have # an external network gateway configured. This option should be True only # for a single agent in a Neutron deployment, and may be False for all agents diff --git a/neutron/agent/l3/router_info.py b/neutron/agent/l3/router_info.py index 073c90ded13..b42936730dc 100644 --- a/neutron/agent/l3/router_info.py +++ b/neutron/agent/l3/router_info.py @@ -80,7 +80,8 @@ class RouterInfo(object): self.radvd = ra.DaemonMonitor(self.router_id, self.ns_name, process_monitor, - self.get_internal_device_name) + self.get_internal_device_name, + self.agent_conf) if self.router_namespace: self.router_namespace.create() diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index bee060181c9..3e739ff9958 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -24,6 +24,8 @@ from neutron.agent.l3 import config as l3_config from neutron.agent.l3 import ha from neutron.agent.linux import external_process from neutron.agent.linux import interface +from neutron.agent.linux import pd +from neutron.agent.linux import ra from neutron.agent.metadata import config as metadata_config from neutron.common import config as common_config from neutron.common import topics @@ -40,6 +42,8 @@ def register_opts(conf): config.register_agent_state_opts_helper(conf) conf.register_opts(interface.OPTS) conf.register_opts(external_process.OPTS) + conf.register_opts(pd.OPTS) + conf.register_opts(ra.OPTS) def main(manager='neutron.agent.l3.agent.L3NATAgentWithStateReport'): diff --git a/neutron/agent/linux/pd.py b/neutron/agent/linux/pd.py index cfed4936f1b..7c79a984022 100644 --- a/neutron/agent/linux/pd.py +++ b/neutron/agent/linux/pd.py @@ -39,8 +39,6 @@ OPTS = [ help=_('Service to handle DHCPv6 Prefix delegation.')), ] -cfg.CONF.register_opts(OPTS) - class PrefixDelegation(object): def __init__(self, context, pmon, intf_driver, notifier, pd_update_cb, diff --git a/neutron/agent/linux/ra.py b/neutron/agent/linux/ra.py index afd7ce8b453..a5337dcfd5d 100644 --- a/neutron/agent/linux/ra.py +++ b/neutron/agent/linux/ra.py @@ -35,8 +35,6 @@ OPTS = [ help=_('Location to store IPv6 RA config files')), ] -cfg.CONF.register_opts(OPTS) - CONFIG_TEMPLATE = jinja2.Template("""interface {{ interface_name }} { AdvSendAdvert on; @@ -73,14 +71,16 @@ CONFIG_TEMPLATE = jinja2.Template("""interface {{ interface_name }} class DaemonMonitor(object): """Manage the data and state of an radvd process.""" - def __init__(self, router_id, router_ns, process_monitor, dev_name_helper): + def __init__(self, router_id, router_ns, process_monitor, dev_name_helper, + agent_conf): self._router_id = router_id self._router_ns = router_ns self._process_monitor = process_monitor self._dev_name_helper = dev_name_helper + self._agent_conf = agent_conf def _generate_radvd_conf(self, router_ports): - radvd_conf = utils.get_conf_file_name(cfg.CONF.ra_confs, + radvd_conf = utils.get_conf_file_name(self._agent_conf.ra_confs, self._router_id, 'radvd.conf', True) @@ -114,7 +114,7 @@ class DaemonMonitor(object): default_cmd_callback=callback, namespace=self._router_ns, service=RADVD_SERVICE_NAME, - conf=cfg.CONF, + conf=self._agent_conf, run_as_root=True) def _spawn_radvd(self, radvd_conf): @@ -154,7 +154,7 @@ class DaemonMonitor(object): service_name=RADVD_SERVICE_NAME) pm = self._get_radvd_process_manager() pm.disable() - utils.remove_conf_files(cfg.CONF.ra_confs, self._router_id) + utils.remove_conf_files(self._agent_conf.ra_confs, self._router_id) LOG.debug("radvd disabled for router %s", self._router_id) @property diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index 6ce8dff789c..544ce1ad8da 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -74,11 +74,15 @@ class BasicRouterOperationsFramework(base.BaseTestCase): agent_config.register_process_monitor_opts(self.conf) self.conf.register_opts(interface.OPTS) self.conf.register_opts(external_process.OPTS) + self.conf.register_opts(pd.OPTS) + self.conf.register_opts(ra.OPTS) self.conf.set_override('router_id', 'fake_id') self.conf.set_override('interface_driver', 'neutron.agent.linux.interface.NullDriver') self.conf.set_override('send_arp_for_ha', 1) self.conf.set_override('state_path', '') + self.conf.set_override('ra_confs', '/tmp') + self.conf.set_override('pd_dhcp_driver', '') self.device_exists_p = mock.patch( 'neutron.agent.linux.ip_lib.device_exists') @@ -169,7 +173,8 @@ class BasicRouterOperationsFramework(base.BaseTestCase): ri.radvd = ra.DaemonMonitor(router['id'], ri.ns_name, agent.process_monitor, - ri.get_internal_device_name) + ri.get_internal_device_name, + self.conf) ri.process(agent) @@ -2224,7 +2229,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): router['id'], namespaces.RouterNamespace._get_ns_name(router['id']), agent.process_monitor, - l3_test_common.FakeDev) + l3_test_common.FakeDev, + self.conf) radvd.enable(router['_interfaces']) cmd = execute.call_args[0][0] @@ -2302,7 +2308,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): ri.radvd = ra.DaemonMonitor(router['id'], ri.ns_name, agent.process_monitor, - ri.get_internal_device_name) + ri.get_internal_device_name, + self.conf) return agent, router, ri def _pd_remove_gw_interface(self, intfs, agent, router, ri):