Merge "Refactoring config options for cmd"
This commit is contained in:
commit
ee42af1011
@ -16,10 +16,10 @@
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron._i18n import _, _LE, _LI
|
||||
from neutron.agent.linux import ipset_manager
|
||||
from neutron._i18n import _LE, _LI
|
||||
from neutron.agent.linux import utils
|
||||
from neutron.common import config
|
||||
from neutron.conf.agent import cmd as command
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -31,22 +31,8 @@ def setup_conf():
|
||||
Use separate setup_conf for the utility because there are many options
|
||||
from the main config that do not apply during clean-up.
|
||||
"""
|
||||
|
||||
cli_opts = [
|
||||
cfg.BoolOpt('allsets',
|
||||
default=False,
|
||||
help=_('Destroy all IPsets.')),
|
||||
cfg.BoolOpt('force',
|
||||
default=False,
|
||||
help=_('Destroy IPsets even if there is an iptables '
|
||||
'reference.')),
|
||||
cfg.StrOpt('prefix',
|
||||
default=ipset_manager.NET_PREFIX,
|
||||
help=_('String prefix used to match IPset names.')),
|
||||
]
|
||||
|
||||
conf = cfg.CONF
|
||||
conf.register_cli_opts(cli_opts)
|
||||
command.register_cmd_opts(command.ip_opts, conf)
|
||||
return conf
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
from neutron._i18n import _, _LE
|
||||
from neutron._i18n import _LE
|
||||
from neutron.agent.common import config as agent_config
|
||||
from neutron.agent.common import ovs_lib
|
||||
from neutron.agent.l3 import agent as l3_agent
|
||||
@ -33,6 +33,7 @@ from neutron.agent.linux import external_process
|
||||
from neutron.agent.linux import interface
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.common import config
|
||||
from neutron.conf.agent import cmd
|
||||
from neutron.conf.agent import dhcp as dhcp_config
|
||||
|
||||
|
||||
@ -60,17 +61,8 @@ def setup_conf():
|
||||
from the main config that do not apply during clean-up.
|
||||
"""
|
||||
|
||||
cli_opts = [
|
||||
cfg.BoolOpt('force',
|
||||
default=False,
|
||||
help=_('Delete the namespace by removing all devices.')),
|
||||
cfg.StrOpt('agent-type',
|
||||
choices=['dhcp', 'l3', 'lbaas'],
|
||||
help=_('Cleanup resources of a specific agent type only.')),
|
||||
]
|
||||
|
||||
conf = cfg.CONF
|
||||
conf.register_cli_opts(cli_opts)
|
||||
cmd.register_cmd_opts(cmd.netns_opts, conf)
|
||||
agent_config.register_interface_driver_opts_helper(conf)
|
||||
dhcp_config.register_agent_dhcp_opts(conf)
|
||||
conf.register_opts(interface.OPTS)
|
||||
|
@ -16,12 +16,13 @@
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron._i18n import _, _LI
|
||||
from neutron._i18n import _LI
|
||||
from neutron.agent.common import config as agent_config
|
||||
from neutron.agent.common import ovs_lib
|
||||
from neutron.agent.linux import interface
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.common import config
|
||||
from neutron.conf.agent import cmd
|
||||
from neutron.conf.agent.l3 import config as l3_config
|
||||
|
||||
|
||||
@ -34,17 +35,9 @@ def setup_conf():
|
||||
Use separate setup_conf for the utility because there are many options
|
||||
from the main config that do not apply during clean-up.
|
||||
"""
|
||||
opts = [
|
||||
cfg.BoolOpt('ovs_all_ports',
|
||||
default=False,
|
||||
help=_('True to delete all ports on all the OpenvSwitch '
|
||||
'bridges. False to delete ports created by '
|
||||
'Neutron on integration and external network '
|
||||
'bridges.'))
|
||||
]
|
||||
|
||||
conf = cfg.CONF
|
||||
conf.register_cli_opts(opts)
|
||||
cmd.register_cmd_opts(cmd.ovs_opts, conf)
|
||||
l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf)
|
||||
conf.register_opts(interface.OPTS)
|
||||
agent_config.register_interface_driver_opts_helper(conf)
|
||||
|
52
neutron/conf/agent/cmd.py
Normal file
52
neutron/conf/agent/cmd.py
Normal file
@ -0,0 +1,52 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.agent.linux import ipset_manager
|
||||
|
||||
|
||||
ip_opts = [
|
||||
cfg.BoolOpt('allsets',
|
||||
default=False,
|
||||
help=_('Destroy all IPsets.')),
|
||||
cfg.BoolOpt('force',
|
||||
default=False,
|
||||
help=_('Destroy IPsets even if there is an iptables '
|
||||
'reference.')),
|
||||
cfg.StrOpt('prefix',
|
||||
default=ipset_manager.NET_PREFIX,
|
||||
help=_('String prefix used to match IPset names.')),
|
||||
]
|
||||
|
||||
netns_opts = [
|
||||
cfg.BoolOpt('force',
|
||||
default=False,
|
||||
help=_('Delete the namespace by removing all devices.')),
|
||||
cfg.StrOpt('agent-type',
|
||||
choices=['dhcp', 'l3', 'lbaas'],
|
||||
help=_('Cleanup resources of a specific agent type only.')),
|
||||
]
|
||||
|
||||
ovs_opts = [
|
||||
cfg.BoolOpt('ovs_all_ports',
|
||||
default=False,
|
||||
help=_('True to delete all ports on all the OpenvSwitch '
|
||||
'bridges. False to delete ports created by '
|
||||
'Neutron on integration and external network '
|
||||
'bridges.'))
|
||||
]
|
||||
|
||||
|
||||
def register_cmd_opts(opts, cfg=cfg.CONF):
|
||||
cfg.register_cli_opts(opts)
|
31
neutron/tests/functional/cmd/test_ipset_cleanup.py
Normal file
31
neutron/tests/functional/cmd/test_ipset_cleanup.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.agent.linux import ipset_manager
|
||||
from neutron.cmd import ipset_cleanup
|
||||
from neutron.conf.agent import cmd
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class TestIPSetCLIConfig(base.BaseTestCase):
|
||||
|
||||
def setup_config(self, args=None):
|
||||
self.conf = ipset_cleanup.setup_conf()
|
||||
super(TestIPSetCLIConfig, self).setup_config(args=args)
|
||||
|
||||
def test_ipset_opts_registration(self):
|
||||
self.assertFalse(self.conf.allsets)
|
||||
self.assertFalse(self.conf.force)
|
||||
self.assertEqual(ipset_manager.NET_PREFIX, self.conf.prefix)
|
||||
# to unregister opts
|
||||
self.conf.reset()
|
||||
self.conf.unregister_opts(cmd.ip_opts)
|
@ -19,6 +19,8 @@ from neutron.agent.l3 import agent as l3_agent
|
||||
from neutron.agent.linux import dhcp
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.cmd import netns_cleanup
|
||||
from neutron.conf.agent import cmd
|
||||
from neutron.tests import base as basetest
|
||||
from neutron.tests.common import net_helpers
|
||||
from neutron.tests.functional import base
|
||||
|
||||
@ -64,3 +66,17 @@ class NetnsCleanupTest(base.BaseSudoTestCase):
|
||||
namespaces_now = ip_lib.IPWrapper.get_namespaces()
|
||||
self.assertNotIn(l3_namespace, namespaces_now)
|
||||
self.assertNotIn(dhcp_namespace, namespaces_now)
|
||||
|
||||
|
||||
class TestNETNSCLIConfig(basetest.BaseTestCase):
|
||||
|
||||
def setup_config(self, args=None):
|
||||
self.conf = netns_cleanup.setup_conf()
|
||||
super(TestNETNSCLIConfig, self).setup_config(args=args)
|
||||
|
||||
def test_netns_opts_registration(self):
|
||||
self.assertFalse(self.conf.force)
|
||||
self.assertIsNone(self.conf.get('agent_type'))
|
||||
# to unregister opts
|
||||
self.conf.reset()
|
||||
self.conf.unregister_opts(cmd.netns_opts)
|
||||
|
28
neutron/tests/functional/cmd/test_ovs_cleanup.py
Normal file
28
neutron/tests/functional/cmd/test_ovs_cleanup.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.cmd import ovs_cleanup
|
||||
from neutron.conf.agent import cmd
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class TestOVSCLIConfig(base.BaseTestCase):
|
||||
|
||||
def setup_config(self, args=None):
|
||||
self.conf = ovs_cleanup.setup_conf()
|
||||
super(TestOVSCLIConfig, self).setup_config(args=args)
|
||||
|
||||
def test_ovs_opts_registration(self):
|
||||
self.assertFalse(self.conf.ovs_all_ports)
|
||||
# to unregister opts
|
||||
self.conf.reset()
|
||||
self.conf.unregister_opts(cmd.ovs_opts)
|
Loading…
Reference in New Issue
Block a user