From cc0431ba6265b50bdc35c2157df32f44cfe3bef8 Mon Sep 17 00:00:00 2001 From: Erik Olof Gunnar Andersson Date: Wed, 1 Nov 2023 15:58:43 -0700 Subject: [PATCH] Standardize all configuration loading There was a large config refactor many releases ago, but we never standardized on the new pattern. This will also help ensure that config is always loaded in the right order. - Standardize how config is setup throughout designate. - Removed unecessary import_opt. Change-Id: I8913d2569f174208740a76c474c73316f6c1d89e --- designate/api/admin/__init__.py | 7 ++-- designate/api/admin/app.py | 7 ++-- designate/api/admin/controllers/root.py | 5 +-- designate/api/admin/views/base.py | 8 ++--- designate/api/middleware.py | 9 ++--- designate/api/service.py | 8 +++-- designate/api/v2/__init__.py | 6 ++-- designate/api/v2/app.py | 7 ++-- designate/api/v2/controllers/limits.py | 4 +-- designate/api/v2/controllers/quotas.py | 6 ++-- designate/api/v2/controllers/root.py | 7 ++-- .../api/v2/controllers/zones/__init__.py | 5 ++- designate/api/versions.py | 9 ++--- designate/api/wsgi.py | 7 ++-- designate/backend/base.py | 5 +-- designate/backend/impl_dynect.py | 5 +-- designate/backend/impl_infoblox/connector.py | 5 +-- designate/backend/impl_ns1.py | 5 +-- designate/backend/impl_pdns4.py | 5 +-- designate/central/rpcapi.py | 7 ++-- designate/central/service.py | 34 ++++++++++--------- designate/cmd/api.py | 4 +-- designate/cmd/central.py | 1 - designate/cmd/mdns.py | 1 - designate/cmd/producer.py | 4 +-- designate/cmd/sink.py | 1 - designate/cmd/worker.py | 4 +-- designate/common/keystone.py | 5 ++- designate/manage/database.py | 4 +-- designate/manage/pool.py | 8 ++--- designate/manage/tlds.py | 5 +-- designate/mdns/handler.py | 7 ++-- designate/mdns/service.py | 13 +++---- designate/network_api/base.py | 6 ++-- designate/network_api/neutron.py | 5 +-- designate/notification_handler/base.py | 8 +++-- designate/notification_handler/fake.py | 10 +++--- designate/notification_handler/neutron.py | 9 ++--- designate/notification_handler/nova.py | 9 ++--- designate/notifications.py | 8 ++--- designate/objects/adapters/api_v2/base.py | 5 +-- designate/objects/recordset.py | 7 ++-- designate/plugin.py | 6 ++-- designate/policy.py | 5 +-- designate/producer/service.py | 8 ++--- designate/producer/tasks.py | 9 ++--- designate/quota/__init__.py | 5 +-- designate/quota/base.py | 16 +++++---- designate/rpc.py | 6 ++-- designate/scheduler/base.py | 7 ++-- .../scheduler/filters/default_pool_filter.py | 8 +++-- .../scheduler/filters/fallback_filter.py | 13 +++---- .../filters/in_doubt_default_pool_filter.py | 13 +++---- designate/sink/service.py | 12 ++++--- designate/storage/sql.py | 9 +++-- .../alembic/versions/c9f427f7180a_liberty.py | 4 +-- designate/storage/sqlalchemy/tables.py | 4 +-- designate/tests/__init__.py | 11 +----- designate/tests/fixtures.py | 5 +-- .../test_admin/extensions/test_quotas.py | 11 +++--- .../test_admin/extensions/test_reports.py | 5 --- designate/tests/test_api/test_middleware.py | 7 ++-- .../test_api/test_v2/test_import_export.py | 5 --- .../tests/test_api/test_v2/test_limits.py | 18 +++++----- .../tests/test_api/test_v2/test_pools.py | 6 ++-- .../tests/test_api/test_v2/test_zones.py | 13 ++++--- designate/tests/test_central/test_service.py | 33 +++++++++--------- designate/tests/test_dnsmiddleware.py | 4 +-- designate/tests/test_dnsutils.py | 4 +-- designate/tests/test_mdns/test_handler.py | 7 ++-- designate/tests/test_quota/test_quota.py | 21 ++++++------ designate/tests/test_storage/test_storage.py | 6 ++-- designate/tests/unit/api/test_version.py | 4 +-- designate/tests/unit/api/test_wsgi.py | 4 +-- designate/tests/unit/central/test_central.py | 4 +-- designate/tests/unit/cmd/test_cmd.py | 6 ++-- designate/tests/unit/cmd/test_manage.py | 5 +-- designate/tests/unit/mdns/test_handler.py | 5 +-- designate/tests/unit/mdns/test_service.py | 5 +-- designate/tests/unit/network_api/test_base.py | 20 ++++++----- .../tests/unit/network_api/test_neutron.py | 5 +-- .../unit/notification_handler/test_fake.py | 5 +-- .../unit/objects/test_adapters_v2_api.py | 5 +-- .../tests/unit/objects/test_recordset.py | 6 ++-- designate/tests/unit/producer/test_service.py | 5 +-- designate/tests/unit/producer/test_tasks.py | 3 +- .../tests/unit/scheduler/test_permutations.py | 11 +++--- .../tests/unit/sink/test_notifications.py | 5 ++- .../impl_sqlalchemy/test_sqlalchemy.py | 8 ++--- .../tests/unit/test_central/test_basic.py | 14 ++++---- designate/tests/unit/test_dnsmiddleware.py | 5 +-- designate/tests/unit/test_dnsutils.py | 5 +-- .../tests/unit/test_heartbeat_emitter.py | 7 ++-- designate/tests/unit/test_service.py | 5 +-- designate/tests/unit/test_utils.py | 5 +-- .../tests/unit/workers/test_base_task.py | 4 +-- designate/tests/unit/workers/test_notify.py | 5 +-- .../tests/unit/workers/test_processing.py | 4 +-- designate/tests/unit/workers/test_service.py | 5 +-- .../tests/unit/workers/test_task_config.py | 3 +- designate/tests/unit/workers/test_xfr.py | 5 +-- .../tests/unit/workers/test_zone_tasks.py | 7 ++-- designate/utils.py | 28 ++++++++------- designate/worker/processing.py | 5 +-- designate/worker/rpcapi.py | 6 ++-- designate/worker/service.py | 8 ++--- designate/worker/tasks/base.py | 6 ++-- designate/worker/tasks/zone.py | 5 +-- 108 files changed, 434 insertions(+), 370 deletions(-) diff --git a/designate/api/admin/__init__.py b/designate/api/admin/__init__.py index 7688db711..60d61f092 100644 --- a/designate/api/admin/__init__.py +++ b/designate/api/admin/__init__.py @@ -12,15 +12,18 @@ # 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_log import log as logging import pecan.deploy +import designate.conf + + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) def factory(global_config, **local_conf): - if not cfg.CONF['service:api'].enable_api_admin: + if not CONF['service:api'].enable_api_admin: def disabled_app(environ, start_response): status = '404 Not Found' start_response(status, []) diff --git a/designate/api/admin/app.py b/designate/api/admin/app.py index d3013f42e..5ba6a7a59 100644 --- a/designate/api/admin/app.py +++ b/designate/api/admin/app.py @@ -13,17 +13,20 @@ # 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 import pecan import pecan.deploy from designate.api.v2 import patches +import designate.conf + + +CONF = designate.conf.CONF def setup_app(pecan_config): config = dict(pecan_config) - config['app']['debug'] = cfg.CONF['service:api'].pecan_debug + config['app']['debug'] = CONF['service:api'].pecan_debug pecan.configuration.set_config(config, overwrite=True) diff --git a/designate/api/admin/controllers/root.py b/designate/api/admin/controllers/root.py index 652227ac8..03a7b73f9 100644 --- a/designate/api/admin/controllers/root.py +++ b/designate/api/admin/controllers/root.py @@ -12,13 +12,14 @@ # 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_log import log as logging from stevedore import named from designate.api.v2.controllers import errors +import designate.conf +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -29,7 +30,7 @@ class RootController: """ def __init__(self): - enabled_ext = cfg.CONF['service:api'].enabled_extensions_admin + enabled_ext = CONF['service:api'].enabled_extensions_admin if len(enabled_ext) > 0: self._mgr = named.NamedExtensionManager( namespace='designate.api.admin.extensions', diff --git a/designate/api/admin/views/base.py b/designate/api/admin/views/base.py index 132cae71b..36d584ad5 100644 --- a/designate/api/admin/views/base.py +++ b/designate/api/admin/views/base.py @@ -15,15 +15,15 @@ # under the License. from urllib import parse -from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import exceptions from designate import objects +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF class BaseView: @@ -141,12 +141,12 @@ class BaseView: # parents) # defined in etc/designate/designate.conf.sample - limit = cfg.CONF['service:api'].default_limit_admin + limit = CONF['service:api'].default_limit_admin if 'limit' in params: limit = params['limit'] if limit.lower() == 'max': - limit = cfg.CONF['service:api'].max_limit_admin + limit = CONF['service:api'].max_limit_admin else: try: limit = int(limit) diff --git a/designate/api/middleware.py b/designate/api/middleware.py index 2d9302321..2cbcd5c85 100644 --- a/designate/api/middleware.py +++ b/designate/api/middleware.py @@ -14,7 +14,6 @@ # License for the specific language governing permissions and limitations # under the License. import flask -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from oslo_middleware import base @@ -23,6 +22,7 @@ from oslo_serialization import jsonutils from oslo_utils import strutils import webob.dec +import designate.conf from designate import context from designate import exceptions from designate import notifications @@ -30,6 +30,7 @@ from designate import objects from designate.objects.adapters import DesignateAdapter +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -39,7 +40,7 @@ def auth_pipeline_factory(loader, global_conf, **local_conf): Code nabbed from cinder. """ - pipeline = local_conf[cfg.CONF['service:api'].auth_strategy] + pipeline = local_conf[CONF['service:api'].auth_strategy] pipeline = pipeline.split() LOG.info('Getting auth pipeline: %s', pipeline[:-1]) filters = [loader.get_filter(n) for n in pipeline[:-1]] @@ -227,8 +228,8 @@ class MaintenanceMiddleware(base.Middleware): LOG.info('Starting designate maintenance middleware') - self.enabled = cfg.CONF['service:api'].maintenance_mode - self.role = cfg.CONF['service:api'].maintenance_mode_role + self.enabled = CONF['service:api'].maintenance_mode + self.role = CONF['service:api'].maintenance_mode_role def process_request(self, request): # If maintaince mode is not enabled, pass the request on as soon as diff --git a/designate/api/service.py b/designate/api/service.py index 7b9524d84..040788acf 100644 --- a/designate/api/service.py +++ b/designate/api/service.py @@ -13,14 +13,16 @@ # 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_log import log as logging from paste import deploy +import designate.conf from designate import exceptions from designate import service from designate import utils + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -29,7 +31,7 @@ class Service(service.WSGIService): super().__init__( self.wsgi_application, self.service_name, - cfg.CONF['service:api'].listen, + CONF['service:api'].listen, ) def start(self): @@ -44,7 +46,7 @@ class Service(service.WSGIService): @property def wsgi_application(self): - api_paste_config = cfg.CONF['service:api'].api_paste_config + api_paste_config = CONF['service:api'].api_paste_config config_paths = utils.find_config(api_paste_config) if not config_paths: diff --git a/designate/api/v2/__init__.py b/designate/api/v2/__init__.py index 49c7e232a..613592523 100644 --- a/designate/api/v2/__init__.py +++ b/designate/api/v2/__init__.py @@ -13,16 +13,18 @@ # 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_log import log as logging import pecan.deploy +import designate.conf + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) def factory(global_config, **local_conf): - if not cfg.CONF['service:api'].enable_api_v2: + if not CONF['service:api'].enable_api_v2: def disabled_app(environ, start_response): status = '404 Not Found' start_response(status, []) diff --git a/designate/api/v2/app.py b/designate/api/v2/app.py index 7d16c97f9..163fc6939 100644 --- a/designate/api/v2/app.py +++ b/designate/api/v2/app.py @@ -13,17 +13,20 @@ # 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 import pecan import pecan.deploy from designate.api.v2 import patches +import designate.conf + + +CONF = designate.conf.CONF def setup_app(pecan_config): config = dict(pecan_config) - config['app']['debug'] = cfg.CONF['service:api'].pecan_debug + config['app']['debug'] = CONF['service:api'].pecan_debug pecan.configuration.set_config(config, overwrite=True) diff --git a/designate/api/v2/controllers/limits.py b/designate/api/v2/controllers/limits.py index 936ab8192..5dcce4b96 100644 --- a/designate/api/v2/controllers/limits.py +++ b/designate/api/v2/controllers/limits.py @@ -13,13 +13,13 @@ # 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 import pecan from designate.api.v2.controllers import rest +import designate.conf -CONF = cfg.CONF +CONF = designate.conf.CONF class LimitsController(rest.RestController): diff --git a/designate/api/v2/controllers/quotas.py b/designate/api/v2/controllers/quotas.py index e4168c5ed..24ea7d2cf 100644 --- a/designate/api/v2/controllers/quotas.py +++ b/designate/api/v2/controllers/quotas.py @@ -13,16 +13,18 @@ # 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_log import log as logging import pecan from designate.api.v2.controllers import rest from designate.common import keystone +import designate.conf from designate import exceptions from designate.objects.adapters import DesignateAdapter from designate.objects import QuotaList + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -59,7 +61,7 @@ class QuotasController(rest.RestController): # on a best effort basis # this will raise only if KeystoneV3 endpoint is not found at all, # or the creds are passing but the project is not found - if cfg.CONF['service:api'].quotas_verify_project_id: + if CONF['service:api'].quotas_verify_project_id: keystone.verify_project_id(context, project_id) quotas = DesignateAdapter.parse('API_v2', body, QuotaList()) diff --git a/designate/api/v2/controllers/root.py b/designate/api/v2/controllers/root.py index bf04c0f50..3667b14a1 100644 --- a/designate/api/v2/controllers/root.py +++ b/designate/api/v2/controllers/root.py @@ -13,7 +13,6 @@ # 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 stevedore import named from designate.api.v2.controllers import blacklists @@ -27,6 +26,10 @@ from designate.api.v2.controllers import service_status from designate.api.v2.controllers import tlds from designate.api.v2.controllers import tsigkeys from designate.api.v2.controllers import zones +import designate.conf + + +CONF = designate.conf.CONF class RootController: @@ -36,7 +39,7 @@ class RootController: """ def __init__(self): - enabled_ext = cfg.CONF['service:api'].enabled_extensions_v2 + enabled_ext = CONF['service:api'].enabled_extensions_v2 if len(enabled_ext) > 0: self._mgr = named.NamedExtensionManager( namespace='designate.api.v2.extensions', diff --git a/designate/api/v2/controllers/zones/__init__.py b/designate/api/v2/controllers/zones/__init__.py index 06d905283..95f087ae5 100644 --- a/designate/api/v2/controllers/zones/__init__.py +++ b/designate/api/v2/controllers/zones/__init__.py @@ -13,7 +13,6 @@ # 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_log import log as logging import pecan @@ -22,14 +21,14 @@ from designate.api.v2.controllers.zones import nameservers from designate.api.v2.controllers.zones import recordsets from designate.api.v2.controllers.zones import sharedzones from designate.api.v2.controllers.zones import tasks +import designate.conf from designate import exceptions from designate import objects from designate.objects.adapters import DesignateAdapter from designate import utils -CONF = cfg.CONF - +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) diff --git a/designate/api/versions.py b/designate/api/versions.py index 24537e252..bd7baf997 100644 --- a/designate/api/versions.py +++ b/designate/api/versions.py @@ -14,11 +14,12 @@ # License for the specific language governing permissions and limitations # under the License. import flask -from oslo_config import cfg from designate.common import constants +import designate.conf -cfg.CONF.import_opt('enable_host_header', 'designate.api', group='service:api') + +CONF = designate.conf.CONF def _add_a_version(versions, version, api_url, status, timestamp): @@ -38,10 +39,10 @@ def factory(global_config, **local_conf): @app.route('/', methods=['GET']) def version_list(): - if cfg.CONF['service:api'].enable_host_header: + if CONF['service:api'].enable_host_header: url_root = flask.request.url_root else: - url_root = cfg.CONF['service:api'].api_base_uri + url_root = CONF['service:api'].api_base_uri api_url = url_root.rstrip('/') + '/v2' versions = [] diff --git a/designate/api/wsgi.py b/designate/api/wsgi.py index 6f7ec6cab..7c0d93256 100644 --- a/designate/api/wsgi.py +++ b/designate/api/wsgi.py @@ -19,12 +19,13 @@ from paste import deploy from designate.common import config from designate.common import profiler -from designate import conf +import designate.conf from designate import heartbeat_emitter from designate import policy from designate import rpc -CONF = conf.CONF + +CONF = designate.conf.CONF CONFIG_FILES = ['api-paste.ini', 'designate.conf'] @@ -41,7 +42,7 @@ def init_application(): logging.register_options(cfg.CONF) cfg.CONF([], project='designate', default_config_files=conf_files) config.set_defaults() - logging.setup(cfg.CONF, 'designate') + logging.setup(CONF, 'designate') policy.init() diff --git a/designate/backend/base.py b/designate/backend/base.py index a6cc746fb..1ac30d8b7 100644 --- a/designate/backend/base.py +++ b/designate/backend/base.py @@ -15,14 +15,15 @@ # under the License. import abc -from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate.context import DesignateContext from designate.plugin import DriverPlugin + LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF class Backend(DriverPlugin): diff --git a/designate/backend/impl_dynect.py b/designate/backend/impl_dynect.py index d8ab3ad27..e30dbfd5a 100755 --- a/designate/backend/impl_dynect.py +++ b/designate/backend/impl_dynect.py @@ -16,18 +16,19 @@ import time from eventlet import Timeout -from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils import requests from requests.adapters import HTTPAdapter from designate.backend import base +import designate.conf from designate import exceptions from designate import utils + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF CFG_GROUP_NAME = 'backend:dynect' diff --git a/designate/backend/impl_infoblox/connector.py b/designate/backend/impl_infoblox/connector.py index 1a625af9d..05620a5ce 100644 --- a/designate/backend/impl_infoblox/connector.py +++ b/designate/backend/impl_infoblox/connector.py @@ -14,16 +14,17 @@ # under the License. from urllib import parse -from oslo_config import cfg from oslo_log import log from oslo_serialization import jsonutils from oslo_utils import strutils import requests from designate.backend.impl_infoblox import ibexceptions as exc +import designate.conf + CFG_GROUP_NAME = 'backend:infoblox' -CONF = cfg.CONF +CONF = designate.conf.CONF LOG = log.getLogger(__name__) diff --git a/designate/backend/impl_ns1.py b/designate/backend/impl_ns1.py index 1bd5ae63a..ce7f71191 100644 --- a/designate/backend/impl_ns1.py +++ b/designate/backend/impl_ns1.py @@ -13,15 +13,16 @@ # 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_log import log as logging import requests from designate.backend import base +import designate.conf from designate import exceptions + LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF class NS1Backend(base.Backend): diff --git a/designate/backend/impl_pdns4.py b/designate/backend/impl_pdns4.py index ae80df8ba..b8457b1cf 100644 --- a/designate/backend/impl_pdns4.py +++ b/designate/backend/impl_pdns4.py @@ -15,15 +15,16 @@ import ipaddress import os.path import urllib -from oslo_config import cfg from oslo_log import log as logging import requests from designate.backend import base +import designate.conf from designate import exceptions + LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF class PDNS4Backend(base.Backend): diff --git a/designate/central/rpcapi.py b/designate/central/rpcapi.py index f7070ac74..1e88f4685 100644 --- a/designate/central/rpcapi.py +++ b/designate/central/rpcapi.py @@ -13,15 +13,16 @@ # 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_log import log as logging import oslo_messaging as messaging from designate.common import profiler +import designate.conf from designate.loggingutils import rpc_logging from designate import rpc + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) CENTRAL_API = None @@ -80,7 +81,7 @@ class CentralAPI: LOGGING_BLACKLIST = ['update_service_status'] def __init__(self, topic=None): - self.topic = topic if topic else cfg.CONF['service:central'].topic + self.topic = topic if topic else CONF['service:central'].topic target = messaging.Target(topic=self.topic, version=self.RPC_API_VERSION) diff --git a/designate/central/service.py b/designate/central/service.py index 586bc2683..c663a17ae 100644 --- a/designate/central/service.py +++ b/designate/central/service.py @@ -24,7 +24,6 @@ import time from dns import exception as dnsexception from dns import zone as dnszone -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from oslo_utils import timeutils @@ -33,6 +32,7 @@ from designate.common import constants from designate.common.decorators import lock from designate.common.decorators import notification from designate.common.decorators import rpc +import designate.conf from designate import coordination from designate import dnsutils from designate import exceptions @@ -48,6 +48,8 @@ from designate.storage import transaction_shallow_copy from designate import utils from designate.worker import rpcapi as worker_rpcapi + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -65,13 +67,13 @@ class Service(service.RPCService): self._quota = None super().__init__( - self.service_name, cfg.CONF['service:central'].topic, - threads=cfg.CONF['service:central'].threads, + self.service_name, CONF['service:central'].topic, + threads=CONF['service:central'].threads, ) self.coordination = coordination.Coordination( self.service_name, self.tg, grouping_enabled=False ) - self.network_api = network_api.get_network_api(cfg.CONF.network_api) + self.network_api = network_api.get_network_api(CONF.network_api) @property def scheduler(self): @@ -98,7 +100,7 @@ class Service(service.RPCService): return 'central' def start(self): - if (cfg.CONF['service:central'].managed_resource_tenant_id == + if (CONF['service:central'].managed_resource_tenant_id == "00000000-0000-0000-0000-000000000000"): LOG.warning("Managed Resource Tenant ID is not properly " "configured") @@ -119,7 +121,7 @@ class Service(service.RPCService): if zone_name is None: raise exceptions.InvalidObject - if len(zone_name) > cfg.CONF['service:central'].max_zone_name_len: + if len(zone_name) > CONF['service:central'].max_zone_name_len: raise exceptions.InvalidZoneName('Name too long') # Break the zone name up into its component labels @@ -172,7 +174,7 @@ class Service(service.RPCService): raise ValueError('Please supply a FQDN') # Validate record name length - max_len = cfg.CONF['service:central'].max_recordset_name_len + max_len = CONF['service:central'].max_recordset_name_len if len(recordset_name) > max_len: raise exceptions.InvalidRecordSetName('Name too long') @@ -336,7 +338,7 @@ class Service(service.RPCService): def _is_valid_ttl(self, context, ttl): if ttl is None: return - min_ttl = cfg.CONF['service:central'].min_ttl + min_ttl = CONF['service:central'].min_ttl if min_ttl is not None and ttl < int(min_ttl): try: policy.check('use_low_ttl', context) @@ -705,11 +707,11 @@ class Service(service.RPCService): maximum val: default_soa_refresh_min minimum val: default_soa_refresh_max """ - assert cfg.CONF.default_soa_refresh_min is not None - assert cfg.CONF.default_soa_refresh_max is not None - dispersion = (cfg.CONF.default_soa_refresh_max - - cfg.CONF.default_soa_refresh_min) * random.random() - refresh_time = cfg.CONF.default_soa_refresh_min + dispersion + assert CONF.default_soa_refresh_min is not None + assert CONF.default_soa_refresh_max is not None + dispersion = (CONF.default_soa_refresh_max - + CONF.default_soa_refresh_min) * random.random() + refresh_time = CONF.default_soa_refresh_min + dispersion return int(refresh_time) def _get_pool_ns_records(self, context, pool_id): @@ -901,7 +903,7 @@ class Service(service.RPCService): def get_zone_ns_records(self, context, zone_id=None, criterion=None): if zone_id is None: policy.check('get_zone_ns_records', context) - pool_id = cfg.CONF['service:central'].default_pool_id + pool_id = CONF['service:central'].default_pool_id else: zone = self.storage.get_zone(context, zone_id) @@ -1988,8 +1990,8 @@ class Service(service.RPCService): zone_values = { 'type': 'PRIMARY', 'name': zone_name, - 'email': cfg.CONF['service:central'].managed_resource_email, - 'tenant_id': cfg.CONF['service:central'].managed_resource_tenant_id + 'email': CONF['service:central'].managed_resource_email, + 'tenant_id': CONF['service:central'].managed_resource_tenant_id } try: zone = self.create_zone( diff --git a/designate/cmd/api.py b/designate/cmd/api.py index 1508fb59a..d2caa41b2 100644 --- a/designate/cmd/api.py +++ b/designate/cmd/api.py @@ -15,7 +15,6 @@ # under the License. import sys -from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr @@ -28,8 +27,7 @@ from designate import version CONF = designate.conf.CONF -CONF.import_opt('workers', 'designate.api', group='service:api') -cfg.CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token') +CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token') def main(): diff --git a/designate/cmd/central.py b/designate/cmd/central.py index b7062c4d4..28fde84e7 100644 --- a/designate/cmd/central.py +++ b/designate/cmd/central.py @@ -27,7 +27,6 @@ from designate import version CONF = designate.conf.CONF -CONF.import_opt('workers', 'designate.central', group='service:central') def main(): diff --git a/designate/cmd/mdns.py b/designate/cmd/mdns.py index 582359476..f7d0fe41d 100644 --- a/designate/cmd/mdns.py +++ b/designate/cmd/mdns.py @@ -27,7 +27,6 @@ from designate import version CONF = designate.conf.CONF -CONF.import_opt('workers', 'designate.mdns', group='service:mdns') def main(): diff --git a/designate/cmd/producer.py b/designate/cmd/producer.py index c15149334..dd01aafd5 100644 --- a/designate/cmd/producer.py +++ b/designate/cmd/producer.py @@ -25,9 +25,9 @@ from designate import service from designate import utils from designate import version -LOG = logging.getLogger(__name__) + CONF = designate.conf.CONF -CONF.import_opt('workers', 'designate.producer', group='service:producer') +LOG = logging.getLogger(__name__) def main(): diff --git a/designate/cmd/sink.py b/designate/cmd/sink.py index bb0884b95..b6e6347ac 100644 --- a/designate/cmd/sink.py +++ b/designate/cmd/sink.py @@ -27,7 +27,6 @@ from designate import version CONF = designate.conf.CONF -CONF.import_opt('workers', 'designate.sink', group='service:sink') def main(): diff --git a/designate/cmd/worker.py b/designate/cmd/worker.py index b322cb965..226c3580a 100644 --- a/designate/cmd/worker.py +++ b/designate/cmd/worker.py @@ -25,9 +25,9 @@ from designate import utils from designate import version from designate.worker import service as worker_service -LOG = logging.getLogger(__name__) + CONF = designate.conf.CONF -CONF.import_opt('workers', 'designate.worker', group='service:worker') +LOG = logging.getLogger(__name__) def main(): diff --git a/designate/common/keystone.py b/designate/common/keystone.py index 8681879df..838b204f2 100644 --- a/designate/common/keystone.py +++ b/designate/common/keystone.py @@ -10,17 +10,16 @@ # 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 keystoneauth1 import exceptions as kse from keystoneauth1 import loading as ksa_loading -from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import exceptions from designate.i18n import _ -CONF = cfg.CONF +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) diff --git a/designate/manage/database.py b/designate/manage/database.py index 314644219..31262a4e3 100644 --- a/designate/manage/database.py +++ b/designate/manage/database.py @@ -19,12 +19,12 @@ import sys from alembic import command as alembic_command from alembic.config import Config -from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate.manage import base -CONF = cfg.CONF +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) diff --git a/designate/manage/pool.py b/designate/manage/pool.py index 5a107609a..66eb24013 100644 --- a/designate/manage/pool.py +++ b/designate/manage/pool.py @@ -13,8 +13,6 @@ # 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_log import log as logging import oslo_messaging as messaging import stevedore.exception @@ -22,6 +20,7 @@ import yaml from designate.backend import base as backend_base from designate.central import rpcapi as central_rpcapi +import designate.conf from designate import exceptions from designate.manage import base from designate import objects @@ -30,8 +29,9 @@ from designate import policy from designate import rpc from designate import utils + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF class PoolCommands(base.Commands): @@ -44,7 +44,7 @@ class PoolCommands(base.Commands): def _setup(self, dry_run=False, skip_verify_drivers=False): self.dry_run = dry_run self.skip_verify_drivers = skip_verify_drivers - rpc.init(cfg.CONF) + rpc.init(CONF) self.central_api = central_rpcapi.CentralAPI() @base.args('--file', help='The path to the file the yaml output should be ' diff --git a/designate/manage/tlds.py b/designate/manage/tlds.py index f3fc6aa47..4d6da6a5e 100644 --- a/designate/manage/tlds.py +++ b/designate/manage/tlds.py @@ -15,17 +15,18 @@ import csv import os -from oslo_config import cfg from oslo_log import log as logging from designate.central import rpcapi as central_rpcapi from designate.common import constants +import designate.conf from designate import exceptions from designate.manage import base from designate import objects from designate import rpc +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -59,7 +60,7 @@ class TLDCommands(base.Commands): super().__init__() def _startup(self): - rpc.init(cfg.CONF) + rpc.init(CONF) self.central_api = central_rpcapi.CentralAPI() # The dictionary function __str__() does not list the fields in any diff --git a/designate/mdns/handler.py b/designate/mdns/handler.py index 07672a8ff..b51c4e52c 100644 --- a/designate/mdns/handler.py +++ b/designate/mdns/handler.py @@ -22,18 +22,15 @@ import dns.rdatatype import dns.renderer import dns.resolver import dns.rrset -from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import exceptions from designate.worker import rpcapi as worker_api +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF - -CONF.import_opt('default_pool_id', 'designate.central', - group='service:central') # 10 Bytes of RR metadata, 64 bytes of TSIG RR data, variable length TSIG Key # name (restricted in designate to 160 chars), 1 byte for trailing dot. diff --git a/designate/mdns/service.py b/designate/mdns/service.py index e1e68065d..c51bc4af8 100644 --- a/designate/mdns/service.py +++ b/designate/mdns/service.py @@ -13,9 +13,9 @@ # 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_log import log as logging +import designate.conf from designate.conf.mdns import DEFAULT_MDNS_PORT from designate import dnsmiddleware from designate import dnsutils @@ -24,8 +24,9 @@ from designate import service from designate import storage from designate import utils + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF class Service(service.Service): @@ -35,13 +36,13 @@ class Service(service.Service): self._storage = None super().__init__( - self.service_name, threads=cfg.CONF['service:mdns'].threads, + self.service_name, threads=CONF['service:mdns'].threads, ) self.dns_service = service.DNSService( self.dns_application, self.tg, - cfg.CONF['service:mdns'].listen, - cfg.CONF['service:mdns'].tcp_backlog, - cfg.CONF['service:mdns'].tcp_recv_timeout, + CONF['service:mdns'].listen, + CONF['service:mdns'].tcp_backlog, + CONF['service:mdns'].tcp_recv_timeout, ) def start(self): diff --git a/designate/network_api/base.py b/designate/network_api/base.py index 7746bb147..86dca49dc 100644 --- a/designate/network_api/base.py +++ b/designate/network_api/base.py @@ -14,12 +14,14 @@ # License for the specific language governing permissions and limitations # under the License. import eventlet.patcher -from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import exceptions from designate.plugin import DriverPlugin + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) # NOTE(kiall): This is a workaround for bug #1424621, a broken reimplementation # of eventlet's 0.17.0 monkey patching of dnspython. @@ -110,7 +112,7 @@ class NetworkAPI(DriverPlugin): """ if not config_section: return None - cfg_group = cfg.CONF[config_section] + cfg_group = CONF[config_section] return cfg_group.endpoints def list_floatingips(self, context, region=None): diff --git a/designate/network_api/neutron.py b/designate/network_api/neutron.py index 5f22da133..4b5169ec2 100644 --- a/designate/network_api/neutron.py +++ b/designate/network_api/neutron.py @@ -20,14 +20,15 @@ from keystoneauth1 import session from keystoneauth1 import token_endpoint import openstack from openstack import exceptions as sdk_exceptions -from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import exceptions from designate.network_api import base from designate import version -CONF = cfg.CONF + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) diff --git a/designate/notification_handler/base.py b/designate/notification_handler/base.py index 73b8dc553..2ce00b00f 100644 --- a/designate/notification_handler/base.py +++ b/designate/notification_handler/base.py @@ -16,15 +16,17 @@ # under the License. import abc -from oslo_config import cfg from oslo_log import log as logging import re from designate.central import rpcapi as central_rpcapi +import designate.conf from designate.context import DesignateContext from designate.plugin import ExtensionPlugin + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -88,13 +90,13 @@ class BaseAddressHandler(NotificationHandler): def _get_formatv4(self): return ( - cfg.CONF[self.name].get('formatv4') or + CONF[self.name].get('formatv4') or self.default_formatv4 ) def _get_formatv6(self): return ( - cfg.CONF[self.name].get('formatv6') or + CONF[self.name].get('formatv6') or self.default_formatv6 ) diff --git a/designate/notification_handler/fake.py b/designate/notification_handler/fake.py index 6dd7e7509..b7c26a42d 100644 --- a/designate/notification_handler/fake.py +++ b/designate/notification_handler/fake.py @@ -9,11 +9,13 @@ # 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_log import log as logging +import designate.conf from designate.notification_handler import base + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -21,12 +23,12 @@ class FakeHandler(base.NotificationHandler): __plugin_name__ = 'fake' def get_exchange_topics(self): - exchange = cfg.CONF[self.name].control_exchange - topics = cfg.CONF[self.name].notification_topics + exchange = CONF[self.name].control_exchange + topics = CONF[self.name].notification_topics return exchange, topics def get_event_types(self): - return cfg.CONF[self.name].allowed_event_types + return CONF[self.name].allowed_event_types def process_notification(self, context, event_type, payload): LOG.info('%s: received notification - %s', diff --git a/designate/notification_handler/neutron.py b/designate/notification_handler/neutron.py index 4b512f6de..6722ce888 100644 --- a/designate/notification_handler/neutron.py +++ b/designate/notification_handler/neutron.py @@ -13,12 +13,13 @@ # 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_log import log as logging +import designate.conf from designate.notification_handler import base +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -27,9 +28,9 @@ class NeutronFloatingHandler(base.BaseAddressHandler): __plugin_name__ = 'neutron_floatingip' def get_exchange_topics(self): - exchange = cfg.CONF[self.name].control_exchange + exchange = CONF[self.name].control_exchange - topics = [topic for topic in cfg.CONF[self.name].notification_topics] + topics = [topic for topic in CONF[self.name].notification_topics] return (exchange, topics) @@ -43,7 +44,7 @@ class NeutronFloatingHandler(base.BaseAddressHandler): LOG.debug('%s received notification - %s', self.get_canonical_name(), event_type) - zone_id = cfg.CONF[self.name].zone_id + zone_id = CONF[self.name].zone_id if not zone_id: LOG.error('NeutronFloatingHandler: zone_id is None, ' diff --git a/designate/notification_handler/nova.py b/designate/notification_handler/nova.py index d60d364f6..bf8f0bed7 100644 --- a/designate/notification_handler/nova.py +++ b/designate/notification_handler/nova.py @@ -13,12 +13,13 @@ # 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_log import log as logging +import designate.conf from designate.notification_handler.base import BaseAddressHandler +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -27,9 +28,9 @@ class NovaFixedHandler(BaseAddressHandler): __plugin_name__ = 'nova_fixed' def get_exchange_topics(self): - exchange = cfg.CONF[self.name].control_exchange + exchange = CONF[self.name].control_exchange - topics = [topic for topic in cfg.CONF[self.name].notification_topics] + topics = [topic for topic in CONF[self.name].notification_topics] return (exchange, topics) @@ -47,7 +48,7 @@ class NovaFixedHandler(BaseAddressHandler): def process_notification(self, context, event_type, payload): LOG.debug('NovaFixedHandler received notification - %s', event_type) - zone_id = cfg.CONF[self.name].zone_id + zone_id = CONF[self.name].zone_id if not zone_id: LOG.error('NovaFixedHandler: zone_id is None, ignore the event.') diff --git a/designate/notifications.py b/designate/notifications.py index 03e4bc5c7..a7395510d 100644 --- a/designate/notifications.py +++ b/designate/notifications.py @@ -17,7 +17,6 @@ # Copied: nova.notifications import abc -from oslo_config import cfg from oslo_log import log as logging import designate.conf @@ -25,8 +24,9 @@ from designate import objects from designate.plugin import DriverPlugin from designate import rpc -LOG = logging.getLogger(__name__) + CONF = designate.conf.CONF +LOG = logging.getLogger(__name__) NOTIFICATION_PLUGIN = None @@ -42,8 +42,8 @@ def send_api_fault(context, url, status, exception): def init_notification_plugin(): - LOG.debug("Loading notification plugin: %s", cfg.CONF.notification_plugin) - cls = NotificationPlugin.get_driver(cfg.CONF.notification_plugin) + LOG.debug("Loading notification plugin: %s", CONF.notification_plugin) + cls = NotificationPlugin.get_driver(CONF.notification_plugin) global NOTIFICATION_PLUGIN NOTIFICATION_PLUGIN = cls() diff --git a/designate/objects/adapters/api_v2/base.py b/designate/objects/adapters/api_v2/base.py index 62502db45..1e6ba871b 100644 --- a/designate/objects/adapters/api_v2/base.py +++ b/designate/objects/adapters/api_v2/base.py @@ -11,14 +11,15 @@ # 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 urllib import parse +import designate.conf from designate import exceptions from designate.objects.adapters import base from designate.objects import base as ovoobj_base -CONF = cfg.CONF + +CONF = designate.conf.CONF class APIv2Adapter(base.DesignateAdapter): diff --git a/designate/objects/recordset.py b/designate/objects/recordset.py index 808ac9bdc..88767adcf 100755 --- a/designate/objects/recordset.py +++ b/designate/objects/recordset.py @@ -15,10 +15,10 @@ from copy import deepcopy -from oslo_config import cfg from oslo_log import log from oslo_versionedobjects import exception as ovo_exc +import designate.conf from designate import exceptions from designate.objects import base from designate.objects import fields @@ -27,10 +27,9 @@ from designate.objects.validation_error import ValidationErrorList from designate import utils +CONF = designate.conf.CONF LOG = log.getLogger(__name__) -cfg.CONF.import_opt('supported_record_type', 'designate') - @base.DesignateRegistry.register class RecordSet(base.DesignateObject, base.DictObjectMixin, @@ -125,7 +124,7 @@ class RecordSet(base.DesignateObject, base.DictObjectMixin, % {'type': self.type}) self._validate_fail(errors, err_msg) - if self.type not in cfg.CONF.supported_record_type: + if self.type not in CONF.supported_record_type: err_msg = ("'%(type)s' is not a supported record type" % {'type': self.type}) self._validate_fail(errors, err_msg) diff --git a/designate/plugin.py b/designate/plugin.py index 015ec8566..b54bc9d44 100644 --- a/designate/plugin.py +++ b/designate/plugin.py @@ -15,13 +15,15 @@ # under the License. import abc -from oslo_config import cfg from oslo_log import log as logging from stevedore import driver from stevedore import enabled +import designate.conf + + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF class Plugin(metaclass=abc.ABCMeta): diff --git a/designate/policy.py b/designate/policy.py index 9b4d14635..aefebe8f8 100644 --- a/designate/policy.py +++ b/designate/policy.py @@ -19,10 +19,11 @@ from oslo_policy import opts from oslo_policy import policy from designate.common import policies +import designate.conf from designate import exceptions -CONF = cfg.CONF +CONF = designate.conf.CONF # Add the default policy opts # TODO(gmann): Remove setting the default value of config policy_file @@ -45,7 +46,7 @@ def reset(): def set_rules(data, default_rule=None, overwrite=True): - default_rule = default_rule or cfg.CONF.policy_default_rule + default_rule = default_rule or CONF.policy_default_rule if not _ENFORCER: LOG.debug("Enforcer not present, recreating at rules stage.") init() diff --git a/designate/producer/service.py b/designate/producer/service.py index 4beab5f5a..bed10c15d 100644 --- a/designate/producer/service.py +++ b/designate/producer/service.py @@ -13,19 +13,19 @@ # 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_log import log as logging import oslo_messaging as messaging from designate.central import rpcapi +import designate.conf from designate import coordination from designate import exceptions from designate.producer import tasks from designate import service +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF NS = 'designate.periodic_tasks' @@ -42,8 +42,8 @@ class Service(service.RPCService): self._quota = None super().__init__( - self.service_name, cfg.CONF['service:producer'].topic, - threads=cfg.CONF['service:producer'].threads, + self.service_name, CONF['service:producer'].topic, + threads=CONF['service:producer'].threads, ) self.coordination = coordination.Coordination( diff --git a/designate/producer/tasks.py b/designate/producer/tasks.py index bed4e3c62..93099f8ba 100644 --- a/designate/producer/tasks.py +++ b/designate/producer/tasks.py @@ -15,18 +15,19 @@ # under the License. import datetime +from oslo_log import log as logging +from oslo_utils import timeutils + from designate.central import rpcapi +import designate.conf from designate import context from designate import plugin from designate import rpc from designate.worker import rpcapi as worker_rpcapi -from oslo_config import cfg -from oslo_log import log as logging -from oslo_utils import timeutils +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF class PeriodicTask(plugin.ExtensionPlugin): diff --git a/designate/quota/__init__.py b/designate/quota/__init__.py index a2e182196..c4ea75a00 100644 --- a/designate/quota/__init__.py +++ b/designate/quota/__init__.py @@ -13,17 +13,18 @@ # 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_log import log as logging +import designate.conf from designate.quota import base +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) def get_quota(): - quota_driver = cfg.CONF.quota_driver + quota_driver = CONF.quota_driver LOG.debug("Loading quota driver: %s", quota_driver) diff --git a/designate/quota/base.py b/designate/quota/base.py index a4cacb7ba..d0f10d714 100644 --- a/designate/quota/base.py +++ b/designate/quota/base.py @@ -15,12 +15,14 @@ # under the License. import abc -from oslo_config import cfg - +import designate.conf from designate import exceptions from designate.plugin import DriverPlugin +CONF = designate.conf.CONF + + class Quota(DriverPlugin, metaclass=abc.ABCMeta): """Base class for quota plugins""" __plugin_ns__ = 'designate.quota' @@ -61,11 +63,11 @@ class Quota(DriverPlugin, metaclass=abc.ABCMeta): def get_default_quotas(self, context): return { - 'zones': cfg.CONF.quota_zones, - 'zone_recordsets': cfg.CONF.quota_zone_recordsets, - 'zone_records': cfg.CONF.quota_zone_records, - 'recordset_records': cfg.CONF.quota_recordset_records, - 'api_export_size': cfg.CONF.quota_api_export_size, + 'zones': CONF.quota_zones, + 'zone_recordsets': CONF.quota_zone_recordsets, + 'zone_records': CONF.quota_zone_records, + 'recordset_records': CONF.quota_recordset_records, + 'api_export_size': CONF.quota_api_export_size, } def get_quota(self, context, tenant_id, resource): diff --git a/designate/rpc.py b/designate/rpc.py index 1b8fd9299..b7cde6023 100644 --- a/designate/rpc.py +++ b/designate/rpc.py @@ -11,17 +11,17 @@ # 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 import oslo_messaging as messaging from oslo_messaging.rpc import dispatcher as rpc_dispatcher from oslo_serialization import jsonutils from oslo_utils import importutils +import designate.conf import designate.context import designate.exceptions from designate import objects + profiler = importutils.try_import('osprofiler.profiler') __all__ = [ @@ -37,7 +37,7 @@ __all__ = [ 'get_notifier', ] -CONF = cfg.CONF +CONF = designate.conf.CONF NOTIFICATION_TRANSPORT = None NOTIFIER = None TRANSPORT = None diff --git a/designate/scheduler/base.py b/designate/scheduler/base.py index 5db35973c..0b9bace09 100644 --- a/designate/scheduler/base.py +++ b/designate/scheduler/base.py @@ -11,13 +11,14 @@ # 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_log import log as logging from stevedore import named +import designate.conf from designate import exceptions + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -31,7 +32,7 @@ class Scheduler: """The list of filters enabled on this scheduler""" def __init__(self, storage): - enabled_filters = cfg.CONF['service:central'].scheduler_filters + enabled_filters = CONF['service:central'].scheduler_filters self.filters = list() self.storage = storage diff --git a/designate/scheduler/filters/default_pool_filter.py b/designate/scheduler/filters/default_pool_filter.py index 2faff54a1..8b7ab7646 100644 --- a/designate/scheduler/filters/default_pool_filter.py +++ b/designate/scheduler/filters/default_pool_filter.py @@ -11,12 +11,14 @@ # 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 - +import designate.conf from designate import objects from designate.scheduler.filters import base +CONF = designate.conf.CONF + + class DefaultPoolFilter(base.Filter): """This filter will always return the default pool specified in the designate config file @@ -36,5 +38,5 @@ class DefaultPoolFilter(base.Filter): def filter(self, context, pools, zone): pools = objects.PoolList() pools.append( - objects.Pool(id=cfg.CONF['service:central'].default_pool_id)) + objects.Pool(id=CONF['service:central'].default_pool_id)) return pools diff --git a/designate/scheduler/filters/fallback_filter.py b/designate/scheduler/filters/fallback_filter.py index 18a6a73be..ce352cc90 100644 --- a/designate/scheduler/filters/fallback_filter.py +++ b/designate/scheduler/filters/fallback_filter.py @@ -11,17 +11,12 @@ # 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 - +import designate.conf from designate import objects from designate.scheduler.filters import base -cfg.CONF.register_opts([ - cfg.StrOpt('default_pool_id', - default='794ccc2c-d751-44fe-b57f-8894c9f5c842', - help="The name of the default pool"), -], group='service:central') + +CONF = designate.conf.CONF class FallbackFilter(base.Filter): @@ -43,6 +38,6 @@ class FallbackFilter(base.Filter): if not pools: pools = objects.PoolList() pools.append( - objects.Pool(id=cfg.CONF['service:central'].default_pool_id) + objects.Pool(id=CONF['service:central'].default_pool_id) ) return pools diff --git a/designate/scheduler/filters/in_doubt_default_pool_filter.py b/designate/scheduler/filters/in_doubt_default_pool_filter.py index b9cc11b50..45f5c18de 100644 --- a/designate/scheduler/filters/in_doubt_default_pool_filter.py +++ b/designate/scheduler/filters/in_doubt_default_pool_filter.py @@ -11,17 +11,12 @@ # 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 - +import designate.conf from designate import objects from designate.scheduler.filters import base -cfg.CONF.register_opts([ - cfg.StrOpt('default_pool_id', - default='794ccc2c-d751-44fe-b57f-8894c9f5c842', - help="The name of the default pool"), -], group='service:central') + +CONF = designate.conf.CONF class InDoubtDefaultPoolFilter(base.Filter): @@ -46,7 +41,7 @@ class InDoubtDefaultPoolFilter(base.Filter): def filter(self, context, pools, zone): if len(pools) > 1: - default_pool_id = cfg.CONF['service:central'].default_pool_id + default_pool_id = CONF['service:central'].default_pool_id try: default_pool = self.storage.get_pool(context, default_pool_id) except Exception: diff --git a/designate/sink/service.py b/designate/sink/service.py index dc86d2f04..fee17d775 100644 --- a/designate/sink/service.py +++ b/designate/sink/service.py @@ -14,22 +14,23 @@ # 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_log import log as logging import oslo_messaging as messaging +import designate.conf from designate import notification_handler from designate import rpc from designate import service +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) class Service(service.Service): def __init__(self): super().__init__( - self.service_name, threads=cfg.CONF['service:sink'].threads + self.service_name, threads=CONF['service:sink'].threads ) # Initialize extensions @@ -45,8 +46,9 @@ class Service(service.Service): def _init_extensions(): """Loads and prepares all enabled extensions""" - enabled_notification_handlers = cfg.CONF[ - 'service:sink'].enabled_notification_handlers + enabled_notification_handlers = ( + CONF['service:sink'].enabled_notification_handlers + ) notification_handlers = notification_handler.get_notification_handlers( enabled_notification_handlers) @@ -75,7 +77,7 @@ class Service(service.Service): if targets: self._server = rpc.get_notification_listener( targets, [self], - pool=cfg.CONF['service:sink'].listener_pool_name + pool=CONF['service:sink'].listener_pool_name ) self._server.start() diff --git a/designate/storage/sql.py b/designate/storage/sql.py index 15fb066e8..593e08abf 100644 --- a/designate/storage/sql.py +++ b/designate/storage/sql.py @@ -27,13 +27,16 @@ from oslo_utils import importutils from osprofiler import opts as profiler from sqlalchemy import inspect +import designate.conf + + osprofiler_sqlalchemy = importutils.try_import('osprofiler.sqlalchemy') +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF = cfg.CONF try: - CONF.import_group("profiler", "designate.service") + CONF.import_group('profiler', 'designate.service') except cfg.NoSuchGroupError: pass @@ -45,7 +48,7 @@ _MAIN_CONTEXT_MANAGER = None def initialize(): """Initialize the module.""" - connection = cfg.CONF['storage:sqlalchemy'].connection + connection = CONF['storage:sqlalchemy'].connection db_options.set_defaults( CONF, connection=connection ) diff --git a/designate/storage/sqlalchemy/alembic/versions/c9f427f7180a_liberty.py b/designate/storage/sqlalchemy/alembic/versions/c9f427f7180a_liberty.py index 0053f31f1..39724226c 100644 --- a/designate/storage/sqlalchemy/alembic/versions/c9f427f7180a_liberty.py +++ b/designate/storage/sqlalchemy/alembic/versions/c9f427f7180a_liberty.py @@ -21,10 +21,10 @@ Create Date: 2022-07-28 23:06:40.731452 """ from alembic import op -from oslo_config import cfg from oslo_utils import timeutils import sqlalchemy as sa +import designate.conf from designate.conf import central from designate.storage.sqlalchemy.alembic import legacy_utils from designate.storage.sqlalchemy.types import UUID @@ -37,7 +37,7 @@ depends_on = None # Equivalent to legacy sqlalchemy-migrate revision 070_liberty -CONF = cfg.CONF +CONF = designate.conf.CONF central.register_opts(CONF) ACTIONS = ('CREATE', 'DELETE', 'UPDATE', 'NONE') diff --git a/designate/storage/sqlalchemy/tables.py b/designate/storage/sqlalchemy/tables.py index aad568354..688aebdc6 100644 --- a/designate/storage/sqlalchemy/tables.py +++ b/designate/storage/sqlalchemy/tables.py @@ -17,15 +17,15 @@ from sqlalchemy import (Table, MetaData, Column, String, Text, Integer, SmallInteger, CHAR, DateTime, Enum, Boolean, Unicode, UniqueConstraint, ForeignKeyConstraint) -from oslo_config import cfg from oslo_db.sqlalchemy import types from oslo_utils import timeutils +import designate.conf from designate.storage.sqlalchemy.types import UUID from designate import utils -CONF = cfg.CONF +CONF = designate.conf.CONF RESOURCE_STATUSES = ['ACTIVE', 'PENDING', 'DELETED', 'ERROR'] RECORD_TYPES = ['A', 'AAAA', 'CNAME', 'MX', 'SRV', 'TXT', 'SPF', 'NS', 'PTR', diff --git a/designate/tests/__init__.py b/designate/tests/__init__.py index 42b5fcacd..bf103d64f 100644 --- a/designate/tests/__init__.py +++ b/designate/tests/__init__.py @@ -22,7 +22,6 @@ import time from unittest import mock import eventlet -from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_log import log as logging from oslo_messaging import conffixture as messaging_fixture @@ -45,14 +44,6 @@ eventlet.monkey_patch(os=False) CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CONF.import_opt('auth_strategy', 'designate.api', - group='service:api') -CONF.import_opt('connection', 'designate.storage.sqlalchemy', - group='storage:sqlalchemy') -CONF.import_opt('emitter_type', 'designate.heartbeat_emitter', - group="heartbeat_emitter") -CONF.import_opt('scheduler_filters', 'designate.scheduler', - group="service:central") default_pool_id = CONF['service:central'].default_pool_id _TRUE_VALUES = ('true', '1', 'yes', 'y') @@ -432,7 +423,7 @@ class TestCase(base.BaseTestCase): group = kwargs.pop('group', None) for k, v in kwargs.items(): - cfg.CONF.set_override(k, v, group) + CONF.set_override(k, v, group) def policy(self, rules, default_rule='allow', overwrite=True): # Inject an allow and deny rule diff --git a/designate/tests/fixtures.py b/designate/tests/fixtures.py index 3ad5b39aa..33891169a 100644 --- a/designate/tests/fixtures.py +++ b/designate/tests/fixtures.py @@ -28,11 +28,11 @@ import shutil import tempfile import fixtures -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import importutils import tooz.coordination +import designate.conf from designate.manage import database as db_commands from designate import network_api from designate.network_api import fake as fake_network_api @@ -44,6 +44,7 @@ import designate.utils """Test fixtures """ _TRUE_VALUES = ('True', 'true', '1', 'yes') +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -170,7 +171,7 @@ class DatabaseFixture(fixtures.Fixture): class NetworkAPIFixture(fixtures.Fixture): def setUp(self): super().setUp() - self.api = network_api.get_network_api(cfg.CONF.network_api) + self.api = network_api.get_network_api(CONF.network_api) self.fake = fake_network_api self.addCleanup(self.fake.reset_floatingips) diff --git a/designate/tests/test_api/test_admin/extensions/test_quotas.py b/designate/tests/test_api/test_admin/extensions/test_quotas.py index 7bd65d237..d3bd1725a 100644 --- a/designate/tests/test_api/test_admin/extensions/test_quotas.py +++ b/designate/tests/test_api/test_admin/extensions/test_quotas.py @@ -13,12 +13,11 @@ # 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 - +import designate.conf from designate.tests.test_api.test_admin import AdminApiTestCase -cfg.CONF.import_opt('enabled_extensions_admin', 'designate.api.admin', - group='service:api') + +CONF = designate.conf.CONF class AdminApiQuotasTest(AdminApiTestCase): @@ -46,8 +45,8 @@ class AdminApiQuotasTest(AdminApiTestCase): max_zones = response.json['quota']['zones'] max_zone_records = response.json['quota']['zone_records'] - self.assertEqual(cfg.CONF.quota_zones, max_zones) - self.assertEqual(cfg.CONF.quota_zone_records, max_zone_records) + self.assertEqual(CONF.quota_zones, max_zones) + self.assertEqual(CONF.quota_zone_records, max_zone_records) def test_patch_quotas(self): self.policy({'set_quotas': '@'}) diff --git a/designate/tests/test_api/test_admin/extensions/test_reports.py b/designate/tests/test_api/test_admin/extensions/test_reports.py index 797772036..198907391 100644 --- a/designate/tests/test_api/test_admin/extensions/test_reports.py +++ b/designate/tests/test_api/test_admin/extensions/test_reports.py @@ -13,13 +13,8 @@ # 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 designate.tests.test_api.test_admin import AdminApiTestCase -cfg.CONF.import_opt('enabled_extensions_admin', 'designate.api.admin', - group='service:api') - class AdminApiReportsTest(AdminApiTestCase): def setUp(self): diff --git a/designate/tests/test_api/test_middleware.py b/designate/tests/test_api/test_middleware.py index 4d6791d46..5de0612e5 100644 --- a/designate/tests/test_api/test_middleware.py +++ b/designate/tests/test_api/test_middleware.py @@ -16,17 +16,20 @@ # under the License. from unittest import mock -from oslo_config import cfg import oslo_messaging as messaging from oslo_messaging.notify import notifier from designate.api import middleware +import designate.conf from designate import context from designate import exceptions from designate import rpc import designate.tests +CONF = designate.conf.CONF + + class FakeRequest: def __init__(self): self.headers = {} @@ -289,7 +292,7 @@ class FaultMiddlewareTest(designate.tests.TestCase): @mock.patch.object(notifier.Notifier, 'error') def test_notify_of_fault(self, mock_notifier): self.config(notify_api_faults=True) - rpc.init(cfg.CONF) + rpc.init(CONF) app = middleware.FaultWrapperMiddleware({}) class RaisingRequest(FakeRequest): diff --git a/designate/tests/test_api/test_v2/test_import_export.py b/designate/tests/test_api/test_v2/test_import_export.py index 5af0b0700..a63cd87d3 100644 --- a/designate/tests/test_api/test_v2/test_import_export.py +++ b/designate/tests/test_api/test_v2/test_import_export.py @@ -14,7 +14,6 @@ import unittest from dns import zone as dnszone -from oslo_config import cfg from webtest import TestApp from designate.api import admin as admin_api @@ -22,10 +21,6 @@ from designate.api import middleware from designate.tests.test_api.test_v2 import ApiV2TestCase -cfg.CONF.import_opt('enabled_extensions_admin', 'designate.api.admin', - group='service:api') - - class APIV2ZoneImportExportTest(ApiV2TestCase): def setUp(self): super().setUp() diff --git a/designate/tests/test_api/test_v2/test_limits.py b/designate/tests/test_api/test_v2/test_limits.py index fc11f9bf0..d3949e4d2 100644 --- a/designate/tests/test_api/test_v2/test_limits.py +++ b/designate/tests/test_api/test_v2/test_limits.py @@ -13,11 +13,13 @@ # 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 - +import designate.conf from designate.tests.test_api.test_v2 import ApiV2TestCase +CONF = designate.conf.CONF + + class ApiV2LimitsTest(ApiV2TestCase): def test_get_limits(self): response = self.client.get('/limits/') @@ -41,14 +43,14 @@ class ApiV2LimitsTest(ApiV2TestCase): absolutelimits = response.json - self.assertEqual(cfg.CONF.quota_zones, absolutelimits['max_zones']) - self.assertEqual(cfg.CONF.quota_zone_records, + self.assertEqual(CONF.quota_zones, absolutelimits['max_zones']) + self.assertEqual(CONF.quota_zone_records, absolutelimits['max_zone_recordsets']) - self.assertEqual(cfg.CONF['service:central'].min_ttl, + self.assertEqual(CONF['service:central'].min_ttl, absolutelimits['min_ttl']) - self.assertEqual(cfg.CONF['service:central'].max_zone_name_len, + self.assertEqual(CONF['service:central'].max_zone_name_len, absolutelimits['max_zone_name_length']) - self.assertEqual(cfg.CONF['service:central'].max_recordset_name_len, + self.assertEqual(CONF['service:central'].max_recordset_name_len, absolutelimits['max_recordset_name_length']) - self.assertEqual(cfg.CONF['service:api'].max_limit_v2, + self.assertEqual(CONF['service:api'].max_limit_v2, absolutelimits['max_page_limit']) diff --git a/designate/tests/test_api/test_v2/test_pools.py b/designate/tests/test_api/test_v2/test_pools.py index c8acae4b5..1e4f89292 100644 --- a/designate/tests/test_api/test_v2/test_pools.py +++ b/designate/tests/test_api/test_v2/test_pools.py @@ -12,11 +12,13 @@ # 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_log import log as logging +import designate.conf from designate.tests.test_api.test_v2 import ApiV2TestCase + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -160,7 +162,7 @@ class ApiV2PoolsTest(ApiV2TestCase): self.assertEqual(1, len(response.json['pools'])) # GET the default pool - pool_id = cfg.CONF['service:central'].default_pool_id + pool_id = CONF['service:central'].default_pool_id default_pool = self.central_service.get_pool(self.admin_context, pool_id) diff --git a/designate/tests/test_api/test_v2/test_zones.py b/designate/tests/test_api/test_v2/test_zones.py index ab1f8fb95..1d35bcabe 100644 --- a/designate/tests/test_api/test_v2/test_zones.py +++ b/designate/tests/test_api/test_v2/test_zones.py @@ -16,16 +16,19 @@ from unittest import mock from unittest.mock import patch -from oslo_config import cfg import oslo_messaging as messaging from designate.central import service as central_service +import designate.conf from designate import exceptions from designate import objects from designate.tests.test_api.test_v2 import ApiV2TestCase from designate.worker import rpcapi as worker_api +CONF = designate.conf.CONF + + class ApiV2ZonesTest(ApiV2TestCase): def setUp(self): super().setUp() @@ -541,7 +544,7 @@ class ApiV2ZonesTest(ApiV2TestCase): self.assertIn('id', response.json) self.assertIn('created_at', response.json) self.assertEqual('PENDING', response.json['status']) - self.assertEqual(cfg.CONF['service:central'].managed_resource_email, + self.assertEqual(CONF['service:central'].managed_resource_email, response.json['email']) self.assertIsNone(response.json['updated_at']) @@ -571,7 +574,7 @@ class ApiV2ZonesTest(ApiV2TestCase): {'host': '192.0.2.2', 'port': 69} ]) ) - zone.email = cfg.CONF['service:central'].managed_resource_email + zone.email = CONF['service:central'].managed_resource_email # Create a zone zone = self.central_service.create_zone(self.admin_context, zone) @@ -603,7 +606,7 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_xfr_request(self): # Create a zone fixture = self.get_zone_fixture('SECONDARY', 0) - fixture['email'] = cfg.CONF['service:central'].managed_resource_email + fixture['email'] = CONF['service:central'].managed_resource_email fixture['masters'] = [{"host": "192.0.2.10", "port": 53}] # Create a zone @@ -641,7 +644,7 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_update_secondary_email_invalid_object(self): # Create a zone fixture = self.get_zone_fixture('SECONDARY', 0) - fixture['email'] = cfg.CONF['service:central'].managed_resource_email + fixture['email'] = CONF['service:central'].managed_resource_email # Create a zone zone = self.create_zone(**fixture) diff --git a/designate/tests/test_central/test_service.py b/designate/tests/test_central/test_service.py index 8043f0c49..edb761b6d 100644 --- a/designate/tests/test_central/test_service.py +++ b/designate/tests/test_central/test_service.py @@ -13,7 +13,6 @@ # 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 collections import namedtuple from concurrent import futures import copy @@ -24,7 +23,6 @@ import random import unittest from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_db import exception as db_exception from oslo_log import log as logging @@ -35,6 +33,7 @@ from oslo_versionedobjects import exception as ovo_exc import testtools from designate.common import constants +import designate.conf from designate import exceptions from designate import objects from designate.storage import sql @@ -44,6 +43,8 @@ from designate.tests import fixtures from designate import utils from designate.worker import rpcapi as worker_api + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -942,7 +943,7 @@ class CentralServiceTest(designate.tests.TestCase): def test_update_zone_master_for_secondary_zone(self): fixture = self.get_zone_fixture('SECONDARY', 0) - fixture['email'] = cfg.CONF['service:central'].managed_resource_email + fixture['email'] = CONF['service:central'].managed_resource_email fixture['masters'] = [{'host': '192.0.2.10', 'port': 53}] # Create a zone @@ -1447,7 +1448,7 @@ class CentralServiceTest(designate.tests.TestCase): def test_xfr_zone(self): # Create a zone fixture = self.get_zone_fixture('SECONDARY', 0) - fixture['email'] = cfg.CONF['service:central'].managed_resource_email + fixture['email'] = CONF['service:central'].managed_resource_email fixture['masters'] = [{"host": "192.0.2.10", "port": 53}] # Create a zone @@ -1466,7 +1467,7 @@ class CentralServiceTest(designate.tests.TestCase): def test_xfr_zone_same_serial(self): # Create a zone fixture = self.get_zone_fixture('SECONDARY', 0) - fixture['email'] = cfg.CONF['service:central'].managed_resource_email + fixture['email'] = CONF['service:central'].managed_resource_email fixture['masters'] = [{"host": "192.0.2.10", "port": 53}] # Create a zone @@ -1484,7 +1485,7 @@ class CentralServiceTest(designate.tests.TestCase): def test_xfr_zone_lower_serial(self): # Create a zone fixture = self.get_zone_fixture('SECONDARY', 0) - fixture['email'] = cfg.CONF['service:central'].managed_resource_email + fixture['email'] = CONF['service:central'].managed_resource_email fixture['masters'] = [{"host": "192.0.2.10", "port": 53}] fixture['serial'] = 10 @@ -1573,8 +1574,8 @@ class CentralServiceTest(designate.tests.TestCase): # Create the Object recordset = objects.RecordSet(name='www.%s' % zone.name, type='A') - self.useFixture(cfg_fixture.Config(cfg.CONF)) - cfg.CONF.set_override('enforce_new_defaults', True, 'oslo_policy') + self.useFixture(cfg_fixture.Config(CONF)) + CONF.set_override('enforce_new_defaults', True, 'oslo_policy') context = self.get_context(project_id='1', roles=['member', 'reader']) self.share_zone(context=self.admin_context, zone_id=zone.id, @@ -3854,7 +3855,7 @@ class CentralServiceTest(designate.tests.TestCase): self.assertEqual('foo', result.message) def test_create_ptr_zone(self): - cfg.CONF.set_override( + CONF.set_override( 'managed_resource_tenant_id', self.admin_context.project_id, 'service:central' @@ -3869,7 +3870,7 @@ class CentralServiceTest(designate.tests.TestCase): self.assertEqual('example.org.', zones[0]['name']) def test_create_duplicate_ptr_zone(self): - cfg.CONF.set_override( + CONF.set_override( 'managed_resource_tenant_id', self.admin_context.project_id, 'service:central' @@ -4035,8 +4036,8 @@ class CentralServiceTest(designate.tests.TestCase): def test_share_zone_new_policy_defaults(self): # Configure designate for enforcing the new policy defaults - self.useFixture(cfg_fixture.Config(cfg.CONF)) - cfg.CONF.set_override('enforce_new_defaults', True, 'oslo_policy') + self.useFixture(cfg_fixture.Config(CONF)) + CONF.set_override('enforce_new_defaults', True, 'oslo_policy') context = self.get_context(project_id='1', roles=['member', 'reader']) # Create a Shared Zone @@ -4077,8 +4078,8 @@ class CentralServiceTest(designate.tests.TestCase): def test_unshare_zone_new_policy_defaults(self): # Configure designate for enforcing the new policy defaults - self.useFixture(cfg_fixture.Config(cfg.CONF)) - cfg.CONF.set_override('enforce_new_defaults', True, 'oslo_policy') + self.useFixture(cfg_fixture.Config(CONF)) + CONF.set_override('enforce_new_defaults', True, 'oslo_policy') context = self.get_context(project_id='1', roles=['member', 'reader']) # Create a Shared Zone @@ -4178,8 +4179,8 @@ class CentralServiceTest(designate.tests.TestCase): context=context, zone_id=zone.id, target_project_id="second_tenant" ) - self.useFixture(cfg_fixture.Config(cfg.CONF)) - cfg.CONF.set_override('enforce_new_defaults', True, 'oslo_policy') + self.useFixture(cfg_fixture.Config(CONF)) + CONF.set_override('enforce_new_defaults', True, 'oslo_policy') # Ensure we can retrieve both shared_zones shared_zones = self.central_service.find_shared_zones( diff --git a/designate/tests/test_dnsmiddleware.py b/designate/tests/test_dnsmiddleware.py index 9562d3448..c15faa8e7 100644 --- a/designate/tests/test_dnsmiddleware.py +++ b/designate/tests/test_dnsmiddleware.py @@ -14,15 +14,15 @@ from unittest import mock import dns import dns.query import dns.tsigkeyring -from oslo_config import cfg +import designate.conf from designate import dnsmiddleware from designate import dnsutils from designate.mdns import handler from designate import storage import designate.tests -CONF = cfg.CONF +CONF = designate.conf.CONF class TestSerializationMiddleware(designate.tests.TestCase): diff --git a/designate/tests/test_dnsutils.py b/designate/tests/test_dnsutils.py index 633ae9369..1cbdb361a 100644 --- a/designate/tests/test_dnsutils.py +++ b/designate/tests/test_dnsutils.py @@ -16,15 +16,15 @@ import dns import dns.query import dns.tsigkeyring -from oslo_config import cfg +import designate.conf from designate import dnsutils from designate import exceptions from designate import objects from designate import storage import designate.tests -CONF = cfg.CONF +CONF = designate.conf.CONF SAMPLES = { ("cname.example.com.", "CNAME"): { "ttl": 10800, diff --git a/designate/tests/test_mdns/test_handler.py b/designate/tests/test_mdns/test_handler.py index 4caf41716..972361dc5 100644 --- a/designate/tests/test_mdns/test_handler.py +++ b/designate/tests/test_mdns/test_handler.py @@ -22,15 +22,16 @@ import dns.rdatatype import dns.resolver import dns.rrset import dns.tsigkeyring -from oslo_config import cfg import testtools +import designate.conf from designate import context from designate.mdns import handler from designate import objects import designate.tests -CONF = cfg.CONF + +CONF = designate.conf.CONF default_pool_id = CONF['service:central'].default_pool_id ANSWER = [ @@ -127,7 +128,7 @@ class MdnsRequestHandlerTest(designate.tests.TestCase): attributes = attributes or [] masters = masters or [{"host": "192.0.2.1", "port": 53}] fixture = self.get_zone_fixture("SECONDARY", values=values) - fixture['email'] = cfg.CONF['service:central'].managed_resource_email + fixture['email'] = CONF['service:central'].managed_resource_email zone = objects.Zone(**fixture) zone.attributes = objects.ZoneAttributeList().from_list(attributes) diff --git a/designate/tests/test_quota/test_quota.py b/designate/tests/test_quota/test_quota.py index aeeedc944..297293220 100644 --- a/designate/tests/test_quota/test_quota.py +++ b/designate/tests/test_quota/test_quota.py @@ -15,14 +15,15 @@ # under the License. from unittest import mock -from oslo_config import cfg from oslo_log import log as logging import testscenarios +import designate.conf from designate import exceptions from designate import quota import designate.tests +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) load_tests = testscenarios.load_tests_apply_scenarios @@ -45,11 +46,11 @@ class QuotaTestCase(designate.tests.TestCase): self.assertIsNotNone(quotas) self.assertEqual({ - 'api_export_size': cfg.CONF.quota_api_export_size, - 'zones': cfg.CONF.quota_zones, - 'zone_recordsets': cfg.CONF.quota_zone_recordsets, - 'zone_records': cfg.CONF.quota_zone_records, - 'recordset_records': cfg.CONF.quota_recordset_records, + 'api_export_size': CONF.quota_api_export_size, + 'zones': CONF.quota_zones, + 'zone_recordsets': CONF.quota_zone_recordsets, + 'zone_records': CONF.quota_zone_records, + 'recordset_records': CONF.quota_recordset_records, }, quotas) def test_limit_check_unknown(self): @@ -78,11 +79,11 @@ class QuotaTestCase(designate.tests.TestCase): zone_records=0) self.quota.limit_check(context, 'tenant_id', - zones=(cfg.CONF.quota_zones - 1)) + zones=(CONF.quota_zones - 1)) self.quota.limit_check( context, 'tenant_id', - zone_records=(cfg.CONF.quota_zone_records - 1)) + zone_records=(CONF.quota_zone_records - 1)) def test_limit_check_at(self): context = self.get_admin_context() @@ -90,13 +91,13 @@ class QuotaTestCase(designate.tests.TestCase): self.assertRaisesRegex( exceptions.OverQuota, 'Quota exceeded for zones\\.', self.quota.limit_check, - context, 'tenant_id', zones=cfg.CONF.quota_zones + 1 + context, 'tenant_id', zones=CONF.quota_zones + 1 ) self.assertRaisesRegex( exceptions.OverQuota, 'Quota exceeded for zone_records\\.', self.quota.limit_check, - context, 'tenant_id', zone_records=cfg.CONF.quota_zone_records + 1 + context, 'tenant_id', zone_records=CONF.quota_zone_records + 1 ) def test_limit_check_unlimited(self): diff --git a/designate/tests/test_storage/test_storage.py b/designate/tests/test_storage/test_storage.py index a0e4eeb18..a4ef3611c 100644 --- a/designate/tests/test_storage/test_storage.py +++ b/designate/tests/test_storage/test_storage.py @@ -17,10 +17,10 @@ import math from sqlalchemy import text from unittest import mock -from oslo_config import cfg from oslo_log import log as logging from oslo_messaging.rpc import dispatcher as rpc_dispatcher +import designate.conf from designate.conf.mdns import DEFAULT_MDNS_PORT from designate import exceptions from designate import objects @@ -29,6 +29,8 @@ from designate.storage import sql from designate.tests import TestCase from designate.utils import generate_uuid + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -651,7 +653,7 @@ class SqlalchemyStorageTest(TestCase): # Zone Tests def test_create_zone(self): - pool_id = cfg.CONF['service:central'].default_pool_id + pool_id = CONF['service:central'].default_pool_id values = { 'tenant_id': self.admin_context.project_id, 'name': 'example.net.', diff --git a/designate/tests/unit/api/test_version.py b/designate/tests/unit/api/test_version.py index 7cbdf1400..db9d25115 100644 --- a/designate/tests/unit/api/test_version.py +++ b/designate/tests/unit/api/test_version.py @@ -10,16 +10,16 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base import webtest from designate.api import versions from designate.common import constants +import designate.conf -CONF = cfg.CONF +CONF = designate.conf.CONF class TestApiVersion(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/api/test_wsgi.py b/designate/tests/unit/api/test_wsgi.py index 1a1776b03..aa21fe89b 100644 --- a/designate/tests/unit/api/test_wsgi.py +++ b/designate/tests/unit/api/test_wsgi.py @@ -10,15 +10,15 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base from unittest import mock from designate.api import wsgi +import designate.conf -CONF = cfg.CONF +CONF = designate.conf.CONF class TestApiWsgi(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/central/test_central.py b/designate/tests/unit/central/test_central.py index dc77fc008..677277c42 100644 --- a/designate/tests/unit/central/test_central.py +++ b/designate/tests/unit/central/test_central.py @@ -12,19 +12,19 @@ from unittest import mock -from oslo_config import cfg import oslotest.base from designate.central import service from designate.common import profiler +import designate.conf from designate import exceptions from designate.objects import record from designate.objects import zone from designate import policy from designate import rpc -CONF = cfg.CONF +CONF = designate.conf.CONF class CentralTestCase(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/cmd/test_cmd.py b/designate/tests/unit/cmd/test_cmd.py index 5d92136c8..1f15361b2 100644 --- a/designate/tests/unit/cmd/test_cmd.py +++ b/designate/tests/unit/cmd/test_cmd.py @@ -9,10 +9,8 @@ # 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 unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base @@ -22,8 +20,10 @@ from designate.cmd import mdns from designate.cmd import producer from designate.cmd import sink from designate.cmd import worker +import designate.conf -CONF = cfg.CONF + +CONF = designate.conf.CONF @mock.patch('designate.service.wait') diff --git a/designate/tests/unit/cmd/test_manage.py b/designate/tests/unit/cmd/test_manage.py index e18a3e52a..24fd036ab 100644 --- a/designate/tests/unit/cmd/test_manage.py +++ b/designate/tests/unit/cmd/test_manage.py @@ -12,14 +12,15 @@ import sys from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base from designate.cmd import manage +import designate.conf from designate.manage import base -CONF = cfg.CONF + +CONF = designate.conf.CONF class ManageTestCase(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/mdns/test_handler.py b/designate/tests/unit/mdns/test_handler.py index 2f99816b2..9341ebf27 100644 --- a/designate/tests/unit/mdns/test_handler.py +++ b/designate/tests/unit/mdns/test_handler.py @@ -16,18 +16,19 @@ from unittest import mock import dns -from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_messaging import conffixture as messaging_fixture import oslotest.base +import designate.conf from designate import exceptions from designate.mdns import handler from designate import objects from designate.tests import fixtures from designate.worker import rpcapi as worker_rpcapi -CONF = cfg.CONF + +CONF = designate.conf.CONF class MdnsHandleTest(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/mdns/test_service.py b/designate/tests/unit/mdns/test_service.py index 8a17f0b9e..a23aa1ac8 100644 --- a/designate/tests/unit/mdns/test_service.py +++ b/designate/tests/unit/mdns/test_service.py @@ -15,10 +15,10 @@ # under the License. from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base +import designate.conf from designate import dnsmiddleware from designate.mdns import handler from designate.mdns import service @@ -27,7 +27,8 @@ from designate import storage from designate.tests import fixtures import designate.utils -CONF = cfg.CONF + +CONF = designate.conf.CONF class MdnsServiceTest(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/network_api/test_base.py b/designate/tests/unit/network_api/test_base.py index cbaddb6f2..5a5753a36 100644 --- a/designate/tests/unit/network_api/test_base.py +++ b/designate/tests/unit/network_api/test_base.py @@ -9,13 +9,15 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.mport threading -import designate.exceptions -from designate.network_api import base -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base -CONF = cfg.CONF +import designate.conf +import designate.exceptions +from designate.network_api import base + + +CONF = designate.conf.CONF SERVICE_CATALOG = [ { @@ -149,7 +151,7 @@ class NetworkEndpointsFromConfigTest(oslotest.base.BaseTestCase): ) result = self.base.endpoints_from_config( - cfg.CONF['network_api:neutron'].endpoints, + CONF['network_api:neutron'].endpoints, ) self.assertEqual( @@ -163,7 +165,7 @@ class NetworkEndpointsFromConfigTest(oslotest.base.BaseTestCase): ) result = self.base.endpoints_from_config( - cfg.CONF['network_api:neutron'].endpoints, + CONF['network_api:neutron'].endpoints, ) self.assertEqual( @@ -177,7 +179,7 @@ class NetworkEndpointsFromConfigTest(oslotest.base.BaseTestCase): ) result = self.base.endpoints_from_config( - cfg.CONF['network_api:neutron'].endpoints, + CONF['network_api:neutron'].endpoints, region='RegionFour', ) @@ -195,7 +197,7 @@ class NetworkEndpointsFromConfigTest(oslotest.base.BaseTestCase): designate.exceptions.ConfigurationError, 'Endpoints are not correctly configured', self.base.endpoints_from_config, - cfg.CONF['network_api:neutron'].endpoints, + CONF['network_api:neutron'].endpoints, region='RegionFive', ) @@ -209,7 +211,7 @@ class NetworkEndpointsFromConfigTest(oslotest.base.BaseTestCase): designate.exceptions.ConfigurationError, 'Endpoints are not correctly configured', self.base.endpoints_from_config, - cfg.CONF['network_api:neutron'].endpoints, + CONF['network_api:neutron'].endpoints, ) diff --git a/designate/tests/unit/network_api/test_neutron.py b/designate/tests/unit/network_api/test_neutron.py index c9e60cb75..227423618 100644 --- a/designate/tests/unit/network_api/test_neutron.py +++ b/designate/tests/unit/network_api/test_neutron.py @@ -16,17 +16,18 @@ from unittest import mock from openstack import exceptions as sdk_exceptions -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base +import designate.conf from designate import context from designate import exceptions from designate.network_api import get_network_api from designate.network_api import neutron from designate import version -CONF = cfg.CONF + +CONF = designate.conf.CONF class NeutronNetworkAPITest(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/notification_handler/test_fake.py b/designate/tests/unit/notification_handler/test_fake.py index 69c88154a..088e102db 100644 --- a/designate/tests/unit/notification_handler/test_fake.py +++ b/designate/tests/unit/notification_handler/test_fake.py @@ -11,13 +11,14 @@ # under the License.mport threading from unittest import mock -from oslo_config import cfg import oslotest.base +import designate.conf from designate.notification_handler import fake from designate.tests import test_notification_handler -CONF = cfg.CONF + +CONF = designate.conf.CONF class TestFakeHandler(oslotest.base.BaseTestCase, diff --git a/designate/tests/unit/objects/test_adapters_v2_api.py b/designate/tests/unit/objects/test_adapters_v2_api.py index 816bf9e85..5ae6ca24f 100644 --- a/designate/tests/unit/objects/test_adapters_v2_api.py +++ b/designate/tests/unit/objects/test_adapters_v2_api.py @@ -15,17 +15,18 @@ # under the License. from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_log import log as logging import oslotest.base +import designate.conf from designate import exceptions from designate import objects from designate.objects import adapters from designate.objects.adapters.api_v2 import base -CONF = cfg.CONF + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) diff --git a/designate/tests/unit/objects/test_recordset.py b/designate/tests/unit/objects/test_recordset.py index 8b0307ca4..e315501a7 100644 --- a/designate/tests/unit/objects/test_recordset.py +++ b/designate/tests/unit/objects/test_recordset.py @@ -16,16 +16,18 @@ import itertools from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_log import log as logging import oslotest.base + +import designate.conf from designate import exceptions from designate import objects from designate.objects.adapters import DesignateAdapter -CONF = cfg.CONF + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) diff --git a/designate/tests/unit/producer/test_service.py b/designate/tests/unit/producer/test_service.py index fc459b284..b0f7a59bb 100644 --- a/designate/tests/unit/producer/test_service.py +++ b/designate/tests/unit/producer/test_service.py @@ -20,16 +20,17 @@ Unit-test Producer service from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base +import designate.conf from designate import exceptions from designate.producer import service import designate.service from designate.tests import fixtures -CONF = cfg.CONF + +CONF = designate.conf.CONF @mock.patch.object(service.rpcapi.CentralAPI, 'get_instance', mock.Mock()) diff --git a/designate/tests/unit/producer/test_tasks.py b/designate/tests/unit/producer/test_tasks.py index 519b468e8..bcf3e494a 100644 --- a/designate/tests/unit/producer/test_tasks.py +++ b/designate/tests/unit/producer/test_tasks.py @@ -27,6 +27,7 @@ from oslo_utils import timeutils import oslotest.base from designate.central import rpcapi as central_api +import designate.conf from designate import context from designate.producer import tasks from designate import rpc @@ -44,7 +45,7 @@ DUMMY_TASK_OPTS = [ help='Default amount of results returned per page'), ] -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.register_group(DUMMY_TASK_GROUP) CONF.register_opts(DUMMY_TASK_OPTS, group=DUMMY_TASK_GROUP) diff --git a/designate/tests/unit/scheduler/test_permutations.py b/designate/tests/unit/scheduler/test_permutations.py index ebab4b932..d77c80009 100644 --- a/designate/tests/unit/scheduler/test_permutations.py +++ b/designate/tests/unit/scheduler/test_permutations.py @@ -11,14 +11,17 @@ # under the License. from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture +import designate.conf from designate import exceptions from designate import objects from designate import scheduler from designate import tests + +CONF = designate.conf.CONF + DEFAULT_POOL_ID = BRONZE_POOL_ID = '67d71c2a-645c-4dde-a6b8-60a172c9ede8' SILVER_POOL_ID = '5fabcd37-262c-4cf3-8625-7f419434b6df' GOLD_POOL_ID = '24702e43-8a52-440f-ab74-19fc16048860' @@ -64,7 +67,7 @@ def build_test_pools(): class AttributeSchedulerPermutationsTest(tests.TestCase): def setUp(self): super().setUp() - self.CONF = self.useFixture(cfg_fixture.Config(cfg.CONF)).conf + self.CONF = self.useFixture(cfg_fixture.Config(CONF)).conf self.context = self.get_context() self.CONF.set_override( @@ -182,7 +185,7 @@ class AttributeSchedulerPermutationsTest(tests.TestCase): class DefaultSchedulerPermutationsTest(tests.TestCase): def setUp(self): super().setUp() - self.CONF = self.useFixture(cfg_fixture.Config(cfg.CONF)).conf + self.CONF = self.useFixture(cfg_fixture.Config(CONF)).conf self.context = self.get_context() self.CONF.set_override( @@ -214,7 +217,7 @@ class DefaultSchedulerPermutationsTest(tests.TestCase): class FallbackSchedulerPermutationsTest(tests.TestCase): def setUp(self): super().setUp() - self.CONF = self.useFixture(cfg_fixture.Config(cfg.CONF)).conf + self.CONF = self.useFixture(cfg_fixture.Config(CONF)).conf self.context = self.get_context() self.CONF.set_override( diff --git a/designate/tests/unit/sink/test_notifications.py b/designate/tests/unit/sink/test_notifications.py index 5a86fa2a5..9fad99f36 100644 --- a/designate/tests/unit/sink/test_notifications.py +++ b/designate/tests/unit/sink/test_notifications.py @@ -9,19 +9,18 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.mport threading - from unittest import mock -from oslo_config import cfg import oslotest.base +import designate.conf from designate.notification_handler import fake from designate.sink import service from designate.tests import fixtures from designate.tests import test_notification_handler -CONF = cfg.CONF +CONF = designate.conf.CONF class TestSinkNotification(oslotest.base.BaseTestCase, diff --git a/designate/tests/unit/storage/impl_sqlalchemy/test_sqlalchemy.py b/designate/tests/unit/storage/impl_sqlalchemy/test_sqlalchemy.py index 055479784..609dbf6e9 100644 --- a/designate/tests/unit/storage/impl_sqlalchemy/test_sqlalchemy.py +++ b/designate/tests/unit/storage/impl_sqlalchemy/test_sqlalchemy.py @@ -9,13 +9,13 @@ # 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 import oslotest.base - +import designate.conf from designate.storage import sqlalchemy -CONF = cfg.CONF + + +CONF = designate.conf.CONF class SqlalchemyTestCase(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/test_central/test_basic.py b/designate/tests/unit/test_central/test_basic.py index 194ce9714..73d240d54 100644 --- a/designate/tests/unit/test_central/test_basic.py +++ b/designate/tests/unit/test_central/test_basic.py @@ -18,7 +18,6 @@ from unittest import mock from unittest.mock import patch import fixtures -from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_log import log as logging from oslo_messaging.rpc import dispatcher as rpc_dispatcher @@ -27,12 +26,15 @@ import testtools import designate.central.service from designate.central.service import Service +import designate.conf from designate import exceptions from designate import objects from designate.storage import sqlalchemy from designate.tests.fixtures import random_seed from designate.tests import TestCase + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -222,7 +224,7 @@ class NotMockedError(NotImplementedError): class CentralBasic(TestCase): def setUp(self): super().setUp() - self.CONF = self.useFixture(cfg_fixture.Config(cfg.CONF)).conf + self.CONF = self.useFixture(cfg_fixture.Config(CONF)).conf self.CONF([], project='designate') mock_storage = mock.Mock(spec=sqlalchemy.SQLAlchemyStorage) @@ -279,7 +281,7 @@ class CentralBasic(TestCase): class CentralServiceTestCase(CentralBasic): def test_conf_fixture(self): - assert 'service:central' in cfg.CONF + assert 'service:central' in CONF def test_init(self): self.assertTrue(self.service.check_for_tlds) @@ -633,7 +635,7 @@ class CentralZoneTestCase(CentralBasic): def test_is_valid_recordset_name_too_long(self): zone = RoObject(name='example.org.') - cfg.CONF['service:central'].max_recordset_name_len = 255 + CONF['service:central'].max_recordset_name_len = 255 rs_name = 'a' * 255 + '.org.' with testtools.ExpectedException(exceptions.InvalidRecordSetName) as e: self.service._is_valid_recordset_name(self.context, zone, rs_name) @@ -1831,8 +1833,8 @@ class CentralStatusTests(CentralBasic): class CentralQuotaTest(unittest.TestCase): def setUp(self): - self.CONF = cfg_fixture.Config(cfg.CONF) - cfg.CONF([], project='designate') + self.CONF = cfg_fixture.Config(CONF) + CONF([], project='designate') self.CONF.config(quota_driver="noop") self.context = mock.Mock() self.zone = mock.Mock() diff --git a/designate/tests/unit/test_dnsmiddleware.py b/designate/tests/unit/test_dnsmiddleware.py index e8163459a..0e305e9c4 100644 --- a/designate/tests/unit/test_dnsmiddleware.py +++ b/designate/tests/unit/test_dnsmiddleware.py @@ -12,12 +12,13 @@ from unittest import mock import dns.message -from oslo_config import cfg +import designate.conf from designate import dnsmiddleware import oslotest.base -CONF = cfg.CONF + +CONF = designate.conf.CONF class TestDNSMiddleware(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/test_dnsutils.py b/designate/tests/unit/test_dnsutils.py index 699175be2..30ba4cbe2 100644 --- a/designate/tests/unit/test_dnsutils.py +++ b/designate/tests/unit/test_dnsutils.py @@ -23,14 +23,15 @@ import dns.rcode import dns.rdatatype import dns.zone import eventlet -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base +import designate.conf from designate import dnsutils from designate import exceptions -CONF = cfg.CONF + +CONF = designate.conf.CONF class TestDNSUtils(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/test_heartbeat_emitter.py b/designate/tests/unit/test_heartbeat_emitter.py index d296a57cc..29e6e690c 100644 --- a/designate/tests/unit/test_heartbeat_emitter.py +++ b/designate/tests/unit/test_heartbeat_emitter.py @@ -14,16 +14,17 @@ import time from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_service import loopingcall import oslotest.base +import designate.conf from designate import heartbeat_emitter from designate import objects from designate.tests import fixtures -CONF = cfg.CONF + +CONF = designate.conf.CONF class HeartbeatEmitterTest(oslotest.base.BaseTestCase): @@ -105,7 +106,7 @@ class RpcEmitterTest(oslotest.base.BaseTestCase): mock_service_status.assert_called_once_with( service_name='svc', - hostname=cfg.CONF.host, + hostname=CONF.host, status='UP', stats={}, capabilities={}, diff --git a/designate/tests/unit/test_service.py b/designate/tests/unit/test_service.py index 9e574238d..01af68ec7 100644 --- a/designate/tests/unit/test_service.py +++ b/designate/tests/unit/test_service.py @@ -13,19 +13,20 @@ import errno import socket from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_service import service import oslotest.base from designate.common import profiler +import designate.conf from designate.mdns import handler from designate import policy from designate import rpc from designate import service as designate_service from designate import utils -CONF = cfg.CONF + +CONF = designate.conf.CONF class TestBaseService(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/test_utils.py b/designate/tests/unit/test_utils.py index 9973d550d..23dab82bd 100644 --- a/designate/tests/unit/test_utils.py +++ b/designate/tests/unit/test_utils.py @@ -14,15 +14,16 @@ from unittest import mock import jinja2 from oslo_concurrency import processutils -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base +import designate.conf from designate import exceptions from designate.tests import fixtures from designate import utils -CONF = cfg.CONF + +CONF = designate.conf.CONF class TestUtils(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/workers/test_base_task.py b/designate/tests/unit/workers/test_base_task.py index c23b2737d..76d52ec8d 100644 --- a/designate/tests/unit/workers/test_base_task.py +++ b/designate/tests/unit/workers/test_base_task.py @@ -13,12 +13,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.mport threading -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base from unittest import mock from designate.central import rpcapi as central_rpcapi +import designate.conf from designate import exceptions from designate import objects import designate.quota.base @@ -28,7 +28,7 @@ from designate.worker import rpcapi as worker_rpcapi from designate.worker.tasks import base -CONF = cfg.CONF +CONF = designate.conf.CONF class TestTask(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/workers/test_notify.py b/designate/tests/unit/workers/test_notify.py index 43a5dcd54..f3f601020 100644 --- a/designate/tests/unit/workers/test_notify.py +++ b/designate/tests/unit/workers/test_notify.py @@ -19,15 +19,16 @@ from unittest import mock import dns import dns.rdataclass import dns.rdatatype -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base +import designate.conf from designate import dnsutils from designate.tests.unit import RoObject from designate.worker.tasks import zone as worker_zone -CONF = cfg.CONF + +CONF = designate.conf.CONF class WorkerNotifyTest(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/workers/test_processing.py b/designate/tests/unit/workers/test_processing.py index cf3251483..360f5760e 100644 --- a/designate/tests/unit/workers/test_processing.py +++ b/designate/tests/unit/workers/test_processing.py @@ -15,16 +15,16 @@ # under the License.mport threading from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture +import designate.conf from designate import exceptions from designate.tests import fixtures from designate.tests import TestCase from designate.worker import processing -CONF = cfg.CONF +CONF = designate.conf.CONF class TestProcessingExecutor(TestCase): diff --git a/designate/tests/unit/workers/test_service.py b/designate/tests/unit/workers/test_service.py index bd6121352..0adcaaa4a 100644 --- a/designate/tests/unit/workers/test_service.py +++ b/designate/tests/unit/workers/test_service.py @@ -15,13 +15,13 @@ # under the License.mport threading from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslo_messaging as messaging import oslotest.base from designate import backend from designate.central import rpcapi as central_rpcapi +import designate.conf from designate import exceptions from designate import objects import designate.service @@ -31,7 +31,8 @@ from designate.tests import fixtures from designate.worker import processing from designate.worker import service -CONF = cfg.CONF + +CONF = designate.conf.CONF class TestService(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/workers/test_task_config.py b/designate/tests/unit/workers/test_task_config.py index ee384e0c6..4935dbb33 100644 --- a/designate/tests/unit/workers/test_task_config.py +++ b/designate/tests/unit/workers/test_task_config.py @@ -13,9 +13,10 @@ from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base +import designate.conf from designate.worker.tasks import base -CONF = cfg.CONF +CONF = designate.conf.CONF class TestTaskConfig(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/workers/test_xfr.py b/designate/tests/unit/workers/test_xfr.py index 6d8d81266..ca4fbf60e 100644 --- a/designate/tests/unit/workers/test_xfr.py +++ b/designate/tests/unit/workers/test_xfr.py @@ -15,18 +15,19 @@ # under the License. from unittest import mock -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base from designate.common import constants +import designate.conf from designate import dnsutils from designate import exceptions from designate import objects from designate.tests import fixtures from designate.worker.tasks import zone as worker_zone -CONF = cfg.CONF + +CONF = designate.conf.CONF class TestXfr(oslotest.base.BaseTestCase): diff --git a/designate/tests/unit/workers/test_zone_tasks.py b/designate/tests/unit/workers/test_zone_tasks.py index faa133a03..f4fbdedf1 100644 --- a/designate/tests/unit/workers/test_zone_tasks.py +++ b/designate/tests/unit/workers/test_zone_tasks.py @@ -16,10 +16,10 @@ from unittest import mock import dns.exception -from oslo_config import cfg from oslo_config import fixture as cfg_fixture import oslotest.base +import designate.conf from designate import dnsutils from designate import exceptions from designate import objects @@ -27,7 +27,8 @@ from designate.tests.unit import utils from designate.worker import processing from designate.worker.tasks import zone -CONF = cfg.CONF + +CONF = designate.conf.CONF QUERY_RESULTS = { 'delete_success_all': { @@ -309,7 +310,7 @@ class TestZoneActor(oslotest.base.BaseTestCase): ) self.assertEqual( - cfg.CONF['service:worker'].threshold_percentage, + CONF['service:worker'].threshold_percentage, actor.threshold_percentage ) diff --git a/designate/utils.py b/designate/utils.py index f6f7b937f..25c6b3100 100644 --- a/designate/utils.py +++ b/designate/utils.py @@ -30,10 +30,12 @@ from oslo_utils import uuidutils import pkg_resources from designate.common import config +import designate.conf from designate import exceptions from designate.i18n import _ LOG = logging.getLogger(__name__) +CONF = designate.conf.CONF # Default datetime format @@ -51,9 +53,9 @@ def find_config(config_path): """ possible_locations = [ config_path, - os.path.join(cfg.CONF.pybasedir, "etc", "designate", config_path), - os.path.join(cfg.CONF.pybasedir, "etc", config_path), - os.path.join(cfg.CONF.pybasedir, config_path), + os.path.join(CONF.pybasedir, "etc", "designate", config_path), + os.path.join(CONF.pybasedir, "etc", config_path), + os.path.join(CONF.pybasedir, config_path), "/etc/designate/%s" % config_path, ] @@ -69,7 +71,7 @@ def find_config(config_path): def read_config(prog, argv): - logging.register_options(cfg.CONF) + logging.register_options(CONF) config_files = find_config('%s.conf' % prog) cfg.CONF(argv[1:], project='designate', prog=prog, default_config_files=config_files) @@ -112,7 +114,7 @@ def render_template(template, **template_context): def execute(*cmd, **kw): """Execute a command in a subprocess, blocking. """ - root_helper = kw.pop('root_helper', cfg.CONF.root_helper) + root_helper = kw.pop('root_helper', CONF.root_helper) run_as_root = kw.pop('run_as_root', True) return processutils.execute(*cmd, run_as_root=run_as_root, root_helper=root_helper, **kw) @@ -192,13 +194,13 @@ def get_proxies(): consumption in clients when we need to proxy requests. """ proxies = {} - if cfg.CONF.proxy.no_proxy: - proxies['no_proxy'] = cfg.CONF.proxy.no_proxy - if cfg.CONF.proxy.http_proxy is not None: - proxies['http'] = cfg.CONF.proxy.http_proxy + if CONF.proxy.no_proxy: + proxies['no_proxy'] = CONF.proxy.no_proxy + if CONF.proxy.http_proxy is not None: + proxies['http'] = CONF.proxy.http_proxy - if cfg.CONF.proxy.https_proxy is not None: - proxies['https'] = cfg.CONF.proxy.https_proxy + if CONF.proxy.https_proxy is not None: + proxies['https'] = CONF.proxy.https_proxy elif 'http' in proxies: proxies['https'] = proxies['http'] @@ -242,10 +244,10 @@ def get_paging_params(context, params, sort_keys): Extract any paging parameters """ marker = params.pop('marker', None) - limit = params.pop('limit', cfg.CONF['service:api'].default_limit_v2) + limit = params.pop('limit', CONF['service:api'].default_limit_v2) sort_key = params.pop('sort_key', None) sort_dir = params.pop('sort_dir', None) - max_limit = cfg.CONF['service:api'].max_limit_v2 + max_limit = CONF['service:api'].max_limit_v2 if isinstance(limit, str) and limit.lower() == "max": # Support for retrieving the max results at once. If set to "max", diff --git a/designate/worker/processing.py b/designate/worker/processing.py index 0c31b9621..b55c95315 100644 --- a/designate/worker/processing.py +++ b/designate/worker/processing.py @@ -16,13 +16,14 @@ import time import futurist -from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import exceptions + LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF def default_executor(): diff --git a/designate/worker/rpcapi.py b/designate/worker/rpcapi.py index 5f0d65719..bed7cea9f 100644 --- a/designate/worker/rpcapi.py +++ b/designate/worker/rpcapi.py @@ -13,14 +13,16 @@ # 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_log import log as logging import oslo_messaging as messaging from designate.common import profiler +import designate.conf from designate.loggingutils import rpc_logging from designate import rpc + +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) WORKER_API = None @@ -41,7 +43,7 @@ class WorkerAPI: RPC_API_VERSION = '1.2' def __init__(self, topic=None): - self.topic = topic if topic else cfg.CONF['service:worker'].topic + self.topic = topic if topic else CONF['service:worker'].topic target = messaging.Target(topic=self.topic, version=self.RPC_API_VERSION) diff --git a/designate/worker/service.py b/designate/worker/service.py index 05ca1228f..2f2c690cb 100644 --- a/designate/worker/service.py +++ b/designate/worker/service.py @@ -15,13 +15,13 @@ # under the License. import time -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from designate import backend from designate.central import rpcapi as central_api from designate.common.decorators import rpc +import designate.conf from designate.context import DesignateContext from designate import exceptions from designate import service @@ -31,7 +31,7 @@ from designate.worker.tasks import zone as zonetasks LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF class AlsoNotifyTask: @@ -54,8 +54,8 @@ class Service(service.RPCService): self._pools_map = None super().__init__( - self.service_name, cfg.CONF['service:worker'].topic, - threads=cfg.CONF['service:worker'].threads, + self.service_name, CONF['service:worker'].topic, + threads=CONF['service:worker'].threads, ) @property diff --git a/designate/worker/tasks/base.py b/designate/worker/tasks/base.py index 2f69b5f16..6cec87a14 100644 --- a/designate/worker/tasks/base.py +++ b/designate/worker/tasks/base.py @@ -13,19 +13,19 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.mport threading - -from oslo_config import cfg from oslo_log import log as logging from designate.central import rpcapi as central_rpcapi +import designate.conf from designate import exceptions from designate import quota from designate import storage from designate import utils from designate.worker import rpcapi as worker_rpcapi + LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF def percentage(part, whole): diff --git a/designate/worker/tasks/zone.py b/designate/worker/tasks/zone.py index 103c77ef1..956a5517a 100644 --- a/designate/worker/tasks/zone.py +++ b/designate/worker/tasks/zone.py @@ -18,18 +18,19 @@ import errno import time import dns -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils from designate.common import constants +import designate.conf from designate import dnsutils from designate import exceptions from designate import objects from designate.worker.tasks import base + LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF ###################### # CRUD Zone Operations