Refactoring config options for common config opts

Refactoring neutron common config opts to be in neutron/conf/common so
that all the configuration options reside in a centralized location.
This simplifies the process of looking up the config opts and provides
an easy way to import.

Moved conf/common/config.py to conf/common.py as per review comments.

Partial-Bug: #1563069

Change-Id: Ib5fa294906549237630f87b9c848eebe0644088c
This commit is contained in:
Anindita Das 2016-07-19 14:37:56 +00:00
parent f7ec19ad01
commit 414ceed4f3
13 changed files with 226 additions and 193 deletions

View File

@ -29,179 +29,15 @@ from oslo_middleware import cors
from oslo_service import wsgi
from neutron._i18n import _, _LI
from neutron import api
from neutron.common import constants
from neutron.common import utils
from neutron.conf import common as common_config
from neutron import policy
from neutron import version
LOG = logging.getLogger(__name__)
core_opts = [
cfg.StrOpt('bind_host', default='0.0.0.0',
help=_("The host IP to bind to")),
cfg.PortOpt('bind_port', default=9696,
help=_("The port to bind to")),
cfg.StrOpt('api_extensions_path', default="",
help=_("The path for API extensions. "
"Note that this can be a colon-separated list of paths. "
"For example: api_extensions_path = "
"extensions:/path/to/more/exts:/even/more/exts. "
"The __path__ of neutron.extensions is appended to "
"this, so if your extensions are in there you don't "
"need to specify them here.")),
cfg.StrOpt('auth_strategy', default='keystone',
help=_("The type of authentication to use")),
cfg.StrOpt('core_plugin',
help=_("The core plugin Neutron will use")),
cfg.ListOpt('service_plugins', default=[],
help=_("The service plugins Neutron will use")),
cfg.StrOpt('base_mac', default="fa:16:3e:00:00:00",
help=_("The base MAC address Neutron will use for VIFs. "
"The first 3 octets will remain unchanged. If the 4th "
"octet is not 00, it will also be used. The others "
"will be randomly generated.")),
cfg.IntOpt('mac_generation_retries', default=16,
deprecated_for_removal=True,
help=_("How many times Neutron will retry MAC generation. This "
"option is now obsolete and so is deprecated to be "
"removed in the Ocata release.")),
cfg.BoolOpt('allow_bulk', default=True,
help=_("Allow the usage of the bulk API")),
cfg.BoolOpt('allow_pagination', default=api.DEFAULT_ALLOW_PAGINATION,
help=_("Allow the usage of the pagination")),
cfg.BoolOpt('allow_sorting', default=api.DEFAULT_ALLOW_SORTING,
help=_("Allow the usage of the sorting")),
cfg.StrOpt('pagination_max_limit', default="-1",
help=_("The maximum number of items returned in a single "
"response, value was 'infinite' or negative integer "
"means no limit")),
cfg.ListOpt('default_availability_zones', default=[],
help=_("Default value of availability zone hints. The "
"availability zone aware schedulers use this when "
"the resources availability_zone_hints is empty. "
"Multiple availability zones can be specified by a "
"comma separated string. This value can be empty. "
"In this case, even if availability_zone_hints for "
"a resource is empty, availability zone is "
"considered for high availability while scheduling "
"the resource.")),
cfg.IntOpt('max_dns_nameservers', default=5,
help=_("Maximum number of DNS nameservers per subnet")),
cfg.IntOpt('max_subnet_host_routes', default=20,
help=_("Maximum number of host routes per subnet")),
cfg.IntOpt('max_fixed_ips_per_port', default=5,
deprecated_for_removal=True,
help=_("Maximum number of fixed ips per port. This option "
"is deprecated and will be removed in the N "
"release.")),
cfg.StrOpt('default_ipv4_subnet_pool', deprecated_for_removal=True,
help=_("Default IPv4 subnet pool to be used for automatic "
"subnet CIDR allocation. "
"Specifies by UUID the pool to be used in case where "
"creation of a subnet is being called without a "
"subnet pool ID. If not set then no pool "
"will be used unless passed explicitly to the subnet "
"create. If no pool is used, then a CIDR must be passed "
"to create a subnet and that subnet will not be "
"allocated from any pool; it will be considered part of "
"the tenant's private address space. This option is "
"deprecated for removal in the N release.")),
cfg.StrOpt('default_ipv6_subnet_pool', deprecated_for_removal=True,
help=_("Default IPv6 subnet pool to be used for automatic "
"subnet CIDR allocation. "
"Specifies by UUID the pool to be used in case where "
"creation of a subnet is being called without a "
"subnet pool ID. See the description for "
"default_ipv4_subnet_pool for more information. This "
"option is deprecated for removal in the N release.")),
cfg.BoolOpt('ipv6_pd_enabled', default=False,
help=_("Enables IPv6 Prefix Delegation for automatic subnet "
"CIDR allocation. "
"Set to True to enable IPv6 Prefix Delegation for "
"subnet allocation in a PD-capable environment. Users "
"making subnet creation requests for IPv6 subnets "
"without providing a CIDR or subnetpool ID will be "
"given a CIDR via the Prefix Delegation mechanism. "
"Note that enabling PD will override the behavior of "
"the default IPv6 subnetpool.")),
cfg.IntOpt('dhcp_lease_duration', default=86400,
deprecated_name='dhcp_lease_time',
help=_("DHCP lease duration (in seconds). Use -1 to tell "
"dnsmasq to use infinite lease times.")),
cfg.StrOpt('dns_domain',
default='openstacklocal',
help=_('Domain to use for building the hostnames')),
cfg.StrOpt('external_dns_driver',
help=_('Driver for external DNS integration.')),
cfg.BoolOpt('dhcp_agent_notification', default=True,
help=_("Allow sending resource operation"
" notification to DHCP agent")),
cfg.BoolOpt('allow_overlapping_ips', default=False,
help=_("Allow overlapping IP support in Neutron. "
"Attention: the following parameter MUST be set to "
"False if Neutron is being used in conjunction with "
"Nova security groups.")),
cfg.StrOpt('host', default=utils.get_hostname(),
sample_default='example.domain',
help=_("Hostname to be used by the Neutron server, agents and "
"services running on this machine. All the agents and "
"services running on this machine must use the same "
"host value.")),
cfg.BoolOpt('notify_nova_on_port_status_changes', default=True,
help=_("Send notification to nova when port status changes")),
cfg.BoolOpt('notify_nova_on_port_data_changes', default=True,
help=_("Send notification to nova when port data (fixed_ips/"
"floatingip) changes so nova can update its cache.")),
cfg.IntOpt('send_events_interval', default=2,
help=_('Number of seconds between sending events to nova if '
'there are any events to send.')),
cfg.BoolOpt('advertise_mtu', default=True,
deprecated_for_removal=True,
help=_('If True, advertise network MTU values if core plugin '
'calculates them. MTU is advertised to running '
'instances via DHCP and RA MTU options.')),
cfg.StrOpt('ipam_driver',
help=_("Neutron IPAM (IP address management) driver to use. "
"If ipam_driver is not set (default behavior), no IPAM "
"driver is used. In order to use the reference "
"implementation of Neutron IPAM driver, "
"use 'internal'.")),
cfg.BoolOpt('vlan_transparent', default=False,
help=_('If True, then allow plugins that support it to '
'create VLAN transparent networks.')),
cfg.StrOpt('web_framework', default='legacy',
choices=('legacy', 'pecan'),
help=_("This will choose the web framework in which to run "
"the Neutron API server. 'pecan' is a new experiemental "
"rewrite of the API server.")),
cfg.IntOpt('global_physnet_mtu', default=constants.DEFAULT_NETWORK_MTU,
deprecated_name='segment_mtu', deprecated_group='ml2',
help=_('MTU of the underlying physical network. Neutron uses '
'this value to calculate MTU for all virtual network '
'components. For flat and VLAN networks, neutron uses '
'this value without modification. For overlay networks '
'such as VXLAN, neutron automatically subtracts the '
'overlay protocol overhead from this value. Defaults '
'to 1500, the standard value for Ethernet. If you want '
'to propagate a change to infrastructure MTU into the '
'backend, you may need to resync agents that manage '
'ports, as well as re-attach VIFs to affected '
'instances.'))
]
core_cli_opts = [
cfg.StrOpt('state_path',
default='/var/lib/neutron',
help=_("Where to store Neutron state files. "
"This directory must be writable by the agent.")),
]
# Register the configuration options
cfg.CONF.register_opts(core_opts)
cfg.CONF.register_cli_opts(core_cli_opts)
wsgi.register_opts(cfg.CONF)
common_config.register_core_common_config_opts()
# Ensure that the control exchange is set correctly
oslo_messaging.set_transport_defaults(control_exchange='neutron')
@ -223,18 +59,9 @@ NOVA_CONF_SECTION = 'nova'
ks_loading.register_auth_conf_options(cfg.CONF, NOVA_CONF_SECTION)
ks_loading.register_session_conf_options(cfg.CONF, NOVA_CONF_SECTION)
nova_opts = [
cfg.StrOpt('region_name',
help=_('Name of nova region to use. Useful if keystone manages'
' more than one region.')),
cfg.StrOpt('endpoint_type',
default='public',
choices=['public', 'admin', 'internal'],
help=_('Type of the nova endpoint to use. This endpoint will'
' be looked up in the keystone catalog and should be'
' one of public, internal or admin.')),
]
cfg.CONF.register_opts(nova_opts, group=NOVA_CONF_SECTION)
# Register the nova configuration options
common_config.register_nova_opts()
logging.register_options(cfg.CONF)

205
neutron/conf/common.py Normal file
View File

@ -0,0 +1,205 @@
# Copyright 2011 VMware, Inc.
# 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 oslo_service import wsgi
from neutron._i18n import _
from neutron import api
from neutron.common import constants
from neutron.common import utils
core_opts = [
cfg.StrOpt('bind_host', default='0.0.0.0',
help=_("The host IP to bind to")),
cfg.PortOpt('bind_port', default=9696,
help=_("The port to bind to")),
cfg.StrOpt('api_extensions_path', default="",
help=_("The path for API extensions. "
"Note that this can be a colon-separated list of paths. "
"For example: api_extensions_path = "
"extensions:/path/to/more/exts:/even/more/exts. "
"The __path__ of neutron.extensions is appended to "
"this, so if your extensions are in there you don't "
"need to specify them here.")),
cfg.StrOpt('auth_strategy', default='keystone',
help=_("The type of authentication to use")),
cfg.StrOpt('core_plugin',
help=_("The core plugin Neutron will use")),
cfg.ListOpt('service_plugins', default=[],
help=_("The service plugins Neutron will use")),
cfg.StrOpt('base_mac', default="fa:16:3e:00:00:00",
help=_("The base MAC address Neutron will use for VIFs. "
"The first 3 octets will remain unchanged. If the 4th "
"octet is not 00, it will also be used. The others "
"will be randomly generated.")),
cfg.IntOpt('mac_generation_retries', default=16,
deprecated_for_removal=True,
help=_("How many times Neutron will retry MAC generation. This "
"option is now obsolete and so is deprecated to be "
"removed in the Ocata release.")),
cfg.BoolOpt('allow_bulk', default=True,
help=_("Allow the usage of the bulk API")),
cfg.BoolOpt('allow_pagination', default=api.DEFAULT_ALLOW_PAGINATION,
help=_("Allow the usage of the pagination")),
cfg.BoolOpt('allow_sorting', default=api.DEFAULT_ALLOW_SORTING,
help=_("Allow the usage of the sorting")),
cfg.StrOpt('pagination_max_limit', default="-1",
help=_("The maximum number of items returned in a single "
"response, value was 'infinite' or negative integer "
"means no limit")),
cfg.ListOpt('default_availability_zones', default=[],
help=_("Default value of availability zone hints. The "
"availability zone aware schedulers use this when "
"the resources availability_zone_hints is empty. "
"Multiple availability zones can be specified by a "
"comma separated string. This value can be empty. "
"In this case, even if availability_zone_hints for "
"a resource is empty, availability zone is "
"considered for high availability while scheduling "
"the resource.")),
cfg.IntOpt('max_dns_nameservers', default=5,
help=_("Maximum number of DNS nameservers per subnet")),
cfg.IntOpt('max_subnet_host_routes', default=20,
help=_("Maximum number of host routes per subnet")),
cfg.IntOpt('max_fixed_ips_per_port', default=5,
deprecated_for_removal=True,
help=_("Maximum number of fixed ips per port. This option "
"is deprecated and will be removed in the N "
"release.")),
cfg.StrOpt('default_ipv4_subnet_pool', deprecated_for_removal=True,
help=_("Default IPv4 subnet pool to be used for automatic "
"subnet CIDR allocation. "
"Specifies by UUID the pool to be used in case where "
"creation of a subnet is being called without a "
"subnet pool ID. If not set then no pool "
"will be used unless passed explicitly to the subnet "
"create. If no pool is used, then a CIDR must be passed "
"to create a subnet and that subnet will not be "
"allocated from any pool; it will be considered part of "
"the tenant's private address space. This option is "
"deprecated for removal in the N release.")),
cfg.StrOpt('default_ipv6_subnet_pool', deprecated_for_removal=True,
help=_("Default IPv6 subnet pool to be used for automatic "
"subnet CIDR allocation. "
"Specifies by UUID the pool to be used in case where "
"creation of a subnet is being called without a "
"subnet pool ID. See the description for "
"default_ipv4_subnet_pool for more information. This "
"option is deprecated for removal in the N release.")),
cfg.BoolOpt('ipv6_pd_enabled', default=False,
help=_("Enables IPv6 Prefix Delegation for automatic subnet "
"CIDR allocation. "
"Set to True to enable IPv6 Prefix Delegation for "
"subnet allocation in a PD-capable environment. Users "
"making subnet creation requests for IPv6 subnets "
"without providing a CIDR or subnetpool ID will be "
"given a CIDR via the Prefix Delegation mechanism. "
"Note that enabling PD will override the behavior of "
"the default IPv6 subnetpool.")),
cfg.IntOpt('dhcp_lease_duration', default=86400,
deprecated_name='dhcp_lease_time',
help=_("DHCP lease duration (in seconds). Use -1 to tell "
"dnsmasq to use infinite lease times.")),
cfg.StrOpt('dns_domain',
default='openstacklocal',
help=_('Domain to use for building the hostnames')),
cfg.StrOpt('external_dns_driver',
help=_('Driver for external DNS integration.')),
cfg.BoolOpt('dhcp_agent_notification', default=True,
help=_("Allow sending resource operation"
" notification to DHCP agent")),
cfg.BoolOpt('allow_overlapping_ips', default=False,
help=_("Allow overlapping IP support in Neutron. "
"Attention: the following parameter MUST be set to "
"False if Neutron is being used in conjunction with "
"Nova security groups.")),
cfg.StrOpt('host', default=utils.get_hostname(),
sample_default='example.domain',
help=_("Hostname to be used by the Neutron server, agents and "
"services running on this machine. All the agents and "
"services running on this machine must use the same "
"host value.")),
cfg.BoolOpt('notify_nova_on_port_status_changes', default=True,
help=_("Send notification to nova when port status changes")),
cfg.BoolOpt('notify_nova_on_port_data_changes', default=True,
help=_("Send notification to nova when port data (fixed_ips/"
"floatingip) changes so nova can update its cache.")),
cfg.IntOpt('send_events_interval', default=2,
help=_('Number of seconds between sending events to nova if '
'there are any events to send.')),
cfg.BoolOpt('advertise_mtu', default=True,
deprecated_for_removal=True,
help=_('If True, advertise network MTU values if core plugin '
'calculates them. MTU is advertised to running '
'instances via DHCP and RA MTU options.')),
cfg.StrOpt('ipam_driver',
help=_("Neutron IPAM (IP address management) driver to use. "
"If ipam_driver is not set (default behavior), no IPAM "
"driver is used. In order to use the reference "
"implementation of Neutron IPAM driver, "
"use 'internal'.")),
cfg.BoolOpt('vlan_transparent', default=False,
help=_('If True, then allow plugins that support it to '
'create VLAN transparent networks.')),
cfg.StrOpt('web_framework', default='legacy',
choices=('legacy', 'pecan'),
help=_("This will choose the web framework in which to run "
"the Neutron API server. 'pecan' is a new experiemental "
"rewrite of the API server.")),
cfg.IntOpt('global_physnet_mtu', default=constants.DEFAULT_NETWORK_MTU,
deprecated_name='segment_mtu', deprecated_group='ml2',
help=_('MTU of the underlying physical network. Neutron uses '
'this value to calculate MTU for all virtual network '
'components. For flat and VLAN networks, neutron uses '
'this value without modification. For overlay networks '
'such as VXLAN, neutron automatically subtracts the '
'overlay protocol overhead from this value. Defaults '
'to 1500, the standard value for Ethernet.'))
]
core_cli_opts = [
cfg.StrOpt('state_path',
default='/var/lib/neutron',
help=_("Where to store Neutron state files. "
"This directory must be writable by the agent.")),
]
def register_core_common_config_opts(cfg=cfg.CONF):
cfg.register_opts(core_opts)
cfg.register_cli_opts(core_cli_opts)
wsgi.register_opts(cfg)
NOVA_CONF_SECTION = 'nova'
nova_opts = [
cfg.StrOpt('region_name',
help=_('Name of nova region to use. Useful if keystone manages'
' more than one region.')),
cfg.StrOpt('endpoint_type',
default='public',
choices=['public', 'admin', 'internal'],
help=_('Type of the nova endpoint to use. This endpoint will'
' be looked up in the keystone catalog and should be'
' one of public, internal or admin.')),
]
def register_nova_opts(cfg=cfg.CONF):
cfg.register_opts(nova_opts, group=NOVA_CONF_SECTION)

View File

@ -31,6 +31,7 @@ import neutron.agent.securitygroups_rpc
import neutron.common.cache_utils
import neutron.conf.agent.dhcp
import neutron.conf.agent.l3.config
import neutron.conf.common
import neutron.conf.quota
import neutron.conf.service
import neutron.db.agents_db
@ -130,14 +131,14 @@ def list_opts():
return [
('DEFAULT',
itertools.chain(
neutron.common.config.core_cli_opts,
neutron.common.config.core_opts,
neutron.conf.common.core_cli_opts,
neutron.conf.common.core_opts,
neutron.wsgi.socket_opts,
neutron.conf.service.service_opts)
),
(neutron.common.config.NOVA_CONF_SECTION,
(neutron.conf.common.NOVA_CONF_SECTION,
itertools.chain(
neutron.common.config.nova_opts)
neutron.conf.common.nova_opts)
),
('quotas', neutron.conf.quota.core_quota_opts)
]

View File

@ -25,8 +25,8 @@ from neutron.pecan_wsgi import hooks
from neutron.pecan_wsgi import startup
CONF = cfg.CONF
CONF.import_opt('bind_host', 'neutron.common.config')
CONF.import_opt('bind_port', 'neutron.common.config')
CONF.import_opt('bind_host', 'neutron.conf.common')
CONF.import_opt('bind_port', 'neutron.conf.common')
def setup_app(*args, **kwargs):

View File

@ -52,7 +52,7 @@ from neutron.tests import tools
CONF = cfg.CONF
CONF.import_opt('state_path', 'neutron.common.config')
CONF.import_opt('state_path', 'neutron.conf.common')
ROOTDIR = os.path.dirname(__file__)
ETCDIR = os.path.join(ROOTDIR, 'etc')

View File

@ -27,8 +27,8 @@ from neutron.agent.common import ovs_lib
from neutron.agent.l2 import l2_agent_extensions_manager as ext_manager
from neutron.agent.linux import interface
from neutron.agent.linux import polling
from neutron.common import config as common_config
from neutron.common import utils
from neutron.conf import common as common_config
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers.openvswitch.agent.common import config \
as ovs_config

View File

@ -29,9 +29,9 @@ from neutron.agent.l3 import agent as neutron_l3_agent
from neutron.agent import l3_agent as l3_agent_main
from neutron.agent.linux import external_process
from neutron.agent.linux import ip_lib
from neutron.common import config as common_config
from neutron.common import constants as n_const
from neutron.common import utils as common_utils
from neutron.conf import common as common_config
from neutron.tests.common import l3_test_common
from neutron.tests.common import net_helpers
from neutron.tests.functional import base

View File

@ -19,9 +19,9 @@ from neutron.agent.common import config
from neutron.agent.linux import dhcp
from neutron.agent.linux import interface
from neutron.agent.linux import ip_lib
from neutron.common import config as common_conf
from neutron.common import utils as common_utils
from neutron.conf.agent import dhcp as dhcp_conf
from neutron.conf import common as common_conf
from neutron.tests import base as tests_base
from neutron.tests.common import net_helpers
from neutron.tests.functional import base as functional_base

View File

@ -35,7 +35,7 @@ from neutron.db.migration import cli as migration
from neutron.db.migration.models import head as head_models
from neutron.tests.unit import testlib_api
cfg.CONF.import_opt('core_plugin', 'neutron.common.config')
cfg.CONF.import_opt('core_plugin', 'neutron.conf.common')
CORE_PLUGIN = 'neutron.plugins.ml2.plugin.Ml2Plugin'

View File

@ -47,10 +47,10 @@ from neutron.agent.linux import pd
from neutron.agent.linux import ra
from neutron.agent.metadata import driver as metadata_driver
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.conf import common as base_config
from neutron.extensions import portbindings
from neutron.plugins.common import constants as p_const
from neutron.tests import base

View File

@ -27,10 +27,10 @@ from neutron.agent.l3 import router_info
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 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.conf import common as base_config
from neutron.extensions import portbindings
from neutron.tests import base
from neutron.tests.common import l3_test_common

View File

@ -23,10 +23,10 @@ from oslo_config import cfg
from neutron.agent.common import config
from neutron.agent.linux import dhcp
from neutron.agent.linux import external_process
from neutron.common import config as base_config
from neutron.common import constants as n_const
from neutron.common import utils
from neutron.conf.agent import dhcp as dhcp_config
from neutron.conf import common as base_config
from neutron.extensions import extra_dhcp_opt as edo_ext
from neutron.tests import base
from neutron.tests import tools

View File

@ -28,7 +28,7 @@ from neutron.tests import base
CONF = cfg.CONF
CONF.import_opt('state_path', 'neutron.common.config')
CONF.import_opt('state_path', 'neutron.conf.common')
class RPCFixture(fixtures.Fixture):