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
This commit is contained in:
Brian Haley 2015-04-10 15:51:43 -04:00
parent 9c0f00a0a7
commit c72559f32d
6 changed files with 4 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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))

View File

@ -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')