]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Register RA and PD config options in l3-agent
authorBrian Haley <brian.haley@hpe.com>
Tue, 12 Jan 2016 23:53:42 +0000 (18:53 -0500)
committerBrian Haley <brian.haley@hpe.com>
Wed, 13 Jan 2016 02:03:54 +0000 (21:03 -0500)
In order for the l3-agent to see the RA and PD config options,
it needs to register them when it starts.  Noticed this when I
went to override something for a test and it wouldn't work.
It now passes the config down to radvd on start so the correct
values are picked-up.

Change-Id: Iec0e0d16eed4f12af77fcd4f0b93b641b1146293
Related-Bug: #1532338

neutron/agent/l3/router_info.py
neutron/agent/l3_agent.py
neutron/agent/linux/pd.py
neutron/agent/linux/ra.py
neutron/opts.py
neutron/tests/unit/agent/l3/test_agent.py

index b990ba38cacd2db3f17d41efc0c42253a319bfbb..877a22fc6b686ace694cef2dfceb8ef2b6359ea7 100644 (file)
@@ -76,7 +76,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)
 
         self.router_namespace.create()
 
index 691b1ec6d8955db465fe01027487c2e5d24db28a..dbfbb65b78b9670ab3dbdd060e539ce62ed2609b 100644 (file)
@@ -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
@@ -39,6 +41,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)
     config.register_availability_zone_opts_helper(conf)
 
 
index b649076d2a7ad8c2afde7d3dba5a1f86efdf20b4..350b530902b4c9110bc2766f398019c595185851 100644 (file)
@@ -40,8 +40,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,
index 8896e8d26c44d99730a5edbf3646d2541f9040df..9cc0a252806fd132f4b25764251daaa69ecd0322 100644 (file)
@@ -40,8 +40,6 @@ OPTS = [
                help=_('Location to store IPv6 RA config files')),
 ]
 
-cfg.CONF.register_opts(OPTS)
-
 CONFIG_TEMPLATE = jinja2.Template("""interface {{ interface_name }}
 {
    AdvSendAdvert on;
@@ -74,14 +72,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)
@@ -117,7 +117,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):
@@ -157,7 +157,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
index 200839369bc5b43ff27327a0421f186a30479221..4e08604682a7d465d93979255029f6304176f90a 100644 (file)
@@ -24,6 +24,8 @@ import neutron.agent.l2.extensions.manager
 import neutron.agent.l3.config
 import neutron.agent.l3.ha
 import neutron.agent.linux.interface
+import neutron.agent.linux.pd
+import neutron.agent.linux.ra
 import neutron.agent.metadata.config
 import neutron.agent.ovsdb.api
 import neutron.agent.securitygroups_rpc
@@ -190,7 +192,9 @@ def list_l3_agent_opts():
          itertools.chain(
              neutron.agent.l3.config.OPTS,
              neutron.service.service_opts,
-             neutron.agent.l3.ha.OPTS)
+             neutron.agent.l3.ha.OPTS,
+             neutron.agent.linux.pd.OPTS,
+             neutron.agent.linux.ra.OPTS)
          )
     ]
 
index 7c42059c9c48e8a4abfbb2443c43fafb6461d155..17051b8aa963a4785bdb5a0614402ec19a42af5c 100644 (file)
@@ -75,10 +75,14 @@ class BasicRouterOperationsFramework(base.BaseTestCase):
         agent_config.register_availability_zone_opts_helper(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('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')
@@ -171,7 +175,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)
 
 
@@ -2182,7 +2187,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]
@@ -2275,7 +2281,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):