Refactoring config options for l3 agent config

Refactoring neutron configuration options for l3 agent to be in
neutron/conf/agent/l3. This would allow centralization of all
configuration options in neutron/conf and provide an easy way to import.

Change-Id: Ie7533ea55eaa4d0f2c1919131a75f56e027c4d6e
Partial-Bug: #1563069
This commit is contained in:
Aradhana Singh 2016-07-06 23:07:31 +00:00
parent 122a971656
commit 88fd2521c1
9 changed files with 124 additions and 93 deletions

View File

@ -14,88 +14,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
# TODO(asingh): https://review.openstack.org/#/c/338596/ refactors
# neutron.agent.l3.config to neutron.conf.agent.l3.config.
# neutron-fwaas/cmd/eventlet/agents/fw.py imports neutron.agent.l3.config
# This file will be removed when neutron-fwaas imports the updated file
# https://review.openstack.org/#/c/339177/
from neutron._i18n import _
from neutron.agent.common import config
from neutron.common import constants
import neutron.conf.agent.l3.config
OPTS = [
cfg.StrOpt('agent_mode', default=constants.L3_AGENT_MODE_LEGACY,
choices=(constants.L3_AGENT_MODE_DVR,
constants.L3_AGENT_MODE_DVR_SNAT,
constants.L3_AGENT_MODE_LEGACY),
help=_("The working mode for the agent. Allowed modes are: "
"'legacy' - this preserves the existing behavior "
"where the L3 agent is deployed on a centralized "
"networking node to provide L3 services like DNAT, "
"and SNAT. Use this mode if you do not want to "
"adopt DVR. 'dvr' - this mode enables DVR "
"functionality and must be used for an L3 agent "
"that runs on a compute host. 'dvr_snat' - this "
"enables centralized SNAT support in conjunction "
"with DVR. This mode must be used for an L3 agent "
"running on a centralized node (or in single-host "
"deployments, e.g. devstack)")),
cfg.PortOpt('metadata_port',
default=9697,
help=_("TCP Port used by Neutron metadata namespace proxy.")),
cfg.IntOpt('send_arp_for_ha',
default=3,
help=_("Send this many gratuitous ARPs for HA setup, if "
"less than or equal to 0, the feature is disabled")),
cfg.BoolOpt('handle_internal_only_routers',
default=True,
help=_("Indicates that this L3 agent should also handle "
"routers that do not have an external network gateway "
"configured. This option should be True only for a "
"single agent in a Neutron deployment, and may be "
"False for all agents if all routers must have an "
"external network gateway.")),
cfg.StrOpt('gateway_external_network_id', default='',
help=_("When external_network_bridge is set, each L3 agent can "
"be associated with no more than one external network. "
"This value should be set to the UUID of that external "
"network. To allow L3 agent support multiple external "
"networks, both the external_network_bridge and "
"gateway_external_network_id must be left empty.")),
cfg.StrOpt('ipv6_gateway', default='',
help=_("With IPv6, the network used for the external gateway "
"does not need to have an associated subnet, since the "
"automatically assigned link-local address (LLA) can "
"be used. However, an IPv6 gateway address is needed "
"for use as the next-hop for the default route. "
"If no IPv6 gateway address is configured here, "
"(and only then) the neutron router will be configured "
"to get its default route from router advertisements "
"(RAs) from the upstream router; in which case the "
"upstream router must also be configured to send "
"these RAs. "
"The ipv6_gateway, when configured, should be the LLA "
"of the interface on the upstream router. If a "
"next-hop using a global unique address (GUA) is "
"desired, it needs to be done via a subnet allocated "
"to the network and not through this parameter. ")),
cfg.StrOpt('prefix_delegation_driver',
default='dibbler',
help=_('Driver used for ipv6 prefix delegation. This needs to '
'be an entry point defined in the '
'neutron.agent.linux.pd_drivers namespace. See '
'setup.cfg for entry points included with the neutron '
'source.')),
cfg.BoolOpt('enable_metadata_proxy', default=True,
help=_("Allow running metadata proxy.")),
cfg.StrOpt('metadata_access_mark',
default='0x1',
help=_('Iptables mangle mark used to mark metadata valid '
'requests. This mark will be masked with 0xffff so '
'that only the lower 16 bits will be used.')),
cfg.StrOpt('external_ingress_mark',
default='0x2',
help=_('Iptables mangle mark used to mark ingress from '
'external network. This mark will be masked with '
'0xffff so that only the lower 16 bits will be used.')),
]
OPTS += config.EXT_NET_BRIDGE_OPTS
OPTS = neutron.conf.agent.l3.config.OPTS

View File

@ -20,7 +20,6 @@ from oslo_config import cfg
from oslo_service import service
from neutron.agent.common import config
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
@ -29,11 +28,12 @@ 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
from neutron.conf.agent.l3 import config as l3_config
from neutron import service as neutron_service
def register_opts(conf):
conf.register_opts(l3_config.OPTS)
l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf)
conf.register_opts(metadata_config.DRIVER_OPTS)
conf.register_opts(metadata_config.SHARED_OPTS)
conf.register_opts(ha.OPTS)

View File

@ -19,10 +19,10 @@ from oslo_log import log as logging
from neutron._i18n import _, _LI
from neutron.agent.common import config as agent_config
from neutron.agent.common import ovs_lib
from neutron.agent.l3 import config as l3_config
from neutron.agent.linux import interface
from neutron.agent.linux import ip_lib
from neutron.common import config
from neutron.conf.agent.l3 import config as l3_config
LOG = logging.getLogger(__name__)
@ -45,7 +45,7 @@ def setup_conf():
conf = cfg.CONF
conf.register_cli_opts(opts)
conf.register_opts(l3_config.OPTS)
l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf)
conf.register_opts(interface.OPTS)
agent_config.register_interface_driver_opts_helper(conf)
return conf

View File

View File

@ -0,0 +1,105 @@
# Copyright (c) 2015 OpenStack Foundation.
#
# All Rights Reserved.
#
# 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.common import config
from neutron.common import constants
OPTS = [
cfg.StrOpt('agent_mode', default=constants.L3_AGENT_MODE_LEGACY,
choices=(constants.L3_AGENT_MODE_DVR,
constants.L3_AGENT_MODE_DVR_SNAT,
constants.L3_AGENT_MODE_LEGACY),
help=_("The working mode for the agent. Allowed modes are: "
"'legacy' - this preserves the existing behavior "
"where the L3 agent is deployed on a centralized "
"networking node to provide L3 services like DNAT, "
"and SNAT. Use this mode if you do not want to "
"adopt DVR. 'dvr' - this mode enables DVR "
"functionality and must be used for an L3 agent "
"that runs on a compute host. 'dvr_snat' - this "
"enables centralized SNAT support in conjunction "
"with DVR. This mode must be used for an L3 agent "
"running on a centralized node (or in single-host "
"deployments, e.g. devstack)")),
cfg.PortOpt('metadata_port',
default=9697,
help=_("TCP Port used by Neutron metadata namespace proxy.")),
cfg.IntOpt('send_arp_for_ha',
default=3,
help=_("Send this many gratuitous ARPs for HA setup, if "
"less than or equal to 0, the feature is disabled")),
cfg.BoolOpt('handle_internal_only_routers',
default=True,
help=_("Indicates that this L3 agent should also handle "
"routers that do not have an external network gateway "
"configured. This option should be True only for a "
"single agent in a Neutron deployment, and may be "
"False for all agents if all routers must have an "
"external network gateway.")),
cfg.StrOpt('gateway_external_network_id', default='',
help=_("When external_network_bridge is set, each L3 agent can "
"be associated with no more than one external network. "
"This value should be set to the UUID of that external "
"network. To allow L3 agent support multiple external "
"networks, both the external_network_bridge and "
"gateway_external_network_id must be left empty.")),
cfg.StrOpt('ipv6_gateway', default='',
help=_("With IPv6, the network used for the external gateway "
"does not need to have an associated subnet, since the "
"automatically assigned link-local address (LLA) can "
"be used. However, an IPv6 gateway address is needed "
"for use as the next-hop for the default route. "
"If no IPv6 gateway address is configured here, "
"(and only then) the neutron router will be configured "
"to get its default route from router advertisements "
"(RAs) from the upstream router; in which case the "
"upstream router must also be configured to send "
"these RAs. "
"The ipv6_gateway, when configured, should be the LLA "
"of the interface on the upstream router. If a "
"next-hop using a global unique address (GUA) is "
"desired, it needs to be done via a subnet allocated "
"to the network and not through this parameter. ")),
cfg.StrOpt('prefix_delegation_driver',
default='dibbler',
help=_('Driver used for ipv6 prefix delegation. This needs to '
'be an entry point defined in the '
'neutron.agent.linux.pd_drivers namespace. See '
'setup.cfg for entry points included with the neutron '
'source.')),
cfg.BoolOpt('enable_metadata_proxy', default=True,
help=_("Allow running metadata proxy.")),
cfg.StrOpt('metadata_access_mark',
default='0x1',
help=_('Iptables mangle mark used to mark metadata valid '
'requests. This mark will be masked with 0xffff so '
'that only the lower 16 bits will be used.')),
cfg.StrOpt('external_ingress_mark',
default='0x2',
help=_('Iptables mangle mark used to mark ingress from '
'external network. This mark will be masked with '
'0xffff so that only the lower 16 bits will be used.')),
]
OPTS += config.EXT_NET_BRIDGE_OPTS
def register_l3_agent_config_opts(opts, cfg=cfg.CONF):
cfg.register_opts(opts)

View File

@ -30,6 +30,7 @@ import neutron.agent.ovsdb.api
import neutron.agent.securitygroups_rpc
import neutron.common.cache_utils
import neutron.conf.agent.dhcp
import neutron.conf.agent.l3.config
import neutron.conf.quota
import neutron.conf.service
import neutron.db.agents_db
@ -195,7 +196,7 @@ def list_l3_agent_opts():
return [
('DEFAULT',
itertools.chain(
neutron.agent.l3.config.OPTS,
neutron.conf.agent.l3.config.OPTS,
neutron.conf.service.service_opts,
neutron.agent.l3.ha.OPTS,
neutron.agent.linux.pd.OPTS,

View File

@ -31,7 +31,6 @@ from testtools import matchers
from neutron.agent.common import config as agent_config
from neutron.agent.l3 import agent as l3_agent
from neutron.agent.l3 import config as l3_config
from neutron.agent.l3 import dvr_edge_router as dvr_router
from neutron.agent.l3 import dvr_snat_ns
from neutron.agent.l3 import ha
@ -51,6 +50,7 @@ from neutron.agent import rpc as agent_rpc
from neutron.common import config as base_config
from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.conf.agent.l3 import config as l3_config
from neutron.extensions import portbindings
from neutron.plugins.common import constants as p_const
from neutron.tests import base
@ -71,7 +71,7 @@ class BasicRouterOperationsFramework(base.BaseTestCase):
self.conf.register_opts(base_config.core_opts)
log.register_options(self.conf)
self.conf.register_opts(agent_config.AGENT_STATE_OPTS, 'AGENT')
self.conf.register_opts(l3_config.OPTS)
l3_config.register_l3_agent_config_opts(l3_config.OPTS, self.conf)
self.conf.register_opts(ha.OPTS)
agent_config.register_interface_driver_opts_helper(self.conf)
agent_config.register_process_monitor_opts(self.conf)

View File

@ -20,7 +20,6 @@ from oslo_utils import uuidutils
from neutron.agent.common import config as agent_config
from neutron.agent.l3 import agent as l3_agent
from neutron.agent.l3 import config as l3_config
from neutron.agent.l3 import dvr_local_router as dvr_router
from neutron.agent.l3 import ha
from neutron.agent.l3 import link_local_allocator as lla
@ -31,6 +30,7 @@ from neutron.agent.linux import ip_lib
from neutron.common import config as base_config
from neutron.common import constants as n_const
from neutron.common import utils as common_utils
from neutron.conf.agent.l3 import config as l3_config
from neutron.extensions import portbindings
from neutron.tests import base
from neutron.tests.common import l3_test_common
@ -49,7 +49,7 @@ class TestDvrRouterOperations(base.BaseTestCase):
self.conf.register_opts(base_config.core_opts)
log.register_options(self.conf)
self.conf.register_opts(agent_config.AGENT_STATE_OPTS, 'AGENT')
self.conf.register_opts(l3_config.OPTS)
l3_config.register_l3_agent_config_opts(l3_config.OPTS, self.conf)
self.conf.register_opts(ha.OPTS)
agent_config.register_interface_driver_opts_helper(self.conf)
agent_config.register_process_monitor_opts(self.conf)

View File

@ -19,11 +19,11 @@ from oslo_utils import uuidutils
from neutron.agent.common import config as agent_config
from neutron.agent.l3 import agent as l3_agent
from neutron.agent.l3 import config as l3_config
from neutron.agent.l3 import ha as l3_ha_agent
from neutron.agent.metadata import config
from neutron.agent.metadata import driver as metadata_driver
from neutron.common import constants
from neutron.conf.agent.l3 import config as l3_config
from neutron.tests import base
@ -74,7 +74,7 @@ class TestMetadataDriverProcess(base.BaseTestCase):
mock.patch('neutron.agent.l3.ha.AgentMixin'
'._init_ha_conf_path').start()
cfg.CONF.register_opts(l3_config.OPTS)
l3_config.register_l3_agent_config_opts(l3_config.OPTS, cfg.CONF)
cfg.CONF.register_opts(l3_ha_agent.OPTS)
cfg.CONF.register_opts(config.SHARED_OPTS)
cfg.CONF.register_opts(config.DRIVER_OPTS)