diff --git a/neutron/conf/services/__init__.py b/neutron/conf/services/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/neutron/conf/services/extdns_designate_driver.py b/neutron/conf/services/extdns_designate_driver.py new file mode 100644 index 00000000000..ddb151795d8 --- /dev/null +++ b/neutron/conf/services/extdns_designate_driver.py @@ -0,0 +1,64 @@ +# Copyright (c) 2016 IBM +# 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 _ + +designate_opts = [ + cfg.StrOpt('url', + help=_('URL for connecting to designate')), + cfg.StrOpt('admin_username', + help=_('Username for connecting to designate in admin ' + 'context')), + cfg.StrOpt('admin_password', + help=_('Password for connecting to designate in admin ' + 'context'), + secret=True), + cfg.StrOpt('admin_tenant_id', + help=_('Tenant id for connecting to designate in admin ' + 'context')), + cfg.StrOpt('admin_tenant_name', + help=_('Tenant name for connecting to designate in admin ' + 'context')), + cfg.StrOpt('admin_auth_url', + help=_('Authorization URL for connecting to designate in admin ' + 'context')), + cfg.BoolOpt('insecure', default=False, + help=_('Skip cert validation for SSL based admin_auth_url')), + cfg.StrOpt('ca_cert', + help=_('CA certificate file to use to verify ' + 'connecting clients')), + cfg.BoolOpt('allow_reverse_dns_lookup', default=True, + help=_('Allow the creation of PTR records')), + cfg.IntOpt('ipv4_ptr_zone_prefix_size', default=24, + help=_('Number of bits in an ipv4 PTR zone that will be considered ' + 'network prefix. It has to align to byte boundary. Minimum ' + 'value is 8. Maximum value is 24. As a consequence, range ' + 'of values is 8, 16 and 24')), + cfg.IntOpt('ipv6_ptr_zone_prefix_size', default=120, + help=_('Number of bits in an ipv6 PTR zone that will be considered ' + 'network prefix. It has to align to nyble boundary. Minimum ' + 'value is 4. Maximum value is 124. As a consequence, range ' + 'of values is 4, 8, 12, 16,..., 124')), + cfg.StrOpt('ptr_zone_email', default='', + help=_('The email address to be used when creating PTR zones. ' + 'If not specified, the email address will be ' + 'admin@')), +] + + +def register_designate_opts(cfg=cfg.CONF): + cfg.register_opts(designate_opts, 'designate') diff --git a/neutron/conf/services/metering_agent.py b/neutron/conf/services/metering_agent.py new file mode 100644 index 00000000000..20506b7c7eb --- /dev/null +++ b/neutron/conf/services/metering_agent.py @@ -0,0 +1,32 @@ +# Copyright (C) 2013 eNovance SAS +# +# 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 _ + +metering_agent_opts = [ + cfg.StrOpt('driver', + default='neutron.services.metering.drivers.noop.' + 'noop_driver.NoopMeteringDriver', + help=_("Metering driver")), + cfg.IntOpt('measure_interval', default=30, + help=_("Interval between two metering measures")), + cfg.IntOpt('report_interval', default=300, + help=_("Interval between two metering reports")), +] + + +def register_metering_agent_opts(cfg=cfg.CONF): + cfg.register_opts(metering_agent_opts) diff --git a/neutron/conf/services/provider_configuration.py b/neutron/conf/services/provider_configuration.py new file mode 100644 index 00000000000..cc532ce150a --- /dev/null +++ b/neutron/conf/services/provider_configuration.py @@ -0,0 +1,29 @@ +# Copyright 2013 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 _ + +serviceprovider_opts = [ + cfg.MultiStrOpt('service_provider', default=[], + help=_('Defines providers for advanced services ' + 'using the format: ' + '::[:default]')) +] + + +def register_service_provider_opts(cfg=cfg.CONF): + cfg.register_opts(serviceprovider_opts, 'service_providers') diff --git a/neutron/conf/services/qos_driver_manager.py b/neutron/conf/services/qos_driver_manager.py new file mode 100644 index 00000000000..57ea1f5f4f5 --- /dev/null +++ b/neutron/conf/services/qos_driver_manager.py @@ -0,0 +1,24 @@ +# 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 _ + +QOS_PLUGIN_OPTS = [ + cfg.ListOpt('notification_drivers', + default=['message_queue'], + help=_('Drivers list to use to send the update notification')), +] + + +def register_qos_plugin_opts(cfg=cfg.CONF): + cfg.register_opts(QOS_PLUGIN_OPTS, "qos") diff --git a/neutron/opts.py b/neutron/opts.py index fe645e0404d..afb2d82d649 100644 --- a/neutron/opts.py +++ b/neutron/opts.py @@ -35,6 +35,8 @@ import neutron.conf.common import neutron.conf.plugins.ml2.drivers.linuxbridge import neutron.conf.quota import neutron.conf.service +import neutron.conf.services.metering_agent +import neutron.conf.services.qos_driver_manager import neutron.conf.wsgi import neutron.db.agents_db import neutron.db.agentschedulers_db @@ -59,8 +61,6 @@ import neutron.plugins.ml2.drivers.type_geneve import neutron.plugins.ml2.drivers.type_gre import neutron.plugins.ml2.drivers.type_vlan import neutron.plugins.ml2.drivers.type_vxlan -import neutron.services.metering.agents.metering_agent -import neutron.services.qos.notification_drivers.manager import neutron.wsgi @@ -148,7 +148,7 @@ def list_opts(): def list_qos_opts(): return [ ('qos', - neutron.services.qos.notification_drivers.manager.QOS_PLUGIN_OPTS) + neutron.conf.services.qos_driver_manager.QOS_PLUGIN_OPTS) ] @@ -233,8 +233,7 @@ def list_metering_agent_opts(): return [ ('DEFAULT', itertools.chain( - neutron.services.metering.agents.metering_agent.MeteringAgent. - Opts, + neutron.conf.services.metering_agent.metering_agent_opts, neutron.agent.common.config.INTERFACE_DRIVER_OPTS) ) ] diff --git a/neutron/services/externaldns/drivers/designate/driver.py b/neutron/services/externaldns/drivers/designate/driver.py index cf15c48db79..698b036f9f4 100644 --- a/neutron/services/externaldns/drivers/designate/driver.py +++ b/neutron/services/externaldns/drivers/designate/driver.py @@ -23,7 +23,7 @@ from keystoneauth1 import token_endpoint from neutron_lib import constants from oslo_config import cfg -from neutron._i18n import _ +from neutron.conf.services import extdns_designate_driver from neutron.extensions import dns from neutron.services.externaldns import driver @@ -34,52 +34,8 @@ IPV6_PTR_ZONE_PREFIX_MAX_SIZE = 124 _SESSION = None -designate_opts = [ - cfg.StrOpt('url', - help=_('URL for connecting to designate')), - cfg.StrOpt('admin_username', - help=_('Username for connecting to designate in admin ' - 'context')), - cfg.StrOpt('admin_password', - help=_('Password for connecting to designate in admin ' - 'context'), - secret=True), - cfg.StrOpt('admin_tenant_id', - help=_('Tenant id for connecting to designate in admin ' - 'context')), - cfg.StrOpt('admin_tenant_name', - help=_('Tenant name for connecting to designate in admin ' - 'context')), - cfg.StrOpt('admin_auth_url', - help=_('Authorization URL for connecting to designate in admin ' - 'context')), - cfg.BoolOpt('insecure', default=False, - help=_('Skip cert validation for SSL based admin_auth_url')), - cfg.StrOpt('ca_cert', - help=_('CA certificate file to use to verify ' - 'connecting clients')), - cfg.BoolOpt('allow_reverse_dns_lookup', default=True, - help=_('Allow the creation of PTR records')), - cfg.IntOpt('ipv4_ptr_zone_prefix_size', default=24, - help=_('Number of bits in an ipv4 PTR zone that will be considered ' - 'network prefix. It has to align to byte boundary. Minimum ' - 'value is 8. Maximum value is 24. As a consequence, range ' - 'of values is 8, 16 and 24')), - cfg.IntOpt('ipv6_ptr_zone_prefix_size', default=120, - help=_('Number of bits in an ipv6 PTR zone that will be considered ' - 'network prefix. It has to align to nyble boundary. Minimum ' - 'value is 4. Maximum value is 124. As a consequence, range ' - 'of values is 4, 8, 12, 16,..., 124')), - cfg.StrOpt('ptr_zone_email', default='', - help=_('The email address to be used when creating PTR zones. ' - 'If not specified, the email address will be ' - 'admin@')), -] - -DESIGNATE_GROUP = 'designate' - CONF = cfg.CONF -CONF.register_opts(designate_opts, DESIGNATE_GROUP) +extdns_designate_driver.register_designate_opts() def get_clients(context): diff --git a/neutron/services/metering/agents/metering_agent.py b/neutron/services/metering/agents/metering_agent.py index 57f622b4245..4d0f49ac9aa 100644 --- a/neutron/services/metering/agents/metering_agent.py +++ b/neutron/services/metering/agents/metering_agent.py @@ -32,6 +32,7 @@ from neutron.common import constants as n_const from neutron.common import rpc as n_rpc from neutron.common import topics from neutron.common import utils +from neutron.conf.services import metering_agent from neutron import context from neutron import manager from neutron import service as neutron_service @@ -63,17 +64,6 @@ class MeteringPluginRpc(object): class MeteringAgent(MeteringPluginRpc, manager.Manager): - Opts = [ - cfg.StrOpt('driver', - default='neutron.services.metering.drivers.noop.' - 'noop_driver.NoopMeteringDriver', - help=_("Metering driver")), - cfg.IntOpt('measure_interval', default=30, - help=_("Interval between two metering measures")), - cfg.IntOpt('report_interval', default=300, - help=_("Interval between two metering reports")), - ] - def __init__(self, host, conf=None): self.conf = conf or cfg.CONF self._load_drivers() @@ -290,7 +280,7 @@ class MeteringAgentWithStateReport(MeteringAgent): def main(): conf = cfg.CONF - conf.register_opts(MeteringAgent.Opts) + metering_agent.register_metering_agent_opts() config.register_agent_state_opts_helper(conf) common_config.init(sys.argv[1:]) config.setup_logging() diff --git a/neutron/services/provider_configuration.py b/neutron/services/provider_configuration.py index 7b387148557..1b37fe5fe2e 100644 --- a/neutron/services/provider_configuration.py +++ b/neutron/services/provider_configuration.py @@ -13,10 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. +import debtcollector import importlib import itertools import os +from neutron.conf.services import provider_configuration as prov_config from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import log as logging @@ -29,14 +31,12 @@ LOG = logging.getLogger(__name__) SERVICE_PROVIDERS = 'neutron.service_providers' -serviceprovider_opts = [ - cfg.MultiStrOpt('service_provider', default=[], - help=_('Defines providers for advanced services ' - 'using the format: ' - '::[:default]')) -] +debtcollector.deprecate( + 'Moved serviceprovider_opts to %s' % prov_config.__name__, + version="newton", removal_version="ocata") +serviceprovider_opts = prov_config.serviceprovider_opts -cfg.CONF.register_opts(serviceprovider_opts, 'service_providers') +prov_config.register_service_provider_opts() class NeutronModule(object): @@ -66,7 +66,7 @@ class NeutronModule(object): def ini(self, neutron_dir=None): if self.repo['ini'] is None: ini_file = cfg.ConfigOpts() - ini_file.register_opts(serviceprovider_opts, 'service_providers') + prov_config.register_service_provider_opts(ini_file) if neutron_dir is not None: neutron_dirs = [neutron_dir] diff --git a/neutron/services/qos/notification_drivers/manager.py b/neutron/services/qos/notification_drivers/manager.py index b25f91150fa..7328791e953 100644 --- a/neutron/services/qos/notification_drivers/manager.py +++ b/neutron/services/qos/notification_drivers/manager.py @@ -12,17 +12,12 @@ from oslo_config import cfg from oslo_log import log as logging +from neutron.conf.services import qos_driver_manager as qos_mgr from neutron._i18n import _, _LI from neutron import manager QOS_DRIVER_NAMESPACE = 'neutron.qos.notification_drivers' -QOS_PLUGIN_OPTS = [ - cfg.ListOpt('notification_drivers', - default=['message_queue'], - help=_('Drivers list to use to send the update notification')), -] - -cfg.CONF.register_opts(QOS_PLUGIN_OPTS, "qos") +qos_mgr.register_qos_plugin_opts() LOG = logging.getLogger(__name__) diff --git a/neutron/tests/unit/services/metering/agents/test_metering_agent.py b/neutron/tests/unit/services/metering/agents/test_metering_agent.py index 5463857ac76..365c29cb9ad 100644 --- a/neutron/tests/unit/services/metering/agents/test_metering_agent.py +++ b/neutron/tests/unit/services/metering/agents/test_metering_agent.py @@ -18,6 +18,7 @@ from oslo_utils import fixture as utils_fixture from oslo_utils import timeutils from oslo_utils import uuidutils +from neutron.conf.services import metering_agent as metering_agent_config from neutron.services.metering.agents import metering_agent from neutron.tests import base from neutron.tests import fake_notifier @@ -49,7 +50,7 @@ class TestMeteringOperations(base.BaseTestCase): def setUp(self): super(TestMeteringOperations, self).setUp() - cfg.CONF.register_opts(metering_agent.MeteringAgent.Opts) + metering_agent_config.register_metering_agent_opts() self.noop_driver = ('neutron.services.metering.drivers.noop.' 'noop_driver.NoopMeteringDriver') @@ -228,7 +229,7 @@ class TestMeteringOperations(base.BaseTestCase): class TestMeteringDriver(base.BaseTestCase): def setUp(self): super(TestMeteringDriver, self).setUp() - cfg.CONF.register_opts(metering_agent.MeteringAgent.Opts) + metering_agent_config.register_metering_agent_opts() self.noop_driver = ('neutron.services.metering.drivers.noop.' 'noop_driver.NoopMeteringDriver') diff --git a/neutron/tests/unit/services/qos/notification_drivers/test_manager.py b/neutron/tests/unit/services/qos/notification_drivers/test_manager.py index bb5d836b379..d3ac31950da 100644 --- a/neutron/tests/unit/services/qos/notification_drivers/test_manager.py +++ b/neutron/tests/unit/services/qos/notification_drivers/test_manager.py @@ -15,6 +15,7 @@ from oslo_config import cfg from oslo_utils import uuidutils from neutron.api.rpc.callbacks import events +from neutron.conf.services import qos_driver_manager as driver_mgr_config from neutron import context from neutron.objects.qos import policy as policy_object from neutron.services.qos.notification_drivers import manager as driver_mgr @@ -39,7 +40,7 @@ class TestQosDriversManagerBase(base.BaseQosTestCase): self.config_parse() self.setup_coreplugin() config = cfg.ConfigOpts() - config.register_opts(driver_mgr.QOS_PLUGIN_OPTS, "qos") + driver_mgr_config.register_qos_plugin_opts(config) self.policy_data = {'policy': { 'id': uuidutils.generate_uuid(), 'tenant_id': uuidutils.generate_uuid(),