]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
options: consolidate options definitions
authorIsaku Yamahata <isaku.yamahata@intel.com>
Thu, 13 Feb 2014 11:19:25 +0000 (20:19 +0900)
committerThomas Goirand <thomas@goirand.fr>
Thu, 13 Mar 2014 07:20:30 +0000 (15:20 +0800)
Some config options(interface_driver, use_namespaces) are defined
multiple times in ad-hoc way.  It causes DuplicateOptError exception
when using those module at the same time.  Right now the exception is
avoided in ad-hoc way by each executable.  Those duplicated
definitions should be consolidated and treated in uniformed way.

This is the blocker for blueprint: l3-agent-consolidation

neutron.services.loadbalancer.drivers.haproxy.agent periodic_interval
conflicts with neutron.service one. Since there is no way to fix it
without changing existing behavior/default value, it is untouched for now.

Closes-bug: #1279769
Change-Id: Ifed79b7ee0033644854499416f8a2b22a20416fe

22 files changed:
neutron/agent/common/config.py
neutron/agent/dhcp_agent.py
neutron/agent/l3_agent.py
neutron/agent/linux/dhcp.py
neutron/agent/netns_cleanup_util.py
neutron/agent/ovs_cleanup_util.py
neutron/debug/debug_agent.py
neutron/debug/shell.py
neutron/services/firewall/agents/varmour/varmour_router.py
neutron/services/loadbalancer/agent/agent.py
neutron/services/loadbalancer/agent/agent_manager.py
neutron/services/metering/drivers/iptables/iptables_driver.py
neutron/tests/unit/midonet/test_midonet_driver.py
neutron/tests/unit/services/firewall/agents/l3reference/test_firewall_l3_agent.py
neutron/tests/unit/services/firewall/agents/varmour/test_varmour_router.py
neutron/tests/unit/services/firewall/drivers/varmour/test_varmour_fwaas.py
neutron/tests/unit/services/vpn/test_vpn_agent.py
neutron/tests/unit/test_debug_commands.py
neutron/tests/unit/test_dhcp_agent.py
neutron/tests/unit/test_l3_agent.py
neutron/tests/unit/test_linux_dhcp.py
neutron/tests/unit/test_linux_interface.py

index 4bf3710eeb6f5ea63e0f06cab05a6cfd92b19c61..33e23945bf29a5b84a62bf43e978d26b04dba065 100644 (file)
@@ -38,6 +38,16 @@ AGENT_STATE_OPTS = [
                         'is half or less than agent_down_time.')),
 ]
 
+INTERFACE_DRIVER_OPTS = [
+    cfg.StrOpt('interface_driver',
+               help=_("The driver used to manage the virtual interface.")),
+]
+
+USE_NAMESPACES_OPTS = [
+    cfg.BoolOpt('use_namespaces', default=True,
+                help=_("Allow overlapping IP.")),
+]
+
 
 def get_log_args(conf, log_file_name):
     cmd_args = []
@@ -76,6 +86,14 @@ def register_agent_state_opts_helper(conf):
     conf.register_opts(AGENT_STATE_OPTS, 'AGENT')
 
 
+def register_interface_driver_opts_helper(conf):
+    conf.register_opts(INTERFACE_DRIVER_OPTS)
+
+
+def register_use_namespaces_opts_helper(conf):
+    conf.register_opts(USE_NAMESPACES_OPTS)
+
+
 def get_root_helper(conf):
     root_helper = conf.AGENT.root_helper
     if root_helper != 'sudo':
index 5cdacab57756340c3359bf7175871fd0e749bd60..ae597cd427396f0db12c14d09ef64618e08c49fe 100644 (file)
@@ -52,8 +52,6 @@ class DhcpAgent(manager.Manager):
         cfg.StrOpt('dhcp_driver',
                    default='neutron.agent.linux.dhcp.Dnsmasq',
                    help=_("The driver used to manage the DHCP server.")),
-        cfg.BoolOpt('use_namespaces', default=True,
-                    help=_("Allow overlapping IP.")),
         cfg.BoolOpt('enable_isolated_metadata', default=False,
                     help=_("Support Metadata requests on isolated networks.")),
         cfg.BoolOpt('enable_metadata_network', default=False,
@@ -589,6 +587,8 @@ class DhcpAgentWithStateReport(DhcpAgent):
 
 def register_options():
     cfg.CONF.register_opts(DhcpAgent.OPTS)
+    config.register_interface_driver_opts_helper(cfg.CONF)
+    config.register_use_namespaces_opts_helper(cfg.CONF)
     config.register_agent_state_opts_helper(cfg.CONF)
     config.register_root_helper(cfg.CONF)
     cfg.CONF.register_opts(dhcp.OPTS)
index c9a01c2f4eff79a53c8fb945d4b097e5d05969f8..21d0957730b8e0e64bb591f6b72549139e35652f 100644 (file)
@@ -157,9 +157,6 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
         cfg.StrOpt('external_network_bridge', default='br-ex',
                    help=_("Name of bridge used for external network "
                           "traffic.")),
-        cfg.StrOpt('interface_driver',
-                   help=_("The driver used to manage the virtual "
-                          "interface.")),
         cfg.IntOpt('metadata_port',
                    default=9697,
                    help=_("TCP Port used by Neutron metadata namespace "
@@ -168,8 +165,6 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
                    default=0,
                    help=_("Send this many gratuitous ARPs for HA setup, if "
                           "less than or equal to 0, the feature is disabled")),
-        cfg.BoolOpt('use_namespaces', default=True,
-                    help=_("Allow overlapping IP.")),
         cfg.StrOpt('router_id', default='',
                    help=_("If namespaces is disabled, the l3 agent can only"
                           " configure a router that has the matching router "
@@ -916,6 +911,8 @@ def main(manager='neutron.agent.l3_agent.L3NATAgentWithStateReport'):
     eventlet.monkey_patch()
     conf = cfg.CONF
     conf.register_opts(L3NATAgent.OPTS)
+    config.register_interface_driver_opts_helper(conf)
+    config.register_use_namespaces_opts_helper(conf)
     config.register_agent_state_opts_helper(conf)
     config.register_root_helper(conf)
     conf.register_opts(interface.OPTS)
index e1682d8aca2a6b935e24205f72bcbf6b2a4e0d3e..08cedfdcf3c99cbf6fa380834c15451dd894e621 100644 (file)
@@ -59,8 +59,6 @@ OPTS = [
         'dnsmasq_lease_max',
         default=(2 ** 24),
         help=_('Limit number of leases to prevent a denial-of-service.')),
-    cfg.StrOpt('interface_driver',
-               help=_("The driver used to manage the virtual interface.")),
 ]
 
 IPV4 = 4
index 9c17f715f7a5594e014c7e3563fd43a7a694dbb6..2551299cda8a4aff7e499b1d8e64a10c5206e9eb 100644 (file)
@@ -63,6 +63,7 @@ def setup_conf():
     conf = cfg.CONF
     conf.register_cli_opts(cli_opts)
     conf.register_opts(opts)
+    agent_config.register_interface_driver_opts_helper(conf)
     agent_config.register_root_helper(conf)
     conf.register_opts(dhcp.OPTS)
     return conf
index 51bf1d459965791fd01bbb5f930bb3386c49fb62..f7a388b3d220f41a388c43c29f12347f9f4b17c5 100644 (file)
@@ -48,6 +48,8 @@ def setup_conf():
     conf.register_cli_opts(opts)
     conf.register_opts(l3_agent.L3NATAgent.OPTS)
     conf.register_opts(interface.OPTS)
+    agent_config.register_interface_driver_opts_helper(conf)
+    agent_config.register_use_namespaces_opts_helper(conf)
     agent_config.register_root_helper(conf)
     return conf
 
index 718475572952575dfc52206eb229d3ac82d27a42..15bbf3d4a22157019f35853b0d586e79da00c170 100644 (file)
@@ -39,11 +39,6 @@ class NeutronDebugAgent():
 
     OPTS = [
         # Needed for drivers
-        cfg.BoolOpt('use_namespaces', default=True,
-                    help=_("Use Linux network namespaces")),
-        cfg.StrOpt('interface_driver',
-                   help=_("The driver used to manage the virtual "
-                          "interface.")),
         cfg.StrOpt('external_network_bridge', default='br-ex',
                    help=_("Name of bridge used for external network "
                           "traffic.")),
index 103c43014f64c7ae85b7cf7428022479f8346659..42793f72113c3925c4b9be3dec0b4064e1d45f86 100644 (file)
@@ -74,6 +74,8 @@ class NeutronDebugShell(NeutronShell):
         client = self.client_manager.neutron
         cfg.CONF.register_opts(interface.OPTS)
         cfg.CONF.register_opts(NeutronDebugAgent.OPTS)
+        config.register_interface_driver_opts_helper(cfg.CONF)
+        config.register_use_namespaces_opts_helper(cfg.CONF)
         config.register_root_helper(cfg.CONF)
         cfg.CONF(['--config-file', self.options.config_file])
         config.setup_logging(cfg.CONF)
index b359ae18024c11b6d1ebdd6d19f1c3e219305935..25cf02ffadff9b0789de07b7a15ef41a538acf4a 100755 (executable)
@@ -331,6 +331,8 @@ def main():
     eventlet.monkey_patch()
     conf = cfg.CONF
     conf.register_opts(vArmourL3NATAgent.OPTS)
+    config.register_interface_driver_opts_helper(conf)
+    config.register_use_namespaces_opts_helper(conf)
     config.register_agent_state_opts_helper(conf)
     config.register_root_helper(conf)
     conf.register_opts(interface.OPTS)
index 64f661c914169282f832201c6ef0bdea614f742e..3a7116c2b3a9c9ca6a97d6532acb03b8281df1b1 100644 (file)
@@ -53,6 +53,7 @@ def main():
     cfg.CONF.register_opts(manager.OPTS)
     # import interface options just in case the driver uses namespaces
     cfg.CONF.register_opts(interface.OPTS)
+    config.register_interface_driver_opts_helper(cfg.CONF)
     config.register_agent_state_opts_helper(cfg.CONF)
     config.register_root_helper(cfg.CONF)
 
index 9517fae9b4486527f09b45d9288cbf083bee50ba..91b453071c4ce9c2b0897527f3736c2a5fcad411 100644 (file)
@@ -39,10 +39,6 @@ OPTS = [
                  '.haproxy.namespace_driver.HaproxyNSDriver'],
         help=_('Drivers used to manage loadbalancing devices'),
     ),
-    cfg.StrOpt(
-        'interface_driver',
-        help=_('The driver used to manage the virtual interface')
-    ),
 ]
 
 
index cd5e41c0f784dd80ae5c94b28e370e36a4a58108..33a4d27b638c15d46997aa0c08a56e2766ffb3f7 100644 (file)
@@ -34,16 +34,10 @@ TOP_CHAIN = WRAP_NAME + "-FORWARD"
 RULE = '-r-'
 LABEL = '-l-'
 
-IptablesDriverOpts = [
-    cfg.StrOpt('interface_driver',
-               help=_("The driver used to manage the virtual "
-                      "interface.")),
-    cfg.BoolOpt('use_namespaces', default=True,
-                help=_("Allow overlapping IP."))
-]
+config.register_interface_driver_opts_helper(cfg.CONF)
+config.register_use_namespaces_opts_helper(cfg.CONF)
 config.register_root_helper(cfg.CONF)
 cfg.CONF.register_opts(interface.OPTS)
-cfg.CONF.register_opts(IptablesDriverOpts)
 
 
 class IptablesManagerTransaction(object):
index cc550cfbe9e6fdfa514846180eca889775f0e01d..dc33bcef1457ea6ecc6dc9bdd327dd71cf068260 100644 (file)
@@ -38,6 +38,7 @@ class TestDhcpNoOpDriver(base.BaseTestCase):
     def setUp(self):
         super(TestDhcpNoOpDriver, self).setUp()
         self.conf = config.setup_conf()
+        config.register_interface_driver_opts_helper(self.conf)
         self.conf.register_opts(base_config.core_opts)
         self.conf.register_opts(dhcp.OPTS)
         self.conf.enable_isolated_metadata = True
index d9c6a640ce8320994f804e68cd027b3637218bd6..7933a34973639ae4834288e8f8e0a4f1fcac1712 100644 (file)
@@ -53,6 +53,7 @@ class TestFwaasL3AgentRpcCallback(base.BaseTestCase):
         self.conf = cfg.ConfigOpts()
         self.conf.register_opts(base_config.core_opts)
         self.conf.register_opts(l3_agent.L3NATAgent.OPTS)
+        agent_config.register_use_namespaces_opts_helper(self.conf)
         agent_config.register_root_helper(self.conf)
         self.conf.root_helper = 'sudo'
         self.api = FWaasAgent(self.conf)
index b56114380d4769017a33ee0fab9541ce7bbda9e6..3a7ddd8b941cf4052c5068181d22b85fafcbfda1 100644 (file)
@@ -44,6 +44,8 @@ class TestVarmourRouter(base.BaseTestCase):
         self.conf = cfg.ConfigOpts()
         self.conf.register_opts(base_config.core_opts)
         self.conf.register_opts(varmour_router.vArmourL3NATAgent.OPTS)
+        agent_config.register_interface_driver_opts_helper(self.conf)
+        agent_config.register_use_namespaces_opts_helper(self.conf)
         agent_config.register_root_helper(self.conf)
         self.conf.register_opts(interface.OPTS)
         self.conf.set_override('interface_driver',
index 79dfbfbb95c61b6ad39695341f7b4fc731e59680..7c6bd6673707a1e24e84c1eb4a9cd61c8946cc04 100644 (file)
@@ -45,6 +45,8 @@ class TestBasicRouterOperations(base.BaseTestCase):
         self.conf = cfg.ConfigOpts()
         self.conf.register_opts(base_config.core_opts)
         self.conf.register_opts(varmour_router.vArmourL3NATAgent.OPTS)
+        agent_config.register_interface_driver_opts_helper(self.conf)
+        agent_config.register_use_namespaces_opts_helper(self.conf)
         agent_config.register_root_helper(self.conf)
         self.conf.register_opts(interface.OPTS)
         self.conf.set_override('interface_driver',
index f22c18c0bff3ed87127d3be40acc4ed0b76988fe..4e60435178f97e66bfa6dee4309371c4d817e7e9 100644 (file)
@@ -52,6 +52,8 @@ class TestVPNAgent(base.BaseTestCase):
         self.conf.register_opts(base_config.core_opts)
         self.conf.register_opts(l3_agent.L3NATAgent.OPTS)
         self.conf.register_opts(interface.OPTS)
+        agent_config.register_interface_driver_opts_helper(self.conf)
+        agent_config.register_use_namespaces_opts_helper(self.conf)
         agent_config.register_agent_state_opts_helper(self.conf)
         agent_config.register_root_helper(self.conf)
 
index de60b0adc9db01d0dd9484908ab373d2d751bcf0..15b62f0e66f1199ac99c083e0f43c3e6ca31bd2e 100644 (file)
@@ -40,8 +40,10 @@ class TestDebugCommands(base.BaseTestCase):
         cfg.CONF.register_opts(interface.OPTS)
         cfg.CONF.register_opts(NeutronDebugAgent.OPTS)
         cfg.CONF(args=[], project='neutron')
-        cfg.CONF.set_override('use_namespaces', True)
+        config.register_interface_driver_opts_helper(cfg.CONF)
+        config.register_use_namespaces_opts_helper(cfg.CONF)
         config.register_root_helper(cfg.CONF)
+        cfg.CONF.set_override('use_namespaces', True)
 
         self.addCleanup(mock.patch.stopall)
         device_exists_p = mock.patch(
index f9f2002f3f33f876144845704ee61c3ea7e42ac7..e544118fee2642c5ba9bda18043e8f971f6588f1 100644 (file)
@@ -156,6 +156,7 @@ class TestDhcpAgent(base.BaseTestCase):
                             'dhcp', '--config-file',
                             etcdir('neutron.conf.test')]
                         cfg.CONF.register_opts(dhcp_agent.DhcpAgent.OPTS)
+                        config.register_interface_driver_opts_helper(cfg.CONF)
                         config.register_agent_state_opts_helper(cfg.CONF)
                         config.register_root_helper(cfg.CONF)
                         cfg.CONF.register_opts(dhcp.OPTS)
@@ -449,6 +450,7 @@ class TestLogArgs(base.BaseTestCase):
 class TestDhcpAgentEventHandler(base.BaseTestCase):
     def setUp(self):
         super(TestDhcpAgentEventHandler, self).setUp()
+        config.register_interface_driver_opts_helper(cfg.CONF)
         cfg.CONF.register_opts(dhcp.OPTS)
         cfg.CONF.set_override('interface_driver',
                               'neutron.agent.linux.interface.NullDriver')
@@ -1087,6 +1089,8 @@ class FakeV4NetworkNoGateway:
 class TestDeviceManager(base.BaseTestCase):
     def setUp(self):
         super(TestDeviceManager, self).setUp()
+        config.register_interface_driver_opts_helper(cfg.CONF)
+        config.register_use_namespaces_opts_helper(cfg.CONF)
         cfg.CONF.register_opts(dhcp_agent.DhcpAgent.OPTS)
         cfg.CONF.register_opts(dhcp.OPTS)
         cfg.CONF.set_override('interface_driver',
index 03625dbc73eac2e903715160beafcc9dbad309d2..4d199dbad78ca4ace9ef8997b41b4d68c3535132 100644 (file)
@@ -43,6 +43,8 @@ class TestBasicRouterOperations(base.BaseTestCase):
         self.conf = cfg.ConfigOpts()
         self.conf.register_opts(base_config.core_opts)
         self.conf.register_opts(l3_agent.L3NATAgent.OPTS)
+        agent_config.register_interface_driver_opts_helper(self.conf)
+        agent_config.register_use_namespaces_opts_helper(self.conf)
         agent_config.register_root_helper(self.conf)
         self.conf.register_opts(interface.OPTS)
         self.conf.set_override('router_id', 'fake_id')
index 7086a7b7fee91812d087ad84c3b53c1fd7126700..1baa17c595d4a79088329aca949274bc9538bcf6 100644 (file)
@@ -394,6 +394,7 @@ class TestBase(base.BaseTestCase):
         self.conf = config.setup_conf()
         self.conf.register_opts(base_config.core_opts)
         self.conf.register_opts(dhcp.OPTS)
+        config.register_interface_driver_opts_helper(self.conf)
         instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager")
         self.mock_mgr = instance.start()
         self.conf.register_opt(cfg.BoolOpt('enable_isolated_metadata',
index 43ebd093a3c8ff55caedb9cdfebe41b3c1ec613a..09bf8df27fdc9a6c00835a393b8e905355eea1cd 100644 (file)
@@ -373,6 +373,7 @@ class TestBridgeInterfaceDriver(TestBase):
 class TestMetaInterfaceDriver(TestBase):
     def setUp(self):
         super(TestMetaInterfaceDriver, self).setUp()
+        config.register_interface_driver_opts_helper(self.conf)
         self.conf.register_opts(dhcp.OPTS)
         self.client_cls_p = mock.patch('neutronclient.v2_0.client.Client')
         client_cls = self.client_cls_p.start()