From c72559f32dc7cabcd5614ae07e0da2e2248c2785 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Fri, 10 Apr 2015 15:51:43 -0400 Subject: [PATCH] Move iptables and ipset config registration into modules Do not do this on a per-object basis, but instead in the module. Change-Id: Ib1cc604c7c0135ca62a6194d8e20a3c29d3c5ed6 Closes-bug: #1441163 --- neutron/agent/linux/ipset_manager.py | 3 ++- neutron/agent/linux/iptables_manager.py | 3 ++- neutron/tests/unit/agent/linux/test_ipset_manager.py | 2 -- neutron/tests/unit/agent/linux/test_iptables_firewall.py | 1 - neutron/tests/unit/agent/linux/test_iptables_manager.py | 4 ---- neutron/tests/unit/agent/test_securitygroups_rpc.py | 2 -- 6 files changed, 4 insertions(+), 11 deletions(-) diff --git a/neutron/agent/linux/ipset_manager.py b/neutron/agent/linux/ipset_manager.py index 33b6379b5..8652fa74f 100644 --- a/neutron/agent/linux/ipset_manager.py +++ b/neutron/agent/linux/ipset_manager.py @@ -21,6 +21,8 @@ IPSET_ADD_BULK_THRESHOLD = 5 SWAP_SUFFIX = '-new' IPSET_NAME_MAX_LENGTH = 31 - len(SWAP_SUFFIX) +config.register_ipset_opts(cfg.CONF) + class IpsetManager(object): """Smart wrapper for ipset. @@ -32,7 +34,6 @@ class IpsetManager(object): def __init__(self, execute=None, namespace=None): self.execute = execute or linux_utils.execute self.namespace = namespace - config.register_ipset_opts(cfg.CONF) self.ipset_sets = {} @staticmethod diff --git a/neutron/agent/linux/iptables_manager.py b/neutron/agent/linux/iptables_manager.py index f7c0be4b8..28b89952e 100644 --- a/neutron/agent/linux/iptables_manager.py +++ b/neutron/agent/linux/iptables_manager.py @@ -37,6 +37,8 @@ from neutron.i18n import _LE, _LW LOG = logging.getLogger(__name__) +config.register_iptables_opts(cfg.CONF) + # NOTE(vish): Iptables supports chain names of up to 28 characters, and we # add up to 12 characters to binary_name which is used as a prefix, @@ -288,7 +290,6 @@ class IptablesManager(object): else: self.execute = linux_utils.execute - config.register_iptables_opts(cfg.CONF) self.use_ipv6 = use_ipv6 self.namespace = namespace self.iptables_apply_deferred = False diff --git a/neutron/tests/unit/agent/linux/test_ipset_manager.py b/neutron/tests/unit/agent/linux/test_ipset_manager.py index 19fbb7e20..a06aea5de 100644 --- a/neutron/tests/unit/agent/linux/test_ipset_manager.py +++ b/neutron/tests/unit/agent/linux/test_ipset_manager.py @@ -14,7 +14,6 @@ import mock from oslo_config import cfg -from neutron.agent.common import config as a_cfg from neutron.agent.linux import ipset_manager from neutron.tests import base @@ -29,7 +28,6 @@ FAKE_IPS = ['10.0.0.1', '10.0.0.2', '10.0.0.3', '10.0.0.4', class BaseIpsetManagerTest(base.BaseTestCase): def setUp(self, maxelem=None, hashsize=None): super(BaseIpsetManagerTest, self).setUp() - cfg.CONF.register_opts(a_cfg.IPSET_OPTS, 'AGENT') cfg.CONF.set_override('ipset_maxelem', maxelem, 'AGENT') cfg.CONF.set_override('ipset_hashsize', hashsize, 'AGENT') self.maxelem = maxelem diff --git a/neutron/tests/unit/agent/linux/test_iptables_firewall.py b/neutron/tests/unit/agent/linux/test_iptables_firewall.py index 7de641359..197326251 100644 --- a/neutron/tests/unit/agent/linux/test_iptables_firewall.py +++ b/neutron/tests/unit/agent/linux/test_iptables_firewall.py @@ -46,7 +46,6 @@ class BaseIptablesFirewallTestCase(base.BaseTestCase): super(BaseIptablesFirewallTestCase, self).setUp() cfg.CONF.register_opts(a_cfg.ROOT_HELPER_OPTS, 'AGENT') cfg.CONF.register_opts(sg_cfg.security_group_opts, 'SECURITYGROUP') - cfg.CONF.register_opts(a_cfg.IPTABLES_OPTS, 'AGENT') cfg.CONF.set_override('comment_iptables_rules', False, 'AGENT') self.utils_exec_p = mock.patch( 'neutron.agent.linux.utils.execute') diff --git a/neutron/tests/unit/agent/linux/test_iptables_manager.py b/neutron/tests/unit/agent/linux/test_iptables_manager.py index ddd55b258..4a1457c07 100644 --- a/neutron/tests/unit/agent/linux/test_iptables_manager.py +++ b/neutron/tests/unit/agent/linux/test_iptables_manager.py @@ -20,7 +20,6 @@ import mock from oslo_config import cfg import testtools -from neutron.agent.common import config as a_cfg from neutron.agent.linux import iptables_comments as ic from neutron.agent.linux import iptables_manager from neutron.common import exceptions as n_exc @@ -132,7 +131,6 @@ class IptablesCommentsTestCase(base.BaseTestCase): def setUp(self): super(IptablesCommentsTestCase, self).setUp() - cfg.CONF.register_opts(a_cfg.IPTABLES_OPTS, 'AGENT') cfg.CONF.set_override('comment_iptables_rules', True, 'AGENT') self.iptables = iptables_manager.IptablesManager() self.execute = mock.patch.object(self.iptables, "execute").start() @@ -232,7 +230,6 @@ class IptablesManagerStateFulTestCase(base.BaseTestCase): def setUp(self): super(IptablesManagerStateFulTestCase, self).setUp() - cfg.CONF.register_opts(a_cfg.IPTABLES_OPTS, 'AGENT') cfg.CONF.set_override('comment_iptables_rules', False, 'AGENT') self.iptables = iptables_manager.IptablesManager() self.execute = mock.patch.object(self.iptables, "execute").start() @@ -1015,7 +1012,6 @@ class IptablesManagerStateLessTestCase(base.BaseTestCase): def setUp(self): super(IptablesManagerStateLessTestCase, self).setUp() - cfg.CONF.register_opts(a_cfg.IPTABLES_OPTS, 'AGENT') cfg.CONF.set_override('comment_iptables_rules', False, 'AGENT') self.iptables = (iptables_manager.IptablesManager(state_less=True)) diff --git a/neutron/tests/unit/agent/test_securitygroups_rpc.py b/neutron/tests/unit/agent/test_securitygroups_rpc.py index feabbcbfd..29f305118 100644 --- a/neutron/tests/unit/agent/test_securitygroups_rpc.py +++ b/neutron/tests/unit/agent/test_securitygroups_rpc.py @@ -22,7 +22,6 @@ import oslo_messaging from testtools import matchers import webob.exc -from neutron.agent.common import config from neutron.agent import firewall as firewall_base from neutron.agent.linux import iptables_manager from neutron.agent import securitygroups_rpc as sg_rpc @@ -2505,7 +2504,6 @@ class TestSecurityGroupAgentWithIptables(base.BaseTestCase): def setUp(self, defer_refresh_firewall=False, test_rpc_v1_1=True): super(TestSecurityGroupAgentWithIptables, self).setUp() - config.register_iptables_opts(cfg.CONF) set_firewall_driver(self.FIREWALL_DRIVER) cfg.CONF.set_override('enable_ipset', False, group='SECURITYGROUP') cfg.CONF.set_override('comment_iptables_rules', False, group='AGENT') -- 2.45.2