From a53c3daf16d366e3cc513c62f57042f43cbd4588 Mon Sep 17 00:00:00 2001 From: Erik Olof Gunnar Andersson Date: Sat, 16 Mar 2019 16:50:02 -0700 Subject: [PATCH] Moved most configuration into designate.conf Based upon the established conf paradigm used in Nova, this patch moves most of the configuration to a central location. Making config a lot easier to manage, as well a lot easier to locate. There is still some configuration listed in classes, that I would like to eventually move to designate.conf as well, but to lower complexity not all config was moved. General changes * Centrelized most configuration under designate.conf. * Cleaned up configuration. * Simplified config generation. * Renamed generated config to designate.conf.sample. Previously broken * xfr_timeout now in the appropriate section. * memcached_servers now in the appropriate section. Previously missing from sample config * allowed_remote_exmods listed in sample config. * backend:akamai section listed in sample config. * backend:dynect section listed in sample config. * backend:infoblox section listed in sample config. blueprint centralize-config-designate Change-Id: I3be68bf294157631a9bac128df0841220020de96 --- designate/__init__.py | 45 +------ designate/agent/__init__.py | 76 ----------- designate/api/__init__.py | 114 ----------------- designate/backend/agent_backend/impl_bind9.py | 44 ++----- .../backend/agent_backend/impl_denominator.py | 25 +--- .../backend/agent_backend/impl_djbdns.py | 54 ++------ designate/backend/agent_backend/impl_gdnsd.py | 35 ++--- designate/backend/agent_backend/impl_knot2.py | 33 +---- designate/backend/agent_backend/impl_msdns.py | 17 +-- designate/backend/impl_akamai.py | 22 +--- designate/backend/impl_designate.py | 2 +- designate/backend/impl_dynect.py | 25 +--- designate/backend/impl_infoblox/connector.py | 9 +- designate/backend/impl_powerdns/__init__.py | 3 +- designate/central/__init__.py | 56 -------- designate/cmd/agent.py | 4 +- designate/cmd/api.py | 5 +- designate/cmd/central.py | 4 +- designate/cmd/manage.py | 4 +- designate/cmd/mdns.py | 4 +- designate/cmd/pool_manager.py | 6 +- designate/cmd/producer.py | 6 +- designate/cmd/sink.py | 4 +- designate/cmd/status.py | 4 +- designate/cmd/worker.py | 6 +- designate/cmd/zone_manager.py | 6 +- designate/common/keystone.py | 16 --- designate/common/memorycache.py | 13 -- designate/conf/__init__.py | 71 ++++++++++ designate/conf/agent.py | 67 ++++++++++ designate/conf/akamai.py | 46 +++++++ designate/conf/api.py | 117 +++++++++++++++++ designate/conf/base.py | 113 ++++++++++++++++ designate/conf/bind9.py | 44 +++++++ designate/conf/central.py | 65 ++++++++++ designate/conf/coordination.py | 53 ++++++++ designate/conf/denominator.py | 39 ++++++ designate/conf/djbdns.py | 57 +++++++++ designate/conf/dynect.py | 41 ++++++ designate/conf/gdnsd.py | 42 ++++++ .../config.py => conf/infoblox.py} | 42 +++--- designate/conf/keystone.py | 32 +++++ designate/conf/knot2.py | 40 ++++++ designate/conf/mdns.py | 68 ++++++++++ designate/conf/metrics.py | 36 ++++++ designate/conf/msdns.py | 35 +++++ designate/conf/network_api.py | 58 +++++++++ designate/conf/opts.py | 80 ++++++++++++ designate/conf/pool_manager.py | 112 ++++++++++++++++ designate/conf/producer.py | 121 ++++++++++++++++++ designate/conf/proxy.py | 43 +++++++ designate/conf/service_status.py | 38 ++++++ designate/conf/sink.py | 88 +++++++++++++ designate/conf/storage.py | 33 +++++ designate/conf/worker.py | 69 ++++++++++ designate/coordination.py | 34 +---- designate/dnsutils.py | 16 +-- designate/mdns/__init__.py | 67 ---------- designate/metrics.py | 21 +-- designate/network_api/neutron.py | 39 ------ designate/notification_handler/neutron.py | 22 ---- designate/notification_handler/nova.py | 22 ---- designate/notifications.py | 12 +- designate/opts.py | 61 --------- designate/pool_manager/__init__.py | 65 ---------- .../cache/impl_memcache/__init__.py | 21 +-- .../cache/impl_sqlalchemy/__init__.py | 11 +- designate/producer/__init__.py | 121 ------------------ designate/quota/__init__.py | 17 --- designate/rpc.py | 7 - designate/scheduler/__init__.py | 16 --- designate/service.py | 17 +-- designate/service_status.py | 21 +-- designate/sink/__init__.py | 42 ------ designate/storage/impl_sqlalchemy/__init__.py | 9 -- designate/tests/__init__.py | 58 ++++----- .../test_agent/test_backends/test_djbdns.py | 2 +- .../test_agent/test_backends/test_gdnsd.py | 8 +- designate/utils.py | 28 ---- designate/worker/__init__.py | 68 ---------- doc/source/conf.py | 1 + etc/designate/designate-config-generator.conf | 16 +-- setup.cfg | 13 +- 83 files changed, 1793 insertions(+), 1334 deletions(-) create mode 100644 designate/conf/__init__.py create mode 100644 designate/conf/agent.py create mode 100644 designate/conf/akamai.py create mode 100644 designate/conf/api.py create mode 100644 designate/conf/base.py create mode 100644 designate/conf/bind9.py create mode 100644 designate/conf/central.py create mode 100644 designate/conf/coordination.py create mode 100644 designate/conf/denominator.py create mode 100644 designate/conf/djbdns.py create mode 100644 designate/conf/dynect.py create mode 100644 designate/conf/gdnsd.py rename designate/{backend/impl_infoblox/config.py => conf/infoblox.py} (76%) create mode 100644 designate/conf/keystone.py create mode 100644 designate/conf/knot2.py create mode 100644 designate/conf/mdns.py create mode 100644 designate/conf/metrics.py create mode 100644 designate/conf/msdns.py create mode 100644 designate/conf/network_api.py create mode 100644 designate/conf/opts.py create mode 100644 designate/conf/pool_manager.py create mode 100644 designate/conf/producer.py create mode 100644 designate/conf/proxy.py create mode 100644 designate/conf/service_status.py create mode 100644 designate/conf/sink.py create mode 100644 designate/conf/storage.py create mode 100644 designate/conf/worker.py delete mode 100644 designate/opts.py diff --git a/designate/__init__.py b/designate/__init__.py index 4dd3ceb42..d68a08c72 100644 --- a/designate/__init__.py +++ b/designate/__init__.py @@ -19,9 +19,6 @@ import os # the /etc/hosts file, causing problems for installs. os.environ['EVENTLET_NO_GREENDNS'] = 'yes' -import socket - -from oslo_config import cfg from oslo_log import log from oslo_concurrency import lockutils import oslo_messaging as messaging @@ -32,45 +29,7 @@ _EXTRA_DEFAULT_LOG_LEVELS = [ 'keystone=INFO', 'oslo_service.loopingcall=WARN', ] - -designate_opts = [ - cfg.StrOpt('host', default=socket.gethostname(), - sample_default='current_hostname', - help='Name of this node'), - cfg.StrOpt( - 'pybasedir', - sample_default='', - default=os.path.abspath(os.path.join(os.path.dirname(__file__), - '../')), - help='Directory where the designate python module is installed' - ), - cfg.StrOpt('state-path', default='/var/lib/designate', - help='Top-level directory for maintaining designate\'s state'), - - cfg.StrOpt('central-topic', default='central', help='Central Topic'), - cfg.StrOpt('mdns-topic', default='mdns', help='mDNS Topic'), - cfg.StrOpt('pool-manager-topic', default='pool_manager', - help='Pool Manager Topic'), - cfg.StrOpt('worker-topic', default='worker', help='Worker Topic'), - - # Default TTL - cfg.IntOpt('default-ttl', default=3600, help='TTL Value'), - - # Default SOA Values - cfg.IntOpt('default-soa-refresh-min', default=3500, - deprecated_name='default-soa-refresh', - help='SOA refresh-min value'), - cfg.IntOpt('default-soa-refresh-max', default=3600, - help='SOA max value'), - cfg.IntOpt('default-soa-retry', default=600, help='SOA retry'), - cfg.IntOpt('default-soa-expire', default=86400, help='SOA expire'), - cfg.IntOpt('default-soa-minimum', default=3600, help='SOA minimum value'), - - # Supported record types - cfg.ListOpt('supported-record-type', help='Supported record types', - default=['A', 'AAAA', 'CNAME', 'MX', 'SRV', 'TXT', 'SPF', 'NS', - 'PTR', 'SSHFP', 'SOA', 'NAPTR', 'CAA']), -] +BASE_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../')) # Set some Oslo Log defaults log.set_defaults(default_log_levels=log.get_default_log_levels() + @@ -81,5 +40,3 @@ messaging.set_transport_defaults('designate') # Set some Oslo Oslo Concurrency defaults lockutils.set_defaults(lock_path='$state_path') - -cfg.CONF.register_opts(designate_opts) diff --git a/designate/agent/__init__.py b/designate/agent/__init__.py index e17f24903..e69de29bb 100644 --- a/designate/agent/__init__.py +++ b/designate/agent/__init__.py @@ -1,76 +0,0 @@ -# Copyright 2014 Rackspace Inc. -# -# Author: Tim Simmons -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_config import cfg - -from designate.utils import DEFAULT_AGENT_PORT -from designate.backend.agent_backend import impl_bind9 -from designate.backend.agent_backend import impl_denominator -from designate.backend.agent_backend import impl_djbdns -from designate.backend.agent_backend import impl_gdnsd -from designate.backend.agent_backend import impl_knot2 -from designate.backend.agent_backend import impl_msdns - - -agent_group = cfg.OptGroup( - name='service:agent', title="Configuration for the Agent Service" -) - -agent_opts = [ - cfg.IntOpt('workers', - help='Number of agent worker processes to spawn'), - cfg.IntOpt('threads', default=1000, - help='Number of agent greenthreads to spawn'), - cfg.IPOpt('host', - deprecated_for_removal=True, - deprecated_reason="Replaced by 'listen' option", - help='Agent Bind Host'), - cfg.PortOpt('port', - deprecated_for_removal=True, - deprecated_reason="Replaced by 'listen' option", - help='Agent Port Number'), - cfg.ListOpt('listen', - default=['0.0.0.0:%d' % DEFAULT_AGENT_PORT], - help='Agent host:port pairs to listen on'), - cfg.IntOpt('tcp-backlog', default=100, - help='The Agent TCP Backlog'), - cfg.FloatOpt('tcp-recv-timeout', default=0.5, - help='Agent TCP Receive Timeout'), - cfg.ListOpt('allow-notify', default=[], - help='List of IP addresses allowed to NOTIFY The Agent'), - cfg.ListOpt('masters', default=[], - help='List of masters for the Agent, format ip:port'), - cfg.StrOpt('backend-driver', default='bind9', - help='The backend driver to use, e.g. bind9, djbdns, knot2'), - cfg.StrOpt('transfer-source', - help='An IP address to be used to fetch zones transferred in'), - cfg.FloatOpt('notify-delay', default=0.0, - help='Delay after a NOTIFY arrives for a zone that the Agent ' - 'will pause and drop subsequent NOTIFYs for that zone'), -] - -cfg.CONF.register_group(agent_group) -cfg.CONF.register_opts(agent_opts, group=agent_group) - - -def list_opts(): - yield agent_group, agent_opts - yield impl_bind9.bind9_group, impl_bind9.bind9_opts - yield impl_denominator.denominator_group, impl_denominator.denominator_opts - yield impl_djbdns.djbdns_group, impl_djbdns.djbdns_opts - yield impl_gdnsd.gdnsd_group, impl_gdnsd.gdnsd_opts - yield impl_knot2.knot2_group, impl_knot2.knot2_opts - yield impl_msdns.msdns_group, impl_msdns.msdns_opts diff --git a/designate/api/__init__.py b/designate/api/__init__.py index 94ce519b0..e69de29bb 100644 --- a/designate/api/__init__.py +++ b/designate/api/__init__.py @@ -1,114 +0,0 @@ -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from oslo_config import cfg - - -api_group = cfg.OptGroup( - name='service:api', title="Configuration for API Service" -) - -api_opts = [ - cfg.IntOpt('workers', - help='Number of api worker processes to spawn'), - cfg.IntOpt('threads', default=1000, - help='Number of api greenthreads to spawn'), - cfg.BoolOpt('enable-host-header', default=False, - help='Enable host request headers'), - cfg.StrOpt('api-base-uri', default='http://127.0.0.1:9001/', - help='the url used as the base for all API responses,' - 'This should consist of the scheme (http/https),' - 'the hostname, port, and any paths that are added' - 'to the base of Designate is URLs,' - 'For example http://dns.openstack.example.com/dns'), - cfg.IPOpt('api_host', - deprecated_for_removal=True, - deprecated_reason="Replaced by 'listen' option", - help='API Bind Host'), - cfg.PortOpt('api_port', - deprecated_for_removal=True, - deprecated_reason="Replaced by 'listen' option", - help='API Port Number'), - cfg.ListOpt('listen', - default=['0.0.0.0:9001'], - help='API host:port pairs to listen on'), - cfg.StrOpt('api_paste_config', default='api-paste.ini', - help='File name for the paste.deploy config for designate-api'), - cfg.StrOpt('auth_strategy', default='keystone', - help='The strategy to use for auth. Supports noauth or ' - 'keystone'), - cfg.BoolOpt('enable-api-v2', default=True, - help='enable-api-v2 which enable in a future'), - cfg.BoolOpt('enable-api-admin', default=False, - help='enable-api-admin'), - cfg.IntOpt('max_header_line', default=16384, - help="Maximum line size of message headers to be accepted. " - "max_header_line may need to be increased when using " - "large tokens (typically those generated by the " - "Keystone v3 API with big service catalogs)."), -] - -api_v2_opts = [ - cfg.ListOpt('enabled-extensions-v2', default=[], - help='Enabled API Extensions for the V2 API'), - cfg.IntOpt('default-limit-v2', default=20, - help='Default per-page limit for the V2 API, a value of None ' - 'means show all results by default'), - cfg.IntOpt('max-limit-v2', default=1000, - help='Max per-page limit for the V2 API'), - cfg.BoolOpt('quotas-verify-project-id', default=False, - help='Verify that the requested Project ID for quota target ' - 'is a valid project in Keystone.'), -] - -api_admin_opts = [ - cfg.ListOpt('enabled-extensions-admin', default=[], - help='Enabled Admin API Extensions'), - cfg.IntOpt('default-limit-admin', default=20, - help='Default per-page limit for the Admin API, a value of None' - ' means show all results by default'), - cfg.IntOpt('max-limit-admin', default=1000, - help='Max per-page limit for the Admin API'), -] - -api_middleware_opts = [ - cfg.BoolOpt('maintenance-mode', default=False, - help='Enable API Maintenance Mode'), - cfg.StrOpt('maintenance-mode-role', default='admin', - help='Role allowed to bypass maintaince mode'), - cfg.StrOpt('secure-proxy-ssl-header', - default='X-Forwarded-Proto', - help="The HTTP Header that will be used to determine which " - "the original request protocol scheme was, even if it was " - "removed by an SSL terminating proxy."), - cfg.StrOpt('override-proto', - help="A scheme that will be used to override " - "the request protocol scheme, even if it was " - "set by an SSL terminating proxy.") -] - - -cfg.CONF.register_group(api_group) -cfg.CONF.register_opts(api_opts, group=api_group) -cfg.CONF.register_opts(api_v2_opts, group=api_group) -cfg.CONF.register_opts(api_admin_opts, group=api_group) -cfg.CONF.register_opts(api_middleware_opts, group=api_group) - - -def list_opts(): - yield api_group, api_opts - yield api_group, api_v2_opts - yield api_group, api_admin_opts - yield api_group, api_middleware_opts diff --git a/designate/backend/agent_backend/impl_bind9.py b/designate/backend/agent_backend/impl_bind9.py index a668810cc..d8cd5c261 100644 --- a/designate/backend/agent_backend/impl_bind9.py +++ b/designate/backend/agent_backend/impl_bind9.py @@ -22,43 +22,23 @@ from oslo_concurrency import lockutils from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate.backend.agent_backend import base from designate import exceptions from designate import utils +CFG_GROUP_NAME = 'backend:agent:bind9' LOG = logging.getLogger(__name__) -CFG_GROUP = 'backend:agent:bind9' - -"""GROUP = backend:agent:bind9""" -bind9_group = cfg.OptGroup( - name='backend:agent:bind9', title="Configuration for bind9 backend" -) - -bind9_opts = [ - cfg.StrOpt('rndc-host', default='127.0.0.1', help='RNDC Host'), - cfg.IntOpt('rndc-port', default=953, help='RNDC Port'), - cfg.StrOpt('rndc-config-file', - help='RNDC Config File'), - cfg.StrOpt('rndc-key-file', help='RNDC Key File'), - cfg.StrOpt('zone-file-path', default='$state_path/zones', - help='Path where zone files are stored'), - cfg.StrOpt('query-destination', default='127.0.0.1', - help='Host to query when finding zones') -] - - -cfg.CONF.register_group(bind9_group) -cfg.CONF.register_opts(bind9_opts, group=bind9_group) class Bind9Backend(base.AgentBackend): __plugin_name__ = 'bind9' - __backend_status__ = 'untested' @classmethod def get_cfg_opts(cls): - return [(bind9_group, bind9_opts)] + return [(designate.conf.bind9.BIND9_GROUP, + designate.conf.bind9.BINS9_OPTS)] def start(self): LOG.info("Started bind9 backend") @@ -66,7 +46,7 @@ class Bind9Backend(base.AgentBackend): def find_zone_serial(self, zone_name): LOG.debug("Finding %s", zone_name) resolver = dns.resolver.Resolver() - resolver.nameservers = [cfg.CONF[CFG_GROUP].query_destination] + resolver.nameservers = [cfg.CONF[CFG_GROUP_NAME].query_destination] try: rdata = resolver.query(zone_name, 'SOA')[0] except Exception: @@ -93,17 +73,17 @@ class Bind9Backend(base.AgentBackend): def _rndc_base(self): rndc_call = [ 'rndc', - '-s', cfg.CONF[CFG_GROUP].rndc_host, - '-p', str(cfg.CONF[CFG_GROUP].rndc_port), + '-s', cfg.CONF[CFG_GROUP_NAME].rndc_host, + '-p', str(cfg.CONF[CFG_GROUP_NAME].rndc_port), ] - if cfg.CONF[CFG_GROUP].rndc_config_file: + if cfg.CONF[CFG_GROUP_NAME].rndc_config_file: rndc_call.extend(['-c', - cfg.CONF[CFG_GROUP].rndc_config_file]) + cfg.CONF[CFG_GROUP_NAME].rndc_config_file]) - if cfg.CONF[CFG_GROUP].rndc_key_file: + if cfg.CONF[CFG_GROUP_NAME].rndc_key_file: rndc_call.extend(['-k', - cfg.CONF[CFG_GROUP].rndc_key_file]) + cfg.CONF[CFG_GROUP_NAME].rndc_key_file]) return rndc_call @@ -122,7 +102,7 @@ class Bind9Backend(base.AgentBackend): with lockutils.lock('bind9-%s' % zone_name): LOG.debug('Synchronising Zone: %s' % zone_name) - zone_path = cfg.CONF[CFG_GROUP].zone_file_path + zone_path = cfg.CONF[CFG_GROUP_NAME].zone_file_path output_path = os.path.join(zone_path, '%s.zone' % zone_name) diff --git a/designate/backend/agent_backend/impl_denominator.py b/designate/backend/agent_backend/impl_denominator.py index e6bee4801..2acc72fbc 100644 --- a/designate/backend/agent_backend/impl_denominator.py +++ b/designate/backend/agent_backend/impl_denominator.py @@ -23,28 +23,13 @@ from oslo_config import cfg from oslo_concurrency import lockutils from oslo_log import log as logging +import designate.conf from designate.backend.agent_backend import base from designate import exceptions from designate import utils +CFG_GROUP_NAME = 'backend:agent:denominator' LOG = logging.getLogger(__name__) -CFG_GROUP = 'backend:agent:denominator' - -"""GROUP = backend:agent:denominator""" -denominator_group = cfg.OptGroup( - name='backend:agent:denominator', - title='Backend options for Denominator', - ) - -denominator_opts = [ - cfg.StrOpt('name', default='fake', - help='Name of the affected provider'), - cfg.StrOpt('config_file', default='/etc/denominator.conf', - help='Path to Denominator configuration file') -] - -cfg.CONF.register_group(denominator_group) -cfg.CONF.register_opts(denominator_opts, group=denominator_group) class Denominator(object): @@ -109,11 +94,13 @@ class DenominatorBackend(base.AgentBackend): def __init__(self, agent_service): super(DenominatorBackend, self).__init__(agent_service) - self.denominator = Denominator(cfg.CONF[CFG_GROUP]) + self.denominator = Denominator( + cfg.CONF[CFG_GROUP_NAME]) @classmethod def get_cfg_opts(cls): - return [(denominator_group, denominator_opts)] + return [(designate.conf.denominator.DENOMINATOR_GROUP, + designate.conf.denominator.DENOMINATOR_OPTS)] def start(self): LOG.info("Started Denominator backend") diff --git a/designate/backend/agent_backend/impl_djbdns.py b/designate/backend/agent_backend/impl_djbdns.py index d74337d6e..7c95fd214 100755 --- a/designate/backend/agent_backend/impl_djbdns.py +++ b/designate/backend/agent_backend/impl_djbdns.py @@ -52,14 +52,14 @@ from oslo_concurrency.processutils import ProcessExecutionError from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import exceptions from designate import utils from designate.backend.agent_backend import base from designate.utils import execute - LOG = logging.getLogger(__name__) -CFG_GROUP = 'backend:agent:djbdns' +CFG_GROUP_NAME = 'backend:agent:djbdns' # rootwrap requires a command name instead of full path TCPCLIENT_DEFAULT_PATH = 'tcpclient' AXFR_GET_DEFAULT_PATH = 'axfr-get' @@ -68,39 +68,6 @@ TINYDNS_DATA_DEFAULT_PATH = 'tinydns-data' TINYDNS_DATADIR_DEFAULT_PATH = '/var/lib/djbdns' SOA_QUERY_TIMEOUT = 1 -"""GROUP = backend:agent:djbdns""" -djbdns_group = cfg.OptGroup( - name='backend:agent:djbdns', - title="Configuration for Djbdns backend" - ) -djbdns_opts = [ - cfg.StrOpt( - 'tcpclient-cmd-name', - help='tcpclient executable path or rootwrap command name', - default='tcpclient' - ), - cfg.StrOpt( - 'axfr-get-cmd-name', - help='axfr-get executable path or rootwrap command name', - default='axfr-get' - ), - cfg.StrOpt( - 'tinydns-data-cmd-name', - help='tinydns-data executable path or rootwrap command name', - default='tinydns-data' - ), - cfg.StrOpt( - 'tinydns-datadir', - help='TinyDNS data directory', - default='/var/lib/djbdns' - ), - cfg.StrOpt('query-destination', default='127.0.0.1', - help='Host to query when finding zones') -] - -cfg.CONF.register_group(djbdns_group) -cfg.CONF.register_opts(djbdns_opts, group=djbdns_group) - # TODO(Federico) on zone creation and update, agent.handler unnecessarily # perfors AXFR from MiniDNS to the Agent to populate the `zone` argument @@ -128,16 +95,18 @@ class DjbdnsBackend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - return [(djbdns_group, djbdns_opts)] + return [(designate.conf.djbdns.DJBDNS_GROUP, + designate.conf.djbdns.DJDNS_OPTS)] def __init__(self, *a, **kw): """Configure the backend""" super(DjbdnsBackend, self).__init__(*a, **kw) + conf = cfg.CONF[CFG_GROUP_NAME] self._resolver = dns.resolver.Resolver(configure=False) self._resolver.timeout = SOA_QUERY_TIMEOUT self._resolver.lifetime = SOA_QUERY_TIMEOUT - self._resolver.nameservers = [cfg.CONF[CFG_GROUP].query_destination] + self._resolver.nameservers = [conf.query_destination] self._masters = [utils.split_host_port(ns) for ns in cfg.CONF['service:agent'].masters] LOG.info("Resolvers: %r", self._resolver.nameservers) @@ -145,12 +114,11 @@ class DjbdnsBackend(base.AgentBackend): if not self._masters: raise exceptions.Backend("Missing agent AXFR masters") - self._tcpclient_cmd_name = cfg.CONF[CFG_GROUP].tcpclient_cmd_name - self._axfr_get_cmd_name = cfg.CONF[CFG_GROUP].axfr_get_cmd_name + self._tcpclient_cmd_name = conf.tcpclient_cmd_name + self._axfr_get_cmd_name = conf.axfr_get_cmd_name # Directory where data.cdb lives, usually /var/lib/djbdns/root - tinydns_root_dir = os.path.join(cfg.CONF[CFG_GROUP].tinydns_datadir, - 'root') + tinydns_root_dir = os.path.join(conf.tinydns_datadir, 'root') # Usually /var/lib/djbdns/root/data.cdb self._tinydns_cdb_filename = os.path.join(tinydns_root_dir, 'data.cdb') @@ -159,7 +127,7 @@ class DjbdnsBackend(base.AgentBackend): # Where the agent puts the zone datafiles, # usually /var/lib/djbdns/datafiles self._datafiles_dir = datafiles_dir = os.path.join( - cfg.CONF[CFG_GROUP].tinydns_datadir, + conf.tinydns_datadir, 'datafiles') self._datafiles_tmp_path_tpl = os.path.join(datafiles_dir, "%s.ztmp") self._datafiles_path_tpl = os.path.join(datafiles_dir, "%s.zonedata") @@ -229,7 +197,7 @@ class DjbdnsBackend(base.AgentBackend): LOG.debug("Convert %s to %s", data_fn, tmp_cdb_fn) try: out, err = execute( - cfg.CONF[CFG_GROUP].tinydns_data_cmd_name, + cfg.CONF[CFG_GROUP_NAME].tinydns_data_cmd_name, cwd=tmpdir ) except ProcessExecutionError as e: diff --git a/designate/backend/agent_backend/impl_gdnsd.py b/designate/backend/agent_backend/impl_gdnsd.py index ef992b675..b817668a1 100644 --- a/designate/backend/agent_backend/impl_gdnsd.py +++ b/designate/backend/agent_backend/impl_gdnsd.py @@ -50,12 +50,13 @@ from oslo_concurrency.processutils import ProcessExecutionError from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import utils from designate import exceptions from designate.backend.agent_backend import base +CFG_GROUP_NAME = 'backend:agent:gdnsd' LOG = logging.getLogger(__name__) -CFG_GROUP = 'backend:agent:gdnsd' # rootwrap requires a command name instead of full path GDNSD_DEFAULT_PATH = 'gdnsd' CONFDIR_PATH = '/etc/gdnsd' @@ -63,25 +64,6 @@ SOA_QUERY_TIMEOUT = 1 ZONE_FILE_PERMISSIONS = 0o0644 -"""GROUP = backend:agent:gdnsd""" -gdnsd_group = cfg.OptGroup( - name='backend:agent:gdnsd', title="Configuration for gdnsd backend" - ) -gdnsd_opts = [ - cfg.StrOpt('gdnsd-cmd-name', - help='gdnsd executable path or rootwrap command name', - default='gdnsd'), - cfg.StrOpt('confdir-path', - help='gdnsd configuration directory path', - default='/etc/gdnsd'), - cfg.StrOpt('query-destination', default='127.0.0.1', - help='Host to query when finding zones') -] - -cfg.CONF.register_group(gdnsd_group) -cfg.CONF.register_opts(gdnsd_opts, group=gdnsd_group) - - def filter_exceptions(fn): # Let Backend() exceptions pass through, log out every other exception # and re-raise it as Backend() @@ -103,21 +85,24 @@ class GdnsdBackend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - return [(gdnsd_group, gdnsd_opts)] + return [(designate.conf.gdnsd.GDNSD_GROUP, + designate.conf.gdnsd.GDNSD_OPTS)] def __init__(self, *a, **kw): """Configure the backend""" super(GdnsdBackend, self).__init__(*a, **kw) - self._gdnsd_cmd_name = cfg.CONF[CFG_GROUP].gdnsd_cmd_name + self._gdnsd_cmd_name = cfg.CONF[CFG_GROUP_NAME].gdnsd_cmd_name LOG.info("gdnsd command: %r", self._gdnsd_cmd_name) - self._confdir_path = cfg.CONF[CFG_GROUP].confdir_path + self._confdir_path = cfg.CONF[CFG_GROUP_NAME].confdir_path self._zonedir_path = os.path.join(self._confdir_path, 'zones') LOG.info("gdnsd conf directory: %r", self._confdir_path) self._resolver = dns.resolver.Resolver(configure=False) self._resolver.timeout = SOA_QUERY_TIMEOUT self._resolver.lifetime = SOA_QUERY_TIMEOUT - self._resolver.nameservers = [cfg.CONF[CFG_GROUP].query_destination] + self._resolver.nameservers = [ + cfg.CONF[CFG_GROUP_NAME].query_destination + ] LOG.info("Resolvers: %r", self._resolver.nameservers) self._check_dirs(self._zonedir_path) @@ -134,7 +119,7 @@ class GdnsdBackend(base.AgentBackend): """ try: out, err = utils.execute( - cfg.CONF[CFG_GROUP].gdnsd_cmd_name, + cfg.CONF[CFG_GROUP_NAME].gdnsd_cmd_name, '-D', '-x', 'checkconf', '-c', self._confdir_path, run_as_root=False, ) diff --git a/designate/backend/agent_backend/impl_knot2.py b/designate/backend/agent_backend/impl_knot2.py index 08fa49c5d..d1c494b9a 100755 --- a/designate/backend/agent_backend/impl_knot2.py +++ b/designate/backend/agent_backend/impl_knot2.py @@ -44,13 +44,13 @@ from oslo_concurrency.processutils import ProcessExecutionError from oslo_config import cfg from oslo_log import log as logging +import designate.conf from designate import exceptions from designate.backend.agent_backend import base from designate.utils import execute - +CFG_GROUP_NAME = 'backend:agent:knot2' LOG = logging.getLogger(__name__) -CFG_GROUP = 'backend:agent:knot2' # rootwrap requires a command name instead of full path KNOTC_DEFAULT_PATH = 'knotc' @@ -58,30 +58,6 @@ KNOTC_DEFAULT_PATH = 'knotc' # perfors AXFR from MiniDNS to the Agent to populate the `zone` argument # (needed by the Bind backend) -"""GROUP = backend:agent:knot2""" -knot2_group = cfg.OptGroup( - name='backend:agent:knot2', title="Configuration for Knot2 backend" - ) -knot2_opts = [ - cfg.StrOpt('knotc-cmd-name', - help='knotc executable path or rootwrap command name', - default='knotc'), - cfg.StrOpt('query-destination', default='127.0.0.1', - help='Host to query when finding zones') -] - -"""GROUP = backend:agent:msdns""" -msdns_group = cfg.OptGroup( - name='backend:agent:msdns', - title="Configuration for Microsoft DNS Server" -) -msdns_opts = [ - -] - -cfg.CONF.register_group(knot2_group) -cfg.CONF.register_opts(knot2_opts, group=knot2_group) - class Knot2Backend(base.AgentBackend): __plugin_name__ = 'knot2' @@ -90,13 +66,14 @@ class Knot2Backend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - return [(knot2_group, knot2_opts)] + return [(designate.conf.knot2.KNOT2_GROUP, + designate.conf.knot2.KNOT2_OPTS)] def __init__(self, *a, **kw): """Configure the backend""" super(Knot2Backend, self).__init__(*a, **kw) - self._knotc_cmd_name = cfg.CONF[CFG_GROUP].knotc_cmd_name + self._knotc_cmd_name = cfg.CONF[CFG_GROUP_NAME].knotc_cmd_name def start(self): """Start the backend""" diff --git a/designate/backend/agent_backend/impl_msdns.py b/designate/backend/agent_backend/impl_msdns.py index e9ef8a37b..cd25c3bd1 100644 --- a/designate/backend/agent_backend/impl_msdns.py +++ b/designate/backend/agent_backend/impl_msdns.py @@ -22,23 +22,11 @@ from os_win import utilsfactory from os_win import constants from os_win import exceptions as os_win_exc +import designate.conf from designate.backend.agent_backend import base from designate import exceptions LOG = logging.getLogger(__name__) -CFG_GROUP = 'backend:agent:msdns' - -"""GROUP = backend:agent:msdns""" -msdns_group = cfg.OptGroup( - name='backend:agent:msdns', - title="Configuration for Microsoft DNS Server" -) -msdns_opts = [ - -] - -cfg.CONF.register_group(msdns_group) -cfg.CONF.register_opts(msdns_opts, group=msdns_group) class MSDNSBackend(base.AgentBackend): @@ -62,7 +50,8 @@ class MSDNSBackend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - return [(msdns_group, msdns_opts)] + return [(designate.conf.msdns.MSDNS_GROUP, + designate.conf.msdns.MSDNS_OPTS)] def start(self): """Start the backend""" diff --git a/designate/backend/impl_akamai.py b/designate/backend/impl_akamai.py index 8429fab32..56673e837 100644 --- a/designate/backend/impl_akamai.py +++ b/designate/backend/impl_akamai.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. -import os - from oslo_log import log as logging from oslo_config import cfg from oslo_utils import importutils +import designate.conf from designate import exceptions from designate import utils from designate.backend import base @@ -39,12 +38,6 @@ except ImportError: LOG = logging.getLogger(__name__) CONF = cfg.CONF -WSDL = os.path.join(os.path.dirname(__file__), - '..', - 'resources', - 'wsdl', - 'EnhancedDNS.xml') - class EnhancedDNSException(exceptions.Backend): pass @@ -245,17 +238,8 @@ class AkamaiBackend(base.Backend): @classmethod def get_cfg_opts(cls): - group = cfg.OptGroup( - name='backend:akamai', title='Backend options for Akamai' - ) - - opts = [ - cfg.StrOpt('enhanceddns_wsdl', - default='file://%s' % WSDL, - help='Akamai EnhancedDNS WSDL URL'), - ] - - return [(group, opts)] + return [(designate.conf.akamai.AKAMAI_GROUP, + designate.conf.akamai.AKAMAI_OPTS)] def __init__(self, target): super(AkamaiBackend, self).__init__(target) diff --git a/designate/backend/impl_designate.py b/designate/backend/impl_designate.py index 3f54698fe..ab5290a4d 100644 --- a/designate/backend/impl_designate.py +++ b/designate/backend/impl_designate.py @@ -24,7 +24,7 @@ from designate.backend import base LOG = logging.getLogger(__name__) -CFG_GROUP = 'backend:designate' +CFG_GROUP_NAME = 'backend:designate' class DesignateBackend(base.Backend): diff --git a/designate/backend/impl_dynect.py b/designate/backend/impl_dynect.py index 2b442854d..b405bab99 100755 --- a/designate/backend/impl_dynect.py +++ b/designate/backend/impl_dynect.py @@ -22,13 +22,14 @@ from oslo_serialization import jsonutils import requests from requests.adapters import HTTPAdapter +import designate.conf from designate import exceptions from designate import utils from designate.backend import base LOG = logging.getLogger(__name__) CONF = cfg.CONF -CFG_GROUP = 'backend:dynect' +CFG_GROUP_NAME = 'backend:dynect' class DynClientError(exceptions.Backend): @@ -223,7 +224,7 @@ class DynClient(object): """ status = response.status - timeout = Timeout(CONF[CFG_GROUP].job_timeout) + timeout = Timeout(CONF[CFG_GROUP_NAME].job_timeout) try: while status == 307: time.sleep(1) @@ -304,20 +305,8 @@ class DynECTBackend(base.Backend): @classmethod def get_cfg_opts(cls): - group = cfg.OptGroup( - name=CFG_GROUP, title='Backend options for DynECT' - ) - - opts = [ - cfg.IntOpt('job_timeout', default=30, - help="Timeout in seconds for pulling a job in DynECT."), - cfg.IntOpt('timeout', help="Timeout in seconds for API Requests.", - default=10), - cfg.BoolOpt('timings', help="Measure requests timings.", - default=False), - ] - - return [(group, opts)] + return [(designate.conf.dynect.DYNECT_GROUP, + designate.conf.dynect.DYNECT_OPTS)] def __init__(self, target): super(DynECTBackend, self).__init__(target) @@ -338,8 +327,8 @@ class DynECTBackend(base.Backend): customer_name=self.customer_name, user_name=self.username, password=self.password, - timeout=CONF[CFG_GROUP].timeout, - timings=CONF[CFG_GROUP].timings) + timeout=CONF[CFG_GROUP_NAME].timeout, + timings=CONF[CFG_GROUP_NAME].timings) def create_zone(self, context, zone): LOG.info('Creating zone %(d_id)s / %(d_name)s', diff --git a/designate/backend/impl_infoblox/connector.py b/designate/backend/impl_infoblox/connector.py index 2f51f0a68..67cdb47ed 100644 --- a/designate/backend/impl_infoblox/connector.py +++ b/designate/backend/impl_infoblox/connector.py @@ -12,17 +12,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 from oslo_log import log from oslo_serialization import jsonutils from oslo_utils import strutils from six.moves.urllib import parse import requests -from designate.backend.impl_infoblox.config import cfg from designate.backend.impl_infoblox import ibexceptions as exc - +CFG_GROUP_NAME = 'backend:infoblox' +CONF = cfg.CONF LOG = log.getLogger(__name__) @@ -39,8 +39,7 @@ class Infoblox(object): Args: options (dict): Target options dictionary """ - - config = cfg.CONF['backend:infoblox'] + config = CONF[CFG_GROUP_NAME] reqd_opts = ['wapi_url', 'username', 'password', 'ns_group'] other_opts = ['sslverify', 'network_view', 'dns_view', 'multi_tenant'] diff --git a/designate/backend/impl_powerdns/__init__.py b/designate/backend/impl_powerdns/__init__.py index 321cb1c7a..6a52922e1 100644 --- a/designate/backend/impl_powerdns/__init__.py +++ b/designate/backend/impl_powerdns/__init__.py @@ -29,6 +29,7 @@ from designate.backend import base from designate.backend.impl_powerdns import tables from designate.sqlalchemy import session +CFG_GROUP_NAME = 'backend:powerdns' LOG = logging.getLogger(__name__) @@ -43,7 +44,7 @@ class PowerDNSBackend(base.Backend): @classmethod def get_cfg_opts(cls): - group = cfg.OptGroup('backend:powerdns') + group = cfg.OptGroup(CFG_GROUP_NAME) opts = copy.deepcopy(options.database_opts) # Strip connection options diff --git a/designate/central/__init__.py b/designate/central/__init__.py index 801cd516a..e69de29bb 100644 --- a/designate/central/__init__.py +++ b/designate/central/__init__.py @@ -1,56 +0,0 @@ -# Copyright 2012 Hewlett-Packard Development Company, L.P. All Rights Reserved. -# -# Author: Kiall Mac Innes -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from oslo_config import cfg - -central_group = cfg.OptGroup( - name='service:central', title="Configuration for Central Service" -) - -OPTS = [ - cfg.IntOpt('workers', - help='Number of central worker processes to spawn'), - cfg.IntOpt('threads', default=1000, - help='Number of central greenthreads to spawn'), - cfg.StrOpt('storage-driver', default='sqlalchemy', - help='The storage driver to use'), - cfg.ListOpt('enabled-notification-handlers', default=[], - help='Enabled Notification Handlers'), - cfg.IntOpt('max_zone_name_len', default=255, - help="Maximum zone name length"), - cfg.IntOpt('max_recordset_name_len', default=255, - help="Maximum recordset name length", - deprecated_name='max_record_name_len'), - cfg.StrOpt('managed_resource_email', default='hostmaster@example.com', - help='E-Mail for Managed resources'), - cfg.StrOpt('managed_resource_tenant_id', - default="00000000-0000-0000-0000-000000000000", - help="The Tenant ID that will own any managed resources."), - cfg.IntOpt('min_ttl', help="Minimum TTL allowed"), - # TODO(betsy): Move to Pool Service once that is written - cfg.StrOpt('default_pool_id', - default='794ccc2c-d751-44fe-b57f-8894c9f5c842', - help="The name of the default pool"), - cfg.StrOpt('central_topic', - default='central', - help="RPC topic name of central service."), -] - -cfg.CONF.register_group(central_group) -cfg.CONF.register_opts(OPTS, group=central_group) - - -def list_opts(): - yield central_group, OPTS diff --git a/designate/cmd/agent.py b/designate/cmd/agent.py index eb8eec2ff..ffe0c775e 100644 --- a/designate/cmd/agent.py +++ b/designate/cmd/agent.py @@ -15,10 +15,10 @@ # 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 +import designate.conf from designate import hookpoints from designate import service from designate import utils @@ -26,7 +26,7 @@ from designate import version from designate.agent import service as agent_service -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.agent', group='service:agent') CONF.import_opt('threads', 'designate.agent', group='service:agent') diff --git a/designate/cmd/api.py b/designate/cmd/api.py index bf4b103c7..a4e83251f 100644 --- a/designate/cmd/api.py +++ b/designate/cmd/api.py @@ -19,7 +19,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr -from designate.common import keystone +import designate.conf from designate import hookpoints from designate import service from designate import utils @@ -27,11 +27,10 @@ from designate import version from designate.api import service as api_service -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.api', group='service:api') CONF.import_opt('threads', 'designate.api', group='service:api') cfg.CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token') -keystone.register_keystone_opts(CONF) def main(): diff --git a/designate/cmd/central.py b/designate/cmd/central.py index 01e9c741d..5364e3544 100644 --- a/designate/cmd/central.py +++ b/designate/cmd/central.py @@ -15,10 +15,10 @@ # 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 +import designate.conf from designate import hookpoints from designate import service from designate import utils @@ -26,7 +26,7 @@ from designate import version from designate.central import service as central -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.central', group='service:central') CONF.import_opt('threads', 'designate.central', group='service:central') diff --git a/designate/cmd/manage.py b/designate/cmd/manage.py index da9470b67..a2befdc08 100644 --- a/designate/cmd/manage.py +++ b/designate/cmd/manage.py @@ -23,14 +23,14 @@ from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr from stevedore.extension import ExtensionManager +import designate.conf from designate import hookpoints from designate import utils from designate import version eventlet.monkey_patch(os=False) - -CONF = cfg.CONF +CONF = designate.conf.CONF def methods_of(obj): diff --git a/designate/cmd/mdns.py b/designate/cmd/mdns.py index 9568664b1..66dd98705 100644 --- a/designate/cmd/mdns.py +++ b/designate/cmd/mdns.py @@ -15,10 +15,10 @@ # 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 +import designate.conf from designate import hookpoints from designate import service from designate import utils @@ -26,7 +26,7 @@ from designate import version from designate.mdns import service as mdns_service -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.mdns', group='service:mdns') CONF.import_opt('threads', 'designate.mdns', group='service:mdns') diff --git a/designate/cmd/pool_manager.py b/designate/cmd/pool_manager.py index 2e61ff9ef..686541ba9 100644 --- a/designate/cmd/pool_manager.py +++ b/designate/cmd/pool_manager.py @@ -15,11 +15,11 @@ # 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 import debtcollector +import designate.conf from designate import service from designate import utils from designate import version @@ -27,7 +27,7 @@ from designate import hookpoints from designate.pool_manager import service as pool_manager_service LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.pool_manager', group='service:pool_manager') CONF.import_opt('threads', 'designate.pool_manager', @@ -42,7 +42,7 @@ def main(): # NOTE(timsim): This is to ensure people don't start the wrong # services when the worker model is enabled. - if cfg.CONF['service:worker'].enabled: + if CONF['service:worker'].enabled: LOG.error('You have designate-worker enabled, starting ' 'designate-pool-manager is incompatible with ' 'designate-worker. You need to start ' diff --git a/designate/cmd/producer.py b/designate/cmd/producer.py index d67e76d59..9b16a735a 100644 --- a/designate/cmd/producer.py +++ b/designate/cmd/producer.py @@ -15,10 +15,10 @@ # 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 +import designate.conf from designate import hookpoints from designate import service from designate import utils @@ -26,7 +26,7 @@ from designate import version from designate.producer import service as producer_service LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.producer', group='service:producer') CONF.import_opt('threads', 'designate.producer', group='service:producer') @@ -38,7 +38,7 @@ def main(): # NOTE(timsim): This is to ensure people don't start the wrong # services when the worker model is enabled. - if not cfg.CONF['service:worker'].enabled: + if not CONF['service:worker'].enabled: LOG.error('You do not have designate-worker enabled, starting ' 'designate-producer is not allowed. ' 'You need to start designate-zone-manager instead.') diff --git a/designate/cmd/sink.py b/designate/cmd/sink.py index bca9c0590..4081e1462 100644 --- a/designate/cmd/sink.py +++ b/designate/cmd/sink.py @@ -15,10 +15,10 @@ # 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 +import designate.conf from designate import hookpoints from designate import service from designate import utils @@ -26,7 +26,7 @@ from designate import version from designate.sink import service as sink_service -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.sink', group='service:sink') CONF.import_opt('threads', 'designate.sink', group='service:sink') diff --git a/designate/cmd/status.py b/designate/cmd/status.py index a9c93eb86..1b32d51be 100644 --- a/designate/cmd/status.py +++ b/designate/cmd/status.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_upgradecheck import upgradecheck from sqlalchemy import MetaData, Table, select, func +import designate.conf from designate.i18n import _ from designate.sqlalchemy import session # This import is not used, but is needed to register the storage:sqlalchemy @@ -50,7 +50,7 @@ def main(): config_files = utils.find_config('designate.conf') checker = Checks() return upgradecheck.main( - conf=cfg.CONF, + conf=designate.conf.CONF, project='designate', upgrade_command=checker, default_config_files=config_files, diff --git a/designate/cmd/worker.py b/designate/cmd/worker.py index 797d58c01..48a239387 100644 --- a/designate/cmd/worker.py +++ b/designate/cmd/worker.py @@ -15,10 +15,10 @@ # 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 +import designate.conf from designate import hookpoints from designate import service from designate import utils @@ -26,7 +26,7 @@ from designate import version from designate.worker import service as worker_service LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.worker', group='service:worker') CONF.import_opt('threads', 'designate.worker', group='service:worker') @@ -38,7 +38,7 @@ def main(): # NOTE(timsim): This is to ensure people don't start the wrong # services when the worker model is enabled. - if not cfg.CONF['service:worker'].enabled: + if not CONF['service:worker'].enabled: LOG.error('You do not have designate-worker enabled, starting ' 'designate-worker is not allowed. ' 'You need to start designate-pool-manager instead.') diff --git a/designate/cmd/zone_manager.py b/designate/cmd/zone_manager.py index e253642ba..327cd6d90 100644 --- a/designate/cmd/zone_manager.py +++ b/designate/cmd/zone_manager.py @@ -15,11 +15,11 @@ # 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 import debtcollector +import designate.conf from designate import service from designate import utils from designate import version @@ -27,7 +27,7 @@ from designate.producer import service as producer_service LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = designate.conf.CONF CONF.import_opt('workers', 'designate.producer', group='service:zone_manager') CONF.import_opt('threads', 'designate.producer', @@ -42,7 +42,7 @@ def main(): # NOTE(timsim): This is to ensure people don't start the wrong # services when the worker model is enabled. - if cfg.CONF['service:worker'].enabled: + if CONF['service:worker'].enabled: LOG.error('You have designate-worker enabled, starting ' 'designate-zone-manager is incompatible with ' 'designate-worker. You need to start ' diff --git a/designate/common/keystone.py b/designate/common/keystone.py index e7ca03617..41d7ec5a1 100644 --- a/designate/common/keystone.py +++ b/designate/common/keystone.py @@ -23,22 +23,6 @@ from designate.i18n import _ CONF = cfg.CONF LOG = logging.getLogger(__name__) -keystone_group = cfg.OptGroup( - name='keystone', title='Access to Keystone API') - - -def register_keystone_opts(conf): - conf.register_group(keystone_group) - ksa_loading.register_adapter_conf_options(conf, keystone_group) - ksa_loading.register_session_conf_options(conf, keystone_group) - conf.set_default('service_type', 'identity', group=keystone_group) - - -def list_opts(): - opts = ksa_loading.get_adapter_conf_options() - opts.extend(ksa_loading.get_session_conf_options()) - return opts - def verify_project_id(context, project_id): """verify that a project_id exists. diff --git a/designate/common/memorycache.py b/designate/common/memorycache.py index e72c26df1..2b0a97148 100644 --- a/designate/common/memorycache.py +++ b/designate/common/memorycache.py @@ -16,23 +16,10 @@ """Super simple fake memcache client.""" -import copy - from oslo_config import cfg from oslo_utils import timeutils -memcache_opts = [ - cfg.ListOpt('memcached_servers', - help='Memcached servers or None for in process cache.'), -] - CONF = cfg.CONF -CONF.register_opts(memcache_opts) - - -def list_opts(): - """Entry point for oslo-config-generator.""" - return [(None, copy.deepcopy(memcache_opts))] def get_client(memcached_servers=None): diff --git a/designate/conf/__init__.py b/designate/conf/__init__.py new file mode 100644 index 000000000..063889e10 --- /dev/null +++ b/designate/conf/__init__.py @@ -0,0 +1,71 @@ +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_config import cfg + +CONF = cfg.CONF + +from designate.conf import base # noqa + +base.register_opts(CONF) # noqa + +from designate.conf import akamai +from designate.conf import agent +from designate.conf import api +from designate.conf import bind9 +from designate.conf import central +from designate.conf import coordination +from designate.conf import denominator +from designate.conf import djbdns +from designate.conf import dynect +from designate.conf import gdnsd +from designate.conf import infoblox +from designate.conf import keystone +from designate.conf import knot2 +from designate.conf import mdns +from designate.conf import metrics +from designate.conf import msdns +from designate.conf import network_api +from designate.conf import pool_manager +from designate.conf import producer +from designate.conf import proxy +from designate.conf import service_status +from designate.conf import sink +from designate.conf import storage +from designate.conf import worker + +akamai.register_opts(CONF) +agent.register_opts(CONF) +api.register_opts(CONF) +bind9.register_opts(CONF) +central.register_opts(CONF) +coordination.register_opts(CONF) +denominator.register_opts(CONF) +djbdns.register_opts(CONF) +dynect.register_opts(CONF) +gdnsd.register_opts(CONF) +infoblox.register_opts(CONF) +keystone.register_opts(CONF) +knot2.register_opts(CONF) +mdns.register_opts(CONF) +metrics.register_opts(CONF) +msdns.register_opts(CONF) +network_api.register_opts(CONF) +pool_manager.register_opts(CONF) +producer.register_opts(CONF) +proxy.register_opts(CONF) +service_status.register_opts(CONF) +sink.register_opts(CONF) +storage.register_opts(CONF) +worker.register_opts(CONF) diff --git a/designate/conf/agent.py b/designate/conf/agent.py new file mode 100644 index 000000000..ee0a74ad0 --- /dev/null +++ b/designate/conf/agent.py @@ -0,0 +1,67 @@ +# Copyright 2014 Rackspace Inc. +# +# Author: Tim Simmons +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +from designate.utils import DEFAULT_AGENT_PORT + +AGENT_GROUP = cfg.OptGroup( + name='service:agent', + title="Configuration for the Agent Service" +) + +AGENT_OPTS = [ + cfg.IntOpt('workers', + help='Number of agent worker processes to spawn'), + cfg.IntOpt('threads', default=1000, + help='Number of agent greenthreads to spawn'), + cfg.IPOpt('host', + deprecated_for_removal=True, + deprecated_reason="Replaced by 'listen' option", + help='Agent Bind Host'), + cfg.PortOpt('port', + deprecated_for_removal=True, + deprecated_reason="Replaced by 'listen' option", + help='Agent Port Number'), + cfg.ListOpt('listen', + default=['0.0.0.0:%d' % DEFAULT_AGENT_PORT], + help='Agent host:port pairs to listen on'), + cfg.IntOpt('tcp-backlog', default=100, + help='The Agent TCP Backlog'), + cfg.FloatOpt('tcp-recv-timeout', default=0.5, + help='Agent TCP Receive Timeout'), + cfg.ListOpt('allow-notify', default=[], + help='List of IP addresses allowed to NOTIFY The Agent'), + cfg.ListOpt('masters', default=[], + help='List of masters for the Agent, format ip:port'), + cfg.StrOpt('backend-driver', default='bind9', + help='The backend driver to use, e.g. bind9, djbdns, knot2'), + cfg.StrOpt('transfer-source', + help='An IP address to be used to fetch zones transferred in'), + cfg.FloatOpt('notify-delay', default=0.0, + help='Delay after a NOTIFY arrives for a zone that the Agent ' + 'will pause and drop subsequent NOTIFYs for that zone'), +] + + +def register_opts(conf): + conf.register_group(AGENT_GROUP) + conf.register_opts(AGENT_OPTS, group=AGENT_GROUP) + + +def list_opts(): + return { + AGENT_GROUP: AGENT_OPTS + } diff --git a/designate/conf/akamai.py b/designate/conf/akamai.py new file mode 100644 index 000000000..8cd55d52a --- /dev/null +++ b/designate/conf/akamai.py @@ -0,0 +1,46 @@ +# Copyright 2012-2015 Hewlett-Packard Development Company, L.P. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +import os + +from oslo_config import cfg + +WSDL = os.path.join(os.path.dirname(__file__), + '..', + 'resources', + 'wsdl', + 'EnhancedDNS.xml') + +AKAMAI_GROUP = cfg.OptGroup( + name='backend:akamai', + title='Backend options for Akamai' +) + +AKAMAI_OPTS = [ + cfg.StrOpt('enhanceddns_wsdl', + default='file://%s' % WSDL, + help='Akamai EnhancedDNS WSDL URL'), +] + + +def register_opts(conf): + conf.register_group(AKAMAI_GROUP) + conf.register_opts(AKAMAI_OPTS, group=AKAMAI_GROUP) + + +def list_opts(): + return { + AKAMAI_GROUP: AKAMAI_OPTS, + } diff --git a/designate/conf/api.py b/designate/conf/api.py new file mode 100644 index 000000000..0b71ae4d2 --- /dev/null +++ b/designate/conf/api.py @@ -0,0 +1,117 @@ +# Copyright 2012 Managed I.T. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +API_GROUP = cfg.OptGroup( + name='service:api', + title="Configuration for API Service" +) + +API_OPTS = [ + cfg.IntOpt('workers', + help='Number of api worker processes to spawn'), + cfg.IntOpt('threads', default=1000, + help='Number of api greenthreads to spawn'), + cfg.BoolOpt('enable-host-header', default=False, + help='Enable host request headers'), + cfg.StrOpt('api-base-uri', default='http://127.0.0.1:9001/', + help='the url used as the base for all API responses,' + 'This should consist of the scheme (http/https),' + 'the hostname, port, and any paths that are added' + 'to the base of Designate is URLs,' + 'For example http://dns.openstack.example.com/dns'), + cfg.IPOpt('api_host', + deprecated_for_removal=True, + deprecated_reason="Replaced by 'listen' option", + help='API Bind Host'), + cfg.PortOpt('api_port', + deprecated_for_removal=True, + deprecated_reason="Replaced by 'listen' option", + help='API Port Number'), + cfg.ListOpt('listen', + default=['0.0.0.0:9001'], + help='API host:port pairs to listen on'), + cfg.StrOpt('api_paste_config', default='api-paste.ini', + help='File name for the paste.deploy config for designate-api'), + cfg.StrOpt('auth_strategy', default='keystone', + help='The strategy to use for auth. Supports noauth or ' + 'keystone'), + cfg.BoolOpt('enable-api-v2', default=True, + help='enable-api-v2 which enable in a future'), + cfg.BoolOpt('enable-api-admin', default=False, + help='enable-api-admin'), + cfg.IntOpt('max_header_line', default=16384, + help="Maximum line size of message headers to be accepted. " + "max_header_line may need to be increased when using " + "large tokens (typically those generated by the " + "Keystone v3 API with big service catalogs)."), +] + +APT_V2_OPTS = [ + cfg.ListOpt('enabled-extensions-v2', default=[], + help='Enabled API Extensions for the V2 API'), + cfg.IntOpt('default-limit-v2', default=20, + help='Default per-page limit for the V2 API, a value of None ' + 'means show all results by default'), + cfg.IntOpt('max-limit-v2', default=1000, + help='Max per-page limit for the V2 API'), + cfg.BoolOpt('quotas-verify-project-id', default=False, + help='Verify that the requested Project ID for quota target ' + 'is a valid project in Keystone.'), +] + +API_ADMIN_OPTS = [ + cfg.ListOpt('enabled-extensions-admin', default=[], + help='Enabled Admin API Extensions'), + cfg.IntOpt('default-limit-admin', default=20, + help='Default per-page limit for the Admin API, a value of None' + ' means show all results by default'), + cfg.IntOpt('max-limit-admin', default=1000, + help='Max per-page limit for the Admin API'), +] + +API_MIDDLEWARE_OPTS = [ + cfg.BoolOpt('maintenance-mode', default=False, + help='Enable API Maintenance Mode'), + cfg.StrOpt('maintenance-mode-role', default='admin', + help='Role allowed to bypass maintaince mode'), + cfg.StrOpt('secure-proxy-ssl-header', + default='X-Forwarded-Proto', + help="The HTTP Header that will be used to determine which " + "the original request protocol scheme was, even if it was " + "removed by an SSL terminating proxy."), + cfg.StrOpt('override-proto', + help="A scheme that will be used to override " + "the request protocol scheme, even if it was " + "set by an SSL terminating proxy."), +] + + +def register_opts(conf): + conf.register_group(API_GROUP) + conf.register_opts(API_OPTS, group=API_GROUP) + conf.register_opts(APT_V2_OPTS, group=API_GROUP) + conf.register_opts(API_ADMIN_OPTS, group=API_GROUP) + conf.register_opts(API_MIDDLEWARE_OPTS, group=API_GROUP) + + +def list_opts(): + return { + API_GROUP: (API_OPTS + + APT_V2_OPTS + + API_ADMIN_OPTS + + API_MIDDLEWARE_OPTS) + } diff --git a/designate/conf/base.py b/designate/conf/base.py new file mode 100644 index 000000000..d5cef14ae --- /dev/null +++ b/designate/conf/base.py @@ -0,0 +1,113 @@ +# Copyright 2012 Managed I.T. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +import socket + +from oslo_config import cfg + +import designate + +DESIGNATE_OPTS = [ + cfg.StrOpt('host', default=socket.gethostname(), + sample_default='current_hostname', + help='Name of this node'), + cfg.StrOpt( + 'pybasedir', + sample_default='', + default=designate.BASE_PATH, + help='Directory where the designate python module is installed' + ), + cfg.StrOpt('state-path', default='/var/lib/designate', + help='Top-level directory for maintaining designate\'s state'), + + cfg.ListOpt( + 'allowed_remote_exmods', + default=[], + help="Additional modules that contains allowed RPC exceptions.", + deprecated_name='allowed_rpc_exception_modules'), + + cfg.StrOpt('central-topic', default='central', help='Central Topic'), + cfg.StrOpt('mdns-topic', default='mdns', help='mDNS Topic'), + cfg.StrOpt('pool-manager-topic', default='pool_manager', + help='Pool Manager Topic'), + cfg.StrOpt('worker-topic', default='worker', help='Worker Topic'), + + # Default TTL + cfg.IntOpt('default-ttl', default=3600, help='TTL Value'), + + # Default SOA Values + cfg.IntOpt('default-soa-refresh-min', default=3500, + deprecated_name='default-soa-refresh', + help='SOA refresh-min value'), + cfg.IntOpt('default-soa-refresh-max', default=3600, + help='SOA max value'), + cfg.IntOpt('default-soa-retry', default=600, help='SOA retry'), + cfg.IntOpt('default-soa-expire', default=86400, help='SOA expire'), + cfg.IntOpt('default-soa-minimum', default=3600, help='SOA minimum value'), + + # Supported record types + cfg.ListOpt('supported-record-type', help='Supported record types', + default=['A', 'AAAA', 'CNAME', 'MX', 'SRV', 'TXT', 'SPF', 'NS', + 'PTR', 'SSHFP', 'SOA', 'NAPTR', 'CAA']), + + # TCP Settings + cfg.IntOpt('backlog', + default=4096, + help="Number of backlog requests to configure the socket with"), + cfg.IntOpt('tcp_keepidle', + default=600, + help="Sets the value of TCP_KEEPIDLE in seconds for each " + "server socket. Not supported on OS X."), + + # Root Helper + cfg.StrOpt('root-helper', + default='sudo designate-rootwrap /etc/designate/rootwrap.conf', + help='designate-rootwrap configuration'), + + # Memcached + cfg.ListOpt('memcached_servers', + help='Memcached servers or None for in process cache.'), + + cfg.StrOpt('network_api', default='neutron', help='Which API to use.'), + + # Notifications + cfg.BoolOpt('notify_api_faults', default=False, + help='Send notifications if there\'s a failure in the API.'), + cfg.StrOpt('notification-plugin', default='default', + help='The notification plugin to use'), + + # Quota + cfg.StrOpt('quota-driver', default='storage', help='Quota driver to use'), + cfg.IntOpt('quota-zones', default=10, + help='Number of zones allowed per tenant'), + cfg.IntOpt('quota-zone-recordsets', default=500, + help='Number of recordsets allowed per zone'), + cfg.IntOpt('quota-zone-records', default=500, + help='Number of records allowed per zone'), + cfg.IntOpt('quota-recordset-records', default=20, + help='Number of records allowed per recordset'), + cfg.IntOpt('quota-api-export-size', default=1000, + help='Number of recordsets allowed in a zone export'), +] + + +def register_opts(conf): + conf.register_opts(DESIGNATE_OPTS) + + +def list_opts(): + return { + 'DEFAULT': DESIGNATE_OPTS + } diff --git a/designate/conf/bind9.py b/designate/conf/bind9.py new file mode 100644 index 000000000..c8a831076 --- /dev/null +++ b/designate/conf/bind9.py @@ -0,0 +1,44 @@ +# Copyright 2014 Rackspace Inc. +# +# Author: Tim Simmons +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +BIND9_GROUP = cfg.OptGroup( + name='backend:agent:bind9', + title="Configuration for bind9 backend" +) + +BINS9_OPTS = [ + cfg.StrOpt('rndc-host', default='127.0.0.1', help='RNDC Host'), + cfg.IntOpt('rndc-port', default=953, help='RNDC Port'), + cfg.StrOpt('rndc-config-file', + help='RNDC Config File'), + cfg.StrOpt('rndc-key-file', help='RNDC Key File'), + cfg.StrOpt('zone-file-path', default='$state_path/zones', + help='Path where zone files are stored'), + cfg.StrOpt('query-destination', default='127.0.0.1', + help='Host to query when finding zones'), +] + + +def register_opts(conf): + conf.register_group(BIND9_GROUP) + conf.register_opts(BINS9_OPTS, group=BIND9_GROUP) + + +def list_opts(): + return { + BIND9_GROUP: BINS9_OPTS, + } diff --git a/designate/conf/central.py b/designate/conf/central.py new file mode 100644 index 000000000..9aaa1926d --- /dev/null +++ b/designate/conf/central.py @@ -0,0 +1,65 @@ +# Copyright 2012 Hewlett-Packard Development Company, L.P. All Rights Reserved. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +CENTRAL_GROUP = cfg.OptGroup( + name='service:central', + title="Configuration for Central Service" +) + +CENTRAL_OPTS = [ + cfg.IntOpt('workers', + help='Number of central worker processes to spawn'), + cfg.IntOpt('threads', default=1000, + help='Number of central greenthreads to spawn'), + cfg.StrOpt('storage-driver', default='sqlalchemy', + help='The storage driver to use'), + cfg.ListOpt('enabled-notification-handlers', default=[], + help='Enabled Notification Handlers'), + cfg.IntOpt('max_zone_name_len', default=255, + help="Maximum zone name length"), + cfg.IntOpt('max_recordset_name_len', default=255, + help="Maximum recordset name length", + deprecated_name='max_record_name_len'), + cfg.StrOpt('managed_resource_email', default='hostmaster@example.com', + help='E-Mail for Managed resources'), + cfg.StrOpt('managed_resource_tenant_id', + default="00000000-0000-0000-0000-000000000000", + help="The Tenant ID that will own any managed resources."), + cfg.IntOpt('min_ttl', help="Minimum TTL allowed"), + # TODO(betsy): Move to Pool Service once that is written + cfg.StrOpt('default_pool_id', + default='794ccc2c-d751-44fe-b57f-8894c9f5c842', + help="The name of the default pool"), + cfg.StrOpt('central_topic', + default='central', + help="RPC topic name of central service."), + cfg.ListOpt( + 'scheduler_filters', + default=['default_pool'], + help='Enabled Pool Scheduling filters'), +] + + +def register_opts(conf): + conf.register_group(CENTRAL_GROUP) + conf.register_opts(CENTRAL_OPTS, group=CENTRAL_GROUP) + + +def list_opts(): + return { + CENTRAL_GROUP: CENTRAL_OPTS + } diff --git a/designate/conf/coordination.py b/designate/conf/coordination.py new file mode 100644 index 000000000..e767e0ee1 --- /dev/null +++ b/designate/conf/coordination.py @@ -0,0 +1,53 @@ +# +# Copyright 2014 Red Hat, Inc. +# Copyright 2015 Hewlett-Packard Development Company, L.P. +# +# Author: Endre Karlson +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +COORDINATION_GROUP = cfg.OptGroup( + name='coordination', + title="Configuration for coordination" +) + +COORDINATION_OPTS = [ + cfg.StrOpt( + 'backend_url', + help=( + 'The backend URL to use for distributed coordination. If ' + 'unset services that need coordination will function as ' + 'a standalone service. This is a `tooz` url - see ' + 'https://docs.openstack.org/tooz/latest/user/compatibility.html') + ), + cfg.FloatOpt('heartbeat_interval', + default=1.0, + help='Number of seconds between heartbeats for distributed ' + 'coordination.'), + cfg.FloatOpt('run_watchers_interval', + default=10.0, + help='Number of seconds between checks to see if group ' + 'membership has changed'), +] + + +def register_opts(conf): + conf.register_group(COORDINATION_GROUP) + conf.register_opts(COORDINATION_OPTS, group=COORDINATION_GROUP) + + +def list_opts(): + return { + COORDINATION_GROUP: COORDINATION_OPTS + } diff --git a/designate/conf/denominator.py b/designate/conf/denominator.py new file mode 100644 index 000000000..946fb1f8a --- /dev/null +++ b/designate/conf/denominator.py @@ -0,0 +1,39 @@ +# Copyright 2015 Dyn Inc. +# +# Author: Yasha Bubnov +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +DENOMINATOR_GROUP = cfg.OptGroup( + name='backend:agent:denominator', + title='Backend options for Denominator', +) + +DENOMINATOR_OPTS = [ + cfg.StrOpt('name', default='fake', + help='Name of the affected provider'), + cfg.StrOpt('config_file', default='/etc/denominator.conf', + help='Path to Denominator configuration file'), +] + + +def register_opts(conf): + conf.register_group(DENOMINATOR_GROUP) + conf.register_opts(DENOMINATOR_OPTS, group=DENOMINATOR_GROUP) + + +def list_opts(): + return { + DENOMINATOR_GROUP: DENOMINATOR_OPTS, + } diff --git a/designate/conf/djbdns.py b/designate/conf/djbdns.py new file mode 100644 index 000000000..21f2d00d3 --- /dev/null +++ b/designate/conf/djbdns.py @@ -0,0 +1,57 @@ +# Copyright 2016 Hewlett Packard Enterprise Development Company LP +# +# Author: Federico Ceratto +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +DJBDNS_GROUP = cfg.OptGroup( + name='backend:agent:djbdns', + title="Configuration for Djbdns backend" +) + +DJDNS_OPTS = [ + cfg.StrOpt( + 'tcpclient-cmd-name', + help='tcpclient executable path or rootwrap command name', + default='tcpclient' + ), + cfg.StrOpt( + 'axfr-get-cmd-name', + help='axfr-get executable path or rootwrap command name', + default='axfr-get' + ), + cfg.StrOpt( + 'tinydns-data-cmd-name', + help='tinydns-data executable path or rootwrap command name', + default='tinydns-data' + ), + cfg.StrOpt( + 'tinydns-datadir', + help='TinyDNS data directory', + default='/var/lib/djbdns' + ), + cfg.StrOpt('query-destination', default='127.0.0.1', + help='Host to query when finding zones'), +] + + +def register_opts(conf): + conf.register_group(DJBDNS_GROUP) + conf.register_opts(DJDNS_OPTS, group=DJBDNS_GROUP) + + +def list_opts(): + return { + DJBDNS_GROUP: DJDNS_OPTS, + } diff --git a/designate/conf/dynect.py b/designate/conf/dynect.py new file mode 100644 index 000000000..81eadc5c1 --- /dev/null +++ b/designate/conf/dynect.py @@ -0,0 +1,41 @@ +# Copyright 2014 Hewlett-Packard Development Company, L.P. +# +# Author: Endre Karlson +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +DYNECT_GROUP = cfg.OptGroup( + name='backend:dynect', + title='Backend options for DynECT' +) + +DYNECT_OPTS = [ + cfg.IntOpt('job_timeout', default=30, + help="Timeout in seconds for pulling a job in DynECT."), + cfg.IntOpt('timeout', help="Timeout in seconds for API Requests.", + default=10), + cfg.BoolOpt('timings', help="Measure requests timings.", + default=False), +] + + +def register_opts(conf): + conf.register_group(DYNECT_GROUP) + conf.register_opts(DYNECT_OPTS, group=DYNECT_GROUP) + + +def list_opts(): + return { + DYNECT_GROUP: DYNECT_OPTS, + } diff --git a/designate/conf/gdnsd.py b/designate/conf/gdnsd.py new file mode 100644 index 000000000..e27443963 --- /dev/null +++ b/designate/conf/gdnsd.py @@ -0,0 +1,42 @@ +# Copyright 2016 Hewlett Packard Enterprise Development Company LP +# +# Author: Federico Ceratto +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +GDNSD_GROUP = cfg.OptGroup( + name='backend:agent:gdnsd', + title="Configuration for gdnsd backend" +) +GDNSD_OPTS = [ + cfg.StrOpt('gdnsd-cmd-name', + help='gdnsd executable path or rootwrap command name', + default='gdnsd'), + cfg.StrOpt('confdir-path', + help='gdnsd configuration directory path', + default='/etc/gdnsd'), + cfg.StrOpt('query-destination', default='127.0.0.1', + help='Host to query when finding zones'), +] + + +def register_opts(conf): + conf.register_group(GDNSD_GROUP) + conf.register_opts(GDNSD_OPTS, group=GDNSD_GROUP) + + +def list_opts(): + return { + GDNSD_GROUP: GDNSD_OPTS, + } diff --git a/designate/backend/impl_infoblox/config.py b/designate/conf/infoblox.py similarity index 76% rename from designate/backend/impl_infoblox/config.py rename to designate/conf/infoblox.py index a9a3fa61a..09235cff5 100644 --- a/designate/backend/impl_infoblox/config.py +++ b/designate/conf/infoblox.py @@ -12,82 +12,90 @@ # 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 +INFOBLOX_GROUP = cfg.OptGroup( + name='backend:infoblox', + title="Configuration for Infoblox Backend" +) -cfg.CONF.register_group(cfg.OptGroup( - name='backend:infoblox', title="Configuration for Infoblox Backend" -)) - -OPTS = [ +INFOBLOX_OPTS = [ cfg.StrOpt( 'wapi_url', deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: wapi_url'), cfg.StrOpt( 'username', deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: username'), cfg.StrOpt( 'password', deprecated_for_removal=True, secret=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: password'), cfg.BoolOpt( 'sslverify', default=True, deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: sslverify'), cfg.BoolOpt( 'multi_tenant', default=False, deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: multi_tenant'), cfg.IntOpt( 'http_pool_connections', default=100, deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: http_pool_connections'), cfg.IntOpt( 'http_pool_maxsize', default=100, deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: http_pool_maxsize'), cfg.StrOpt( 'dns_view', default='default', deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: dns_view'), cfg.StrOpt( 'network_view', default='default', deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: network_view'), cfg.StrOpt( 'ns_group', deprecated_for_removal=True, deprecated_reason="All backend options have been migrated to options " - "in the pools.yaml file", + "in the pools.yaml file", help='DEPRECATED: ns_group'), ] -cfg.CONF.register_opts(OPTS, group='backend:infoblox') + +def register_opts(conf): + conf.register_group(INFOBLOX_GROUP) + conf.register_opts(INFOBLOX_OPTS, group=INFOBLOX_GROUP) + + +def list_opts(): + return { + INFOBLOX_GROUP: INFOBLOX_OPTS + } diff --git a/designate/conf/keystone.py b/designate/conf/keystone.py new file mode 100644 index 000000000..8c6c0b06e --- /dev/null +++ b/designate/conf/keystone.py @@ -0,0 +1,32 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from keystoneauth1 import loading as ksa_loading +from oslo_config import cfg + +KEYSTONE_GROUP = cfg.OptGroup( + name='keystone', + title='Access to Keystone API') + + +def register_opts(conf): + conf.register_group(KEYSTONE_GROUP) + ksa_loading.register_adapter_conf_options(conf, KEYSTONE_GROUP) + ksa_loading.register_session_conf_options(conf, KEYSTONE_GROUP) + conf.set_default('service_type', 'identity', group=KEYSTONE_GROUP) + + +def list_opts(): + return { + KEYSTONE_GROUP: (ksa_loading.get_adapter_conf_options() + + ksa_loading.get_session_conf_options()) + } diff --git a/designate/conf/knot2.py b/designate/conf/knot2.py new file mode 100644 index 000000000..4da4cf4a2 --- /dev/null +++ b/designate/conf/knot2.py @@ -0,0 +1,40 @@ +# Copyright 2016 Hewlett Packard Enterprise Development Company LP +# +# Author: Federico Ceratto +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +KNOT2_GROUP = cfg.OptGroup( + name='backend:agent:knot2', + title="Configuration for Knot2 backend" +) + +KNOT2_OPTS = [ + cfg.StrOpt('knotc-cmd-name', + help='knotc executable path or rootwrap command name', + default='knotc'), + cfg.StrOpt('query-destination', default='127.0.0.1', + help='Host to query when finding zones'), +] + + +def register_opts(conf): + conf.register_group(KNOT2_GROUP) + conf.register_opts(KNOT2_OPTS, group=KNOT2_GROUP) + + +def list_opts(): + return { + KNOT2_GROUP: KNOT2_OPTS, + } diff --git a/designate/conf/mdns.py b/designate/conf/mdns.py new file mode 100644 index 000000000..653a268cb --- /dev/null +++ b/designate/conf/mdns.py @@ -0,0 +1,68 @@ +# Copyright 2014 Hewlett-Packard Development Company, L.P. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +from designate.utils import DEFAULT_MDNS_PORT + +MDNS_GROUP = cfg.OptGroup( + name='service:mdns', title="Configuration for mDNS Service" +) + +MDNS_OPTS = [ + cfg.IntOpt('workers', + help='Number of mdns worker processes to spawn'), + cfg.IntOpt('threads', default=1000, + help='Number of mdns greenthreads to spawn'), + cfg.IPOpt('host', + deprecated_for_removal=True, + deprecated_reason="Replaced by 'listen' option", + help='mDNS Bind Host'), + cfg.PortOpt('port', + deprecated_for_removal=True, + deprecated_reason="Replaced by 'listen' option", + help='mDNS Port Number'), + cfg.ListOpt('listen', + default=['0.0.0.0:%d' % DEFAULT_MDNS_PORT], + help='mDNS host:port pairs to listen on'), + cfg.IntOpt('tcp-backlog', default=100, + help='mDNS TCP Backlog'), + cfg.FloatOpt('tcp-recv-timeout', default=0.5, + help='mDNS TCP Receive Timeout'), + cfg.BoolOpt('all-tcp', default=False, + help='Send all traffic over TCP'), + cfg.BoolOpt('query-enforce-tsig', default=False, + help='Enforce all incoming queries (including AXFR) are TSIG ' + 'signed'), + cfg.StrOpt('storage-driver', default='sqlalchemy', + help='The storage driver to use'), + cfg.IntOpt('max-message-size', default=65535, + help='Maximum message size to emit'), + cfg.StrOpt('mdns_topic', default='mdns', + help='RPC topic name for mini-DNS'), + cfg.IntOpt('xfr_timeout', help="Timeout in seconds for XFR's.", + default=10), +] + + +def register_opts(conf): + conf.register_group(MDNS_GROUP) + conf.register_opts(MDNS_OPTS, group=MDNS_GROUP) + + +def list_opts(): + return { + MDNS_GROUP: MDNS_OPTS + } diff --git a/designate/conf/metrics.py b/designate/conf/metrics.py new file mode 100644 index 000000000..dfb788e71 --- /dev/null +++ b/designate/conf/metrics.py @@ -0,0 +1,36 @@ +# Copyright 2016 Hewlett Packard Enterprise Development Company LP +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +METRICS_GROUP = cfg.OptGroup( + name='monasca:statsd', + title="Configuration for Monasca Statsd" +) + +METRICS_OPTS = [ + cfg.BoolOpt('enabled', default=False, help='enable'), + cfg.IntOpt('port', default=8125, help='UDP port'), + cfg.StrOpt('hostname', default='127.0.0.1', help='hostname'), +] + + +def register_opts(conf): + conf.register_group(METRICS_GROUP) + conf.register_opts(METRICS_OPTS, group=METRICS_GROUP) + + +def list_opts(): + return { + METRICS_GROUP: METRICS_OPTS + } diff --git a/designate/conf/msdns.py b/designate/conf/msdns.py new file mode 100644 index 000000000..4d8002c87 --- /dev/null +++ b/designate/conf/msdns.py @@ -0,0 +1,35 @@ +# Copyright 2016 Cloudbase Solutions Srl +# All Rights Reserved. +# +# Author: Alin Balutoiu +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +MSDNS_GROUP = cfg.OptGroup( + name='backend:agent:msdns', + title="Configuration for Microsoft DNS Server" +) +MSDNS_OPTS = [ +] + + +def register_opts(conf): + conf.register_group(MSDNS_GROUP) + conf.register_opts(MSDNS_OPTS, group=MSDNS_GROUP) + + +def list_opts(): + return { + MSDNS_GROUP: MSDNS_OPTS, + } diff --git a/designate/conf/network_api.py b/designate/conf/network_api.py new file mode 100644 index 000000000..3c6aaf5cc --- /dev/null +++ b/designate/conf/network_api.py @@ -0,0 +1,58 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +NETWORK_API_NEUTRON_GROUP = cfg.OptGroup( + name='network_api:neutron', title="Configuration network api" +) + +NETWORK_API_NEUTRON_OPTS = [ + cfg.ListOpt('endpoints', + help='URL to use if None in the ServiceCatalog that is ' + 'passed by the request context. Format: |'), + cfg.StrOpt('endpoint_type', default='publicURL', + help="Endpoint type to use"), + cfg.IntOpt('timeout', + default=30, + help='timeout value for connecting to neutron in seconds'), + cfg.StrOpt('admin_username', + help='username for connecting to neutron in admin context'), + cfg.StrOpt('admin_password', + help='password for connecting to neutron in admin context', + secret=True), + cfg.StrOpt('admin_tenant_name', + help='tenant name for connecting to neutron in admin context'), + cfg.StrOpt('auth_url', + help='auth url for connecting to neutron in admin context'), + cfg.BoolOpt('insecure', + default=False, + help='if set, ignore any SSL validation issues'), + cfg.StrOpt('auth_strategy', + default='keystone', + help='auth strategy for connecting to ' + 'neutron in admin context'), + cfg.StrOpt('ca_certificates_file', + help='Location of ca certificates file to use for ' + 'neutron client requests.'), +] + + +def register_opts(conf): + conf.register_group(NETWORK_API_NEUTRON_GROUP) + conf.register_opts(NETWORK_API_NEUTRON_OPTS, + group=NETWORK_API_NEUTRON_GROUP) + + +def list_opts(): + return { + NETWORK_API_NEUTRON_GROUP: NETWORK_API_NEUTRON_OPTS + } diff --git a/designate/conf/opts.py b/designate/conf/opts.py new file mode 100644 index 000000000..a38b76b7d --- /dev/null +++ b/designate/conf/opts.py @@ -0,0 +1,80 @@ +# Copyright 2015 OpenStack Foundation +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# Copied from nova + +""" +This is the single point of entry to generate the sample configuration +file for Designate. It collects all the necessary info from the other modules +in this package. It is assumed that: + +* every other module in this package has a 'list_opts' function which + return a dict where + * the keys are strings which are the group names + * the value of each key is a list of config options for that group +* the designate.conf package doesn't have further packages with config options +* this module is only used in the context of sample file generation +""" + +import collections +import importlib +import os +import pkgutil + +LIST_OPTS_FUNC_NAME = "list_opts" + + +def _tupleize(dct): + """Take the dict of options and convert to the 2-tuple format.""" + return [(key, val) for key, val in dct.items()] + + +def list_opts(): + opts = collections.defaultdict(list) + module_names = _list_module_names() + imported_modules = _import_modules(module_names) + _append_config_options(imported_modules, opts) + return _tupleize(opts) + + +def _list_module_names(): + module_names = [] + package_path = os.path.dirname(os.path.abspath(__file__)) + for _, modname, ispkg in pkgutil.iter_modules(path=[package_path]): + if modname == "opts" or ispkg: + continue + else: + module_names.append(modname) + return module_names + + +def _import_modules(module_names): + imported_modules = [] + for modname in module_names: + mod = importlib.import_module("designate.conf." + modname) + if not hasattr(mod, LIST_OPTS_FUNC_NAME): + msg = ("The module 'designate.conf.%s' should have a '%s' " + "function which returns the config options." % + (modname, LIST_OPTS_FUNC_NAME)) + raise Exception(msg) + else: + imported_modules.append(mod) + return imported_modules + + +def _append_config_options(imported_modules, config_options): + for mod in imported_modules: + configs = mod.list_opts() + for key, val in configs.items(): + config_options[key].extend(val) diff --git a/designate/conf/pool_manager.py b/designate/conf/pool_manager.py new file mode 100644 index 000000000..076970b11 --- /dev/null +++ b/designate/conf/pool_manager.py @@ -0,0 +1,112 @@ +# Copyright 2014 eBay Inc. +# +# Author: Ron Rickard +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg +from oslo_db import options + +POOL_MANAGER_GROUP = cfg.OptGroup( + name='service:pool_manager', + title="Configuration for Pool Manager Service" +) + +POOL_MANAGER_SQLALCHEMY_GROUP = cfg.OptGroup( + name='pool_manager_cache:sqlalchemy', + title="Configuration for SQLAlchemy Pool Manager Cache" +) + +POOL_MANAGER_MEMCACHE_GROUP = cfg.OptGroup( + name='pool_manager_cache:memcache', + title="Configuration for memcache Pool Manager Cache" +) + +POOL_MANAGER_OPTS = [ + cfg.IntOpt('workers', + help='Number of Pool Manager worker processes to spawn'), + cfg.IntOpt('threads', default=1000, + help='Number of Pool Manager greenthreads to spawn'), + cfg.StrOpt('pool-id', default='794ccc2c-d751-44fe-b57f-8894c9f5c842', + help='The ID of the pool managed by this instance of the ' + 'Pool Manager'), + cfg.IntOpt('threshold-percentage', default=100, + help='The percentage of servers requiring a successful update ' + 'for a zone change to be considered active', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.IntOpt('poll-timeout', default=30, + help='The time to wait for a response from a server', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.IntOpt('poll-retry-interval', default=15, + help='The time between retrying to send a request and ' + 'waiting for a response from a server', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.IntOpt('poll-max-retries', default=10, + help='The maximum number of times to retry sending a request ' + 'and wait for a response from a server', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.IntOpt('poll-delay', default=5, + help='The time to wait before sending the first request ' + 'to a server', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.BoolOpt('enable-recovery-timer', default=True, + help='The flag for the recovery timer'), + cfg.IntOpt('periodic-recovery-interval', default=120, + help='The time between recovering from failures'), + cfg.BoolOpt('enable-sync-timer', default=True, + help='The flag for the sync timer'), + cfg.IntOpt('periodic-sync-interval', default=1800, + help='The time between synchronizing the servers with storage'), + cfg.IntOpt('periodic-sync-seconds', default=21600, + help='Zones Updated within last N seconds will be syncd.' + 'Use an empty value to sync all zones.'), + cfg.IntOpt('periodic-sync-max-attempts', default=3, + help='Number of attempts to update a zone during sync'), + cfg.IntOpt('periodic-sync-retry-interval', default=30, + help='Interval between zone update attempts during sync'), + cfg.StrOpt('cache-driver', default='memcache', + help='The cache driver to use'), + cfg.StrOpt('pool_manager_topic', default='pool_manager', + help='RPC topic name for pool-manager'), +] + +POOL_MANAGER_MEMCACHE_OPTS = [ + cfg.ListOpt('memcached_servers', + help='Memcached servers or None for in process cache.'), + cfg.IntOpt('expiration', default=3600, + help='Time in seconds to expire cache.'), +] + + +def register_opts(conf): + conf.register_group(POOL_MANAGER_GROUP) + conf.register_opts(POOL_MANAGER_OPTS, + group=POOL_MANAGER_GROUP) + conf.register_group(POOL_MANAGER_SQLALCHEMY_GROUP) + conf.register_opts(options.database_opts, + group=POOL_MANAGER_SQLALCHEMY_GROUP) + conf.register_group(POOL_MANAGER_MEMCACHE_GROUP) + conf.register_opts(POOL_MANAGER_MEMCACHE_OPTS, + group=POOL_MANAGER_MEMCACHE_GROUP) + + +def list_opts(): + return { + POOL_MANAGER_GROUP: POOL_MANAGER_OPTS, + POOL_MANAGER_MEMCACHE_GROUP: POOL_MANAGER_MEMCACHE_OPTS, + POOL_MANAGER_SQLALCHEMY_GROUP: options.database_opts, + } diff --git a/designate/conf/producer.py b/designate/conf/producer.py new file mode 100644 index 000000000..70b9fc8ce --- /dev/null +++ b/designate/conf/producer.py @@ -0,0 +1,121 @@ +# Copyright 2015 Hewlett-Packard Development Company, L.P. +# +# Author: Endre Karlson +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +from designate.producer import tasks + +PRODUCER_GROUP = cfg.OptGroup( + name='service:producer', + title="Configuration for Producer Service" +) + +ZONE_MANAGER_GROUP = cfg.OptGroup( + name='service:zone_manager', title="Configuration for Zone Manager Service" +) + +PRODUCER_OPTS = [ + cfg.IntOpt('workers', + help='Number of Producer worker processes to spawn'), + cfg.IntOpt('threads', default=1000, + help='Number of Producer greenthreads to spawn'), + cfg.ListOpt('enabled_tasks', + help='Enabled tasks to run'), + cfg.StrOpt('storage-driver', default='sqlalchemy', + help='The storage driver to use'), + cfg.BoolOpt('export-synchronous', default=True, + help='Whether to allow synchronous zone exports', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), +] + +ZONE_MANAGER_OPTS = [ + cfg.IntOpt('workers', + help='Number of Zone Manager worker processes to spawn', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.IntOpt('threads', default=1000, + help='Number of Zone Manager greenthreads to spawn', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.ListOpt('enabled_tasks', + help='Enabled tasks to run', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.StrOpt('storage-driver', default='sqlalchemy', + help='The storage driver to use', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), + cfg.BoolOpt('export-synchronous', default=True, + help='Whether to allow synchronous zone exports', + deprecated_for_removal=True, + deprecated_reason='Migrated to designate-worker'), +] + +# NOTE(trungnv): Get [producer_task:zone_purge] config +zone_purge_opts = tasks.DeletedZonePurgeTask.get_cfg_opts()[0][1] +zone_purge_old_group = tasks.DeletedZonePurgeTask.get_cfg_opts()[0][0].name +zone_purge_group = cfg.OptGroup(zone_purge_old_group) + +# NOTE(trungnv): Get [producer_task:periodic_exists] config +periodic_exists_opts = tasks.PeriodicExistsTask.get_cfg_opts()[0][1] +periodic_exists_old_group = tasks.PeriodicExistsTask.get_cfg_opts()[0][0].name +periodic_exists_group = cfg.OptGroup(periodic_exists_old_group) + +# NOTE(trungnv): Get [producer_task:periodic_secondary_refresh] config +psr_opts = tasks.PeriodicSecondaryRefreshTask.get_cfg_opts()[0][1] +psr_old_group = tasks.PeriodicSecondaryRefreshTask.get_cfg_opts()[0][0].name +psr_group = cfg.OptGroup(psr_old_group) + +# NOTE(trungnv): Get [producer_task:delayed_notify] config +delayed_notify_opts = \ + tasks.PeriodicGenerateDelayedNotifyTask.get_cfg_opts()[0][1] +delayed_notify_old_group = \ + tasks.PeriodicGenerateDelayedNotifyTask.get_cfg_opts()[0][0].name +delayed_notify_group = cfg.OptGroup(delayed_notify_old_group) + +# NOTE(trungnv): Get [producer_task:worker_periodic_recovery] config +wpr_opts = tasks.WorkerPeriodicRecovery.get_cfg_opts()[0][1] +wpr_old_group = tasks.WorkerPeriodicRecovery.get_cfg_opts()[0][0].name +wpr_group = cfg.OptGroup(wpr_old_group) + + +def register_opts(conf): + conf.register_group(PRODUCER_GROUP) + conf.register_opts(PRODUCER_OPTS, group=PRODUCER_GROUP) + conf.register_group(ZONE_MANAGER_GROUP) + conf.register_opts(ZONE_MANAGER_OPTS, group=ZONE_MANAGER_GROUP) + conf.register_group(zone_purge_group) + conf.register_opts(zone_purge_opts, group=zone_purge_group) + conf.register_group(periodic_exists_group) + conf.register_opts(periodic_exists_opts, group=periodic_exists_group) + conf.register_group(psr_group) + conf.register_opts(psr_opts, group=psr_group) + conf.register_group(delayed_notify_group) + conf.register_opts(delayed_notify_opts, group=delayed_notify_group) + conf.register_group(wpr_group) + conf.register_opts(wpr_opts, group=wpr_group) + + +def list_opts(): + return { + PRODUCER_GROUP: PRODUCER_OPTS, + ZONE_MANAGER_GROUP: ZONE_MANAGER_OPTS, + zone_purge_group: zone_purge_opts, + periodic_exists_group: periodic_exists_opts, + psr_group: psr_opts, + delayed_notify_group: delayed_notify_opts, + wpr_group: wpr_opts, + } diff --git a/designate/conf/proxy.py b/designate/conf/proxy.py new file mode 100644 index 000000000..a0eb19d0c --- /dev/null +++ b/designate/conf/proxy.py @@ -0,0 +1,43 @@ +# Copyright 2012 Managed I.T. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +# Set some proxy options (Used for clients that need to communicate via a +# proxy) +PROXY_GROUP = cfg.OptGroup( + name='proxy', + title="Configuration for Client Proxy" +) + +PROXY_OPTS = [ + cfg.StrOpt('http_proxy', + help='Proxy HTTP requests via this proxy.'), + cfg.StrOpt('https_proxy', + help='Proxy HTTPS requests via this proxy'), + cfg.ListOpt('no_proxy', default=[], + help='These addresses should not be proxied'), +] + + +def register_opts(conf): + conf.register_group(PROXY_GROUP) + conf.register_opts(PROXY_OPTS, group=PROXY_GROUP) + + +def list_opts(): + return { + PROXY_GROUP: PROXY_OPTS + } diff --git a/designate/conf/service_status.py b/designate/conf/service_status.py new file mode 100644 index 000000000..d43afec6d --- /dev/null +++ b/designate/conf/service_status.py @@ -0,0 +1,38 @@ +# Copyright 2016 Hewlett Packard Enterprise Development Company LP +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +HEARTBEAT_GROUP = cfg.OptGroup( + name='heartbeat_emitter', + title="Configuration for heartbeat_emitter" +) + +HEARTBEAT_OPTS = [ + cfg.FloatOpt('heartbeat_interval', + default=5.0, + help='Number of seconds between heartbeats for reporting ' + 'state'), + cfg.StrOpt('emitter_type', default="rpc", help="Emitter to use"), +] + + +def register_opts(conf): + conf.register_group(HEARTBEAT_GROUP) + conf.register_opts(HEARTBEAT_OPTS, group=HEARTBEAT_GROUP) + + +def list_opts(): + return { + HEARTBEAT_GROUP: HEARTBEAT_OPTS + } diff --git a/designate/conf/sink.py b/designate/conf/sink.py new file mode 100644 index 000000000..382847c57 --- /dev/null +++ b/designate/conf/sink.py @@ -0,0 +1,88 @@ +# Copyright 2012 Hewlett-Packard Development Company, L.P. All Rights Reserved. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +SINK_GROUP = cfg.OptGroup( + name='service:sink', + title="Configuration for Sink Service" +) + +SINK_NEUTRON_GROUP = cfg.OptGroup( + name='handler:neutron_floatingip', + title="Configuration for Neutron Notification Handler" +) + +SINK_NOVA_GROUP = cfg.OptGroup( + name='handler:nova_fixed', + title="Configuration for Nova Notification Handler" +) + +SINK_OPTS = [ + cfg.IntOpt('workers', + help='Number of sink worker processes to spawn'), + cfg.IntOpt('threads', default=1000, + help='Number of sink greenthreads to spawn'), + cfg.ListOpt('enabled-notification-handlers', default=[], + help='Enabled Notification Handlers'), + cfg.StrOpt('listener-pool-name', + help='pool name to use for oslo.messaging ' + 'notification listener. ' + 'Note that listener pooling is not supported ' + 'by all oslo.messaging drivers.'), +] + +SINK_NEUTRON_OPTS = [ + cfg.ListOpt('notification-topics', default=['notifications'], + help='notification any events from neutron'), + cfg.StrOpt('control-exchange', default='neutron', + help='control-exchange for neutron notification'), + cfg.StrOpt('zone-id', help='Zone ID with each notification'), + cfg.MultiStrOpt('formatv4', help='IPv4 format'), + cfg.MultiStrOpt('format', deprecated_for_removal=True, + deprecated_reason="Replaced by 'formatv4/formatv6'", + help='format which replaced by formatv4/formatv6'), + cfg.MultiStrOpt('formatv6', help='IPv6 format'), +] + +SINK_NOVA_OPTS = [ + cfg.ListOpt('notification-topics', default=['notifications'], + help='notification any events from nova'), + cfg.StrOpt('control-exchange', default='nova', + help='control-exchange for nova notification'), + cfg.StrOpt('zone-id', help='Zone ID with each notification'), + cfg.MultiStrOpt('formatv4', help='IPv4 format'), + cfg.MultiStrOpt('format', deprecated_for_removal=True, + deprecated_reason="Replaced by 'formatv4/formatv6'", + help='format which replaced by formatv4/formatv6'), + cfg.MultiStrOpt('formatv6', help='IPv6 format'), +] + + +def register_opts(conf): + conf.register_group(SINK_GROUP) + conf.register_opts(SINK_OPTS, group=SINK_GROUP) + conf.register_group(SINK_NEUTRON_GROUP) + conf.register_opts(SINK_NEUTRON_OPTS, group=SINK_NEUTRON_GROUP) + conf.register_group(SINK_NOVA_GROUP) + conf.register_opts(SINK_NOVA_OPTS, group=SINK_NOVA_GROUP) + + +def list_opts(): + return { + SINK_GROUP: SINK_OPTS, + SINK_NEUTRON_GROUP: SINK_NEUTRON_OPTS, + SINK_NOVA_GROUP: SINK_NOVA_OPTS, + } diff --git a/designate/conf/storage.py b/designate/conf/storage.py new file mode 100644 index 000000000..e576d9f47 --- /dev/null +++ b/designate/conf/storage.py @@ -0,0 +1,33 @@ +# Copyright 2012 Managed I.T. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg +from oslo_db import options + +STORAGE_GROUP = cfg.OptGroup( + name='storage:sqlalchemy', + title="Configuration for SQLAlchemy Storage" +) + + +def register_opts(conf): + conf.register_group(STORAGE_GROUP) + conf.register_opts(options.database_opts, group=STORAGE_GROUP) + + +def list_opts(): + return { + STORAGE_GROUP: options.database_opts, + } diff --git a/designate/conf/worker.py b/designate/conf/worker.py new file mode 100644 index 000000000..22eb823a6 --- /dev/null +++ b/designate/conf/worker.py @@ -0,0 +1,69 @@ +# Copyright 2016 Rackspace Inc. +# +# Author: Tim Simmons +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import cfg + +WORKER_GROUP = cfg.OptGroup( + name='service:worker', title="Configuration for the Worker Service" +) + +WORKER_OPTS = [ + cfg.BoolOpt('enabled', default=True, + help='Whether to send events to worker instead of ' + 'Pool Manager', + deprecated_for_removal=True, + deprecated_reason='In Train, this option will disappear' + 'because pool manager will be removed'), + cfg.IntOpt('workers', + help='Number of Worker worker processes to spawn'), + cfg.IntOpt('threads', default=200, + help='Number of Worker threads to spawn per process'), + # cfg.ListOpt('enabled_tasks', + # help='Enabled tasks to run'), + cfg.StrOpt('storage-driver', default='sqlalchemy', + help='The storage driver to use'), + cfg.IntOpt('threshold-percentage', default=100, + help='The percentage of servers requiring a successful update ' + 'for a domain change to be considered active'), + cfg.IntOpt('poll-timeout', default=30, + help='The time to wait for a response from a server'), + cfg.IntOpt('poll-retry-interval', default=15, + help='The time between retrying to send a request and ' + 'waiting for a response from a server'), + cfg.IntOpt('poll-max-retries', default=10, + help='The maximum number of times to retry sending a request ' + 'and wait for a response from a server'), + cfg.IntOpt('poll-delay', default=5, + help='The time to wait before sending the first request ' + 'to a server'), + cfg.BoolOpt('notify', default=True, + help='Whether to allow worker to send NOTIFYs, this will ' + 'noop NOTIFYs in mdns if true'), + cfg.BoolOpt('export-synchronous', default=True, + help='Whether to allow synchronous zone exports'), + cfg.StrOpt('worker_topic', default='worker', + help='RPC topic for worker component'), +] + + +def register_opts(conf): + conf.register_group(WORKER_GROUP) + conf.register_opts(WORKER_OPTS, group=WORKER_GROUP) + + +def list_opts(): + return { + WORKER_GROUP: WORKER_OPTS, + } diff --git a/designate/coordination.py b/designate/coordination.py index 7084b10f0..2efbd8c78 100644 --- a/designate/coordination.py +++ b/designate/coordination.py @@ -19,40 +19,16 @@ import math import time -from oslo_config import cfg from oslo_log import log import tenacity import tooz.coordination +import designate.conf from designate.utils import generate_uuid +CONF = designate.conf.CONF LOG = log.getLogger(__name__) -coordination_group = cfg.OptGroup( - name='coordination', title="Configuration for coordination" -) - -coordination_opts = [ - cfg.StrOpt('backend_url', - help='The backend URL to use for distributed coordination. If ' - 'unset services that need coordination will function as ' - 'a standalone service. This is a `tooz` url - see ' - 'https://docs.openstack.org/tooz/latest/user/compatibility.html'), # noqa - cfg.FloatOpt('heartbeat_interval', - default=1.0, - help='Number of seconds between heartbeats for distributed ' - 'coordination.'), - cfg.FloatOpt('run_watchers_interval', - default=10.0, - help='Number of seconds between checks to see if group ' - 'membership has changed') - -] -cfg.CONF.register_group(coordination_group) -cfg.CONF.register_opts(coordination_opts, group=coordination_group) - -CONF = cfg.CONF - def _retry_if_tooz_error(exception): """Return True if we should retry, False otherwise""" @@ -69,15 +45,15 @@ class CoordinationMixin(object): self._coordination_id = ":".join([CONF.host, generate_uuid()]) if CONF.coordination.backend_url is not None: - backend_url = cfg.CONF.coordination.backend_url + backend_url = CONF.coordination.backend_url self._coordinator = tooz.coordination.get_coordinator( backend_url, self._coordination_id) self._coordination_started = False - self.tg.add_timer(cfg.CONF.coordination.heartbeat_interval, + self.tg.add_timer(CONF.coordination.heartbeat_interval, self._coordinator_heartbeat) - self.tg.add_timer(cfg.CONF.coordination.run_watchers_interval, + self.tg.add_timer(CONF.coordination.run_watchers_interval, self._coordinator_run_watchers) else: diff --git a/designate/dnsutils.py b/designate/dnsutils.py index 9b00ed572..6833d5427 100644 --- a/designate/dnsutils.py +++ b/designate/dnsutils.py @@ -26,22 +26,16 @@ import eventlet from dns import rdatatype from oslo_serialization import base64 from oslo_log import log as logging -from oslo_config import cfg +import designate.conf from designate import context from designate import exceptions from designate import objects +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -util_opts = [ - cfg.IntOpt('xfr_timeout', help="Timeout in seconds for XFR's.", default=10) -] - -cfg.CONF.register_opts(util_opts) - - class DNSMiddleware(object): """Base DNS Middleware class with some utility methods""" def __init__(self, application): @@ -246,7 +240,7 @@ class LimitNotifyMiddleware(DNSMiddleware): def __init__(self, application): super(LimitNotifyMiddleware, self).__init__(application) - self.delay = cfg.CONF['service:agent'].notify_delay + self.delay = CONF['service:agent'].notify_delay self.locker = ZoneLock(self.delay) def process_request(self, request): @@ -278,7 +272,7 @@ def from_dnspython_zone(dnspython_zone): if soa is None: raise exceptions.BadRequest('An SOA record is required') if soa.ttl == 0: - soa.ttl = cfg.CONF['service:central'].min_ttl + soa.ttl = CONF['service:central'].min_ttl email = soa[0].rname.to_text(omit_final_dot=True) if six.PY3 and isinstance(email, bytes): email = email.decode('utf-8') @@ -350,7 +344,7 @@ def do_axfr(zone_name, servers, timeout=None, source=None): :returns: Zone instance from dnspython """ random.shuffle(servers) - timeout = timeout or cfg.CONF["service:mdns"].xfr_timeout + timeout = timeout or CONF["service:mdns"].xfr_timeout xfr = None diff --git a/designate/mdns/__init__.py b/designate/mdns/__init__.py index de1a3fae1..e69de29bb 100644 --- a/designate/mdns/__init__.py +++ b/designate/mdns/__init__.py @@ -1,67 +0,0 @@ -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Author: Kiall Mac Innes -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_config import cfg - -from designate import dnsutils -from designate.utils import DEFAULT_MDNS_PORT - - -mdns_group = cfg.OptGroup( - name='service:mdns', title="Configuration for mDNS Service" -) - -OPTS = [ - cfg.IntOpt('workers', - help='Number of mdns worker processes to spawn'), - cfg.IntOpt('threads', default=1000, - help='Number of mdns greenthreads to spawn'), - cfg.IPOpt('host', - deprecated_for_removal=True, - deprecated_reason="Replaced by 'listen' option", - help='mDNS Bind Host'), - cfg.PortOpt('port', - deprecated_for_removal=True, - deprecated_reason="Replaced by 'listen' option", - help='mDNS Port Number'), - cfg.ListOpt('listen', - default=['0.0.0.0:%d' % DEFAULT_MDNS_PORT], - help='mDNS host:port pairs to listen on'), - cfg.IntOpt('tcp-backlog', default=100, - help='mDNS TCP Backlog'), - cfg.FloatOpt('tcp-recv-timeout', default=0.5, - help='mDNS TCP Receive Timeout'), - cfg.BoolOpt('all-tcp', default=False, - help='Send all traffic over TCP'), - cfg.BoolOpt('query-enforce-tsig', default=False, - help='Enforce all incoming queries (including AXFR) are TSIG ' - 'signed'), - cfg.StrOpt('storage-driver', default='sqlalchemy', - help='The storage driver to use'), - cfg.IntOpt('max-message-size', default=65535, - help='Maximum message size to emit'), - cfg.StrOpt('mdns_topic', default='mdns', - help='RPC topic name for mini-DNS') -] - - -cfg.CONF.register_group(mdns_group) -cfg.CONF.register_opts(OPTS, group=mdns_group) -cfg.CONF.register_opts(dnsutils.util_opts, group=mdns_group) - - -def list_opts(): - yield mdns_group, OPTS diff --git a/designate/metrics.py b/designate/metrics.py index 0d77b5533..656f77683 100644 --- a/designate/metrics.py +++ b/designate/metrics.py @@ -37,29 +37,18 @@ Usage examples: """ -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import importutils +import designate.conf.metrics + stats_client = importutils.import_any('monascastatsd', 'designate.metrics_client.noop') +CFG_GROUP_NAME = 'monasca:statsd' +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -CFG_GROUP = 'monasca:statsd' -metrics_group = cfg.OptGroup( - name=CFG_GROUP, title="Configuration for Monasca Statsd" -) - -metrics_opts = [ - cfg.BoolOpt('enabled', default=False, help='enable'), - cfg.IntOpt('port', default=8125, help='UDP port'), - cfg.StrOpt('hostname', default='127.0.0.1', help='hostname') -] - -cfg.CONF.register_group(metrics_group) -cfg.CONF.register_opts(metrics_opts, group=metrics_group) - # Global metrics client to be imported by other modules metrics = None @@ -84,7 +73,7 @@ class Metrics(object): """Setup client connection or disable metrics based on configuration. This is called once the cfg.CONF is ready. """ - conf = cfg.CONF[CFG_GROUP] + conf = CONF[CFG_GROUP_NAME] if conf.enabled: LOG.info("Statsd reports to %(host)s %(port)d", { diff --git a/designate/network_api/neutron.py b/designate/network_api/neutron.py index 860147c3b..359ea196e 100644 --- a/designate/network_api/neutron.py +++ b/designate/network_api/neutron.py @@ -14,7 +14,6 @@ # under the License. # # Copied partially from nova - from neutronclient.v2_0 import client as clientv20 from neutronclient.common import exceptions as neutron_exceptions from oslo_config import cfg @@ -29,44 +28,6 @@ CONF = cfg.CONF LOG = logging.getLogger(__name__) -neutron_group = cfg.OptGroup( - name='network_api:neutron', title="Configuration network api" - ) - -neutron_opts = [ - cfg.ListOpt('endpoints', - help='URL to use if None in the ServiceCatalog that is ' - 'passed by the request context. Format: |'), - cfg.StrOpt('endpoint_type', default='publicURL', - help="Endpoint type to use"), - cfg.IntOpt('timeout', - default=30, - help='timeout value for connecting to neutron in seconds'), - cfg.StrOpt('admin_username', - help='username for connecting to neutron in admin context'), - cfg.StrOpt('admin_password', - help='password for connecting to neutron in admin context', - secret=True), - cfg.StrOpt('admin_tenant_name', - help='tenant name for connecting to neutron in admin context'), - cfg.StrOpt('auth_url', - help='auth url for connecting to neutron in admin context'), - cfg.BoolOpt('insecure', - default=False, - help='if set, ignore any SSL validation issues'), - cfg.StrOpt('auth_strategy', - default='keystone', - help='auth strategy for connecting to ' - 'neutron in admin context'), - cfg.StrOpt('ca_certificates_file', - help='Location of ca certificates file to use for ' - 'neutron client requests.'), -] - -cfg.CONF.register_group(neutron_group) -cfg.CONF.register_opts(neutron_opts, group=neutron_group) - - def get_client(context, endpoint): params = { 'endpoint_url': endpoint, diff --git a/designate/notification_handler/neutron.py b/designate/notification_handler/neutron.py index 47bc6058b..4a816eebc 100644 --- a/designate/notification_handler/neutron.py +++ b/designate/notification_handler/neutron.py @@ -21,28 +21,6 @@ from designate.notification_handler import base LOG = logging.getLogger(__name__) -# TODO(trungnv): update default format for v4 and v6 in these cfg. -neutron_group = cfg.OptGroup( - name='handler:neutron_floatingip', - title="Configuration for Neutron Notification Handler" -) - -neutron_opts = [ - cfg.ListOpt('notification-topics', default=['notifications'], - help='notification any events from neutron'), - cfg.StrOpt('control-exchange', default='neutron', - help='control-exchange for neutron notification'), - cfg.StrOpt('zone-id', help='Zone ID with each notification'), - cfg.MultiStrOpt('formatv4', help='IPv4 format'), - cfg.MultiStrOpt('format', deprecated_for_removal=True, - deprecated_reason="Replaced by 'formatv4/formatv6'", - help='format which replaced by formatv4/formatv6'), - cfg.MultiStrOpt('formatv6', help='IPv6 format') -] - -cfg.CONF.register_group(neutron_group) -cfg.CONF.register_opts(neutron_opts, group=neutron_group) - class NeutronFloatingHandler(base.BaseAddressHandler): """Handler for Neutron's notifications""" diff --git a/designate/notification_handler/nova.py b/designate/notification_handler/nova.py index a9e5eb5f9..7f35ea166 100644 --- a/designate/notification_handler/nova.py +++ b/designate/notification_handler/nova.py @@ -21,28 +21,6 @@ from designate.notification_handler.base import BaseAddressHandler LOG = logging.getLogger(__name__) -# TODO(trungnv): update default format for v4 and v6 in these cfg. -nova_group = cfg.OptGroup( - name='handler:nova_fixed', - title="Configuration for Nova Notification Handler" -) - -nova_opts = [ - cfg.ListOpt('notification-topics', default=['notifications'], - help='notification any events from nova'), - cfg.StrOpt('control-exchange', default='nova', - help='control-exchange for nova notification'), - cfg.StrOpt('zone-id', help='Zone ID with each notification'), - cfg.MultiStrOpt('formatv4', help='IPv4 format'), - cfg.MultiStrOpt('format', deprecated_for_removal=True, - deprecated_reason="Replaced by 'formatv4/formatv6'", - help='format which replaced by formatv4/formatv6'), - cfg.MultiStrOpt('formatv6', help='IPv6 format') -] - -cfg.CONF.register_group(nova_group) -cfg.CONF.register_opts(nova_opts, group=nova_group) - class NovaFixedHandler(BaseAddressHandler): """Handler for Nova's notifications""" diff --git a/designate/notifications.py b/designate/notifications.py index 9f3e4874c..f13bc381c 100644 --- a/designate/notifications.py +++ b/designate/notifications.py @@ -21,21 +21,13 @@ from oslo_config import cfg from oslo_log import log as logging import six +import designate.conf from designate.plugin import DriverPlugin from designate import objects from designate import rpc LOG = logging.getLogger(__name__) - -notify_opts = [ - cfg.BoolOpt('notify_api_faults', default=False, - help='Send notifications if there\'s a failure in the API.'), - cfg.StrOpt('notification-plugin', default='default', - help='The notification plugin to use'), -] - -CONF = cfg.CONF -CONF.register_opts(notify_opts) +CONF = designate.conf.CONF NOTIFICATION_PLUGIN = None diff --git a/designate/opts.py b/designate/opts.py deleted file mode 100644 index 14b8eaf15..000000000 --- a/designate/opts.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2017 Fujitsu Ltd. -# -# Author: Nguyen Van Trung -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_db import options - -from designate import central -from designate.common import keystone -import designate -import designate.network_api -from designate.network_api import neutron -from designate import metrics -from designate.notification_handler import neutron as neutrons -from designate import notifications -from designate.notification_handler import nova -from designate.pool_manager.cache import impl_memcache -from designate.pool_manager.cache import impl_sqlalchemy as impl_sql -from designate import quota -from designate import scheduler -from designate.storage import impl_sqlalchemy as ssql -from designate import dnsutils -from designate import coordination as co -from designate import utils -from designate import service -from designate import service_status as stt - - -# TODO(trungnv): creating and auto-genconfig for: -# Hook Points. -def list_opts(): - yield None, designate.designate_opts - yield None, designate.network_api.neutron_opts - yield neutron.neutron_group, neutron.neutron_opts - yield metrics.metrics_group, metrics.metrics_opts - yield neutrons.neutron_group, neutrons.neutron_opts - yield nova.nova_group, nova.nova_opts - yield None, notifications.notify_opts - yield impl_memcache.memcache_group, impl_memcache.OPTS - yield impl_sql.sqlalchemy_group, impl_sql.options.database_opts - yield None, quota.quota_opts - yield central.central_group, scheduler.scheduler_opts - yield ssql.storage_group, options.database_opts - yield None, dnsutils.util_opts - yield co.coordination_group, co.coordination_opts - yield None, utils.helper_opts - yield utils.proxy_group, utils.proxy_opts - yield None, service.wsgi_socket_opts - yield stt.heartbeat_group, stt.heartbeat_opts - yield keystone.keystone_group, keystone.list_opts() diff --git a/designate/pool_manager/__init__.py b/designate/pool_manager/__init__.py index 1a3182ec4..8d619ac83 100644 --- a/designate/pool_manager/__init__.py +++ b/designate/pool_manager/__init__.py @@ -17,63 +17,6 @@ from oslo_config import cfg CONF = cfg.CONF -pool_manager_group = cfg.OptGroup( - name='service:pool_manager', title="Configuration for Pool Manager Service" -) - -OPTS = [ - cfg.IntOpt('workers', - help='Number of Pool Manager worker processes to spawn'), - cfg.IntOpt('threads', default=1000, - help='Number of Pool Manager greenthreads to spawn'), - cfg.StrOpt('pool-id', default='794ccc2c-d751-44fe-b57f-8894c9f5c842', - help='The ID of the pool managed by this instance of the ' - 'Pool Manager'), - cfg.IntOpt('threshold-percentage', default=100, - help='The percentage of servers requiring a successful update ' - 'for a zone change to be considered active', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.IntOpt('poll-timeout', default=30, - help='The time to wait for a response from a server', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.IntOpt('poll-retry-interval', default=15, - help='The time between retrying to send a request and ' - 'waiting for a response from a server', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.IntOpt('poll-max-retries', default=10, - help='The maximum number of times to retry sending a request ' - 'and wait for a response from a server', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.IntOpt('poll-delay', default=5, - help='The time to wait before sending the first request ' - 'to a server', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.BoolOpt('enable-recovery-timer', default=True, - help='The flag for the recovery timer'), - cfg.IntOpt('periodic-recovery-interval', default=120, - help='The time between recovering from failures'), - cfg.BoolOpt('enable-sync-timer', default=True, - help='The flag for the sync timer'), - cfg.IntOpt('periodic-sync-interval', default=1800, - help='The time between synchronizing the servers with storage'), - cfg.IntOpt('periodic-sync-seconds', default=21600, - help='Zones Updated within last N seconds will be syncd.' - 'Use an empty value to sync all zones.'), - cfg.IntOpt('periodic-sync-max-attempts', default=3, - help='Number of attempts to update a zone during sync'), - cfg.IntOpt('periodic-sync-retry-interval', default=30, - help='Interval between zone update attempts during sync'), - cfg.StrOpt('cache-driver', default='memcache', - help='The cache driver to use'), - cfg.StrOpt('pool_manager_topic', default='pool_manager', - help='RPC topic name for pool-manager') -] - def register_dynamic_pool_options(): # Pool Options Registration Pass One @@ -126,11 +69,3 @@ def register_dynamic_pool_options(): CONF.register_group(pool_nameserver_group) CONF.register_opts(pool_nameserver_opts, group=pool_nameserver_group) - - -cfg.CONF.register_group(pool_manager_group) -cfg.CONF.register_opts(OPTS, group=pool_manager_group) - - -def list_opts(): - yield pool_manager_group, OPTS diff --git a/designate/pool_manager/cache/impl_memcache/__init__.py b/designate/pool_manager/cache/impl_memcache/__init__.py index 7918defad..925c20c6a 100644 --- a/designate/pool_manager/cache/impl_memcache/__init__.py +++ b/designate/pool_manager/cache/impl_memcache/__init__.py @@ -29,19 +29,7 @@ from designate import objects from designate.common import memorycache from designate.pool_manager.cache import base as cache_base -memcache_group = cfg.OptGroup( - name='pool_manager_cache:memcache', - title="Configuration for memcache Pool Manager Cache" -) - - -OPTS = [ - cfg.IntOpt('expiration', default=3600, - help='Time in seconds to expire cache.') -] -OPTS.extend(memorycache.memcache_opts) - - +CONF = cfg.CONF DEFAULT_STATUS = 'NONE' @@ -52,8 +40,8 @@ class MemcachePoolManagerCache(cache_base.PoolManagerCache): super(MemcachePoolManagerCache, self).__init__() self.cache = memorycache.get_client( - cfg.CONF['pool_manager_cache:memcache'].memcached_servers) - self.expiration = cfg.CONF['pool_manager_cache:memcache'].expiration + CONF['pool_manager_cache:memcache'].memcached_servers) + self.expiration = CONF['pool_manager_cache:memcache'].expiration def get_name(self): return self.name @@ -125,6 +113,3 @@ class MemcachePoolManagerCache(cache_base.PoolManagerCache): def _build_status_key(self, pool_manager_status): return self._status_key(pool_manager_status, 'status') - -cfg.CONF.register_group(memcache_group) -cfg.CONF.register_opts(OPTS, group=memcache_group) diff --git a/designate/pool_manager/cache/impl_sqlalchemy/__init__.py b/designate/pool_manager/cache/impl_sqlalchemy/__init__.py index 56e4b90a1..349e4af78 100644 --- a/designate/pool_manager/cache/impl_sqlalchemy/__init__.py +++ b/designate/pool_manager/cache/impl_sqlalchemy/__init__.py @@ -14,7 +14,6 @@ # License for the specific language governing permissions and limitations # under the License. from oslo_config import cfg -from oslo_db import options from oslo_log import log as logging from designate import exceptions @@ -23,14 +22,9 @@ from designate.pool_manager.cache import base as cache_base from designate.sqlalchemy import base as sqlalchemy_base from designate.pool_manager.cache.impl_sqlalchemy import tables - +CONF = cfg.CONF LOG = logging.getLogger(__name__) -sqlalchemy_group = cfg.OptGroup( - name='pool_manager_cache:sqlalchemy', - title="Configuration for SQLAlchemy Pool Manager Cache" -) - class SQLAlchemyPoolManagerCache(sqlalchemy_base.SQLAlchemy, cache_base.PoolManagerCache): @@ -73,6 +67,3 @@ class SQLAlchemyPoolManagerCache(sqlalchemy_base.SQLAlchemy, context, tables.pool_manager_statuses, objects.PoolManagerStatus, objects.PoolManagerStatusList, exceptions.PoolManagerStatusNotFound, criterion, one=True) - -cfg.CONF.register_group(sqlalchemy_group) -cfg.CONF.register_opts(options.database_opts, group=sqlalchemy_group) diff --git a/designate/producer/__init__.py b/designate/producer/__init__.py index 7302bdaf3..e69de29bb 100644 --- a/designate/producer/__init__.py +++ b/designate/producer/__init__.py @@ -1,121 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Endre Karlson -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from oslo_config import cfg - -from designate.producer import tasks - -CONF = cfg.CONF - -producer_group = cfg.OptGroup( - name='service:producer', title="Configuration for Producer Service" -) - -OPTS = [ - cfg.IntOpt('workers', - help='Number of Producer worker processes to spawn'), - cfg.IntOpt('threads', default=1000, - help='Number of Producer greenthreads to spawn'), - cfg.ListOpt('enabled_tasks', - help='Enabled tasks to run'), - cfg.StrOpt('storage-driver', default='sqlalchemy', - help='The storage driver to use'), - cfg.BoolOpt('export-synchronous', default=True, - help='Whether to allow synchronous zone exports', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), -] - -# TODO(timsim): Remove these when zone-manager is removed -zone_manager_group = cfg.OptGroup( - name='service:zone_manager', title="Configuration for Zone Manager Service" -) - -ZONEMGROPTS = [ - cfg.IntOpt('workers', - help='Number of Zone Manager worker processes to spawn', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.IntOpt('threads', default=1000, - help='Number of Zone Manager greenthreads to spawn', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.ListOpt('enabled_tasks', - help='Enabled tasks to run', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.StrOpt('storage-driver', default='sqlalchemy', - help='The storage driver to use', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), - cfg.BoolOpt('export-synchronous', default=True, - help='Whether to allow synchronous zone exports', - deprecated_for_removal=True, - deprecated_reason='Migrated to designate-worker'), -] - - -cfg.CONF.register_group(producer_group) -cfg.CONF.register_opts(OPTS, group=producer_group) - -cfg.CONF.register_group(zone_manager_group) -cfg.CONF.register_opts(ZONEMGROPTS, group=zone_manager_group) - -# NOTE(trungnv): Get [producer_task:zone_purge] config -zone_purge_opts = tasks.DeletedZonePurgeTask.get_cfg_opts()[0][1] -zone_purge_old_group = tasks.DeletedZonePurgeTask.get_cfg_opts()[0][0].name -zone_purge_group = cfg.OptGroup(zone_purge_old_group) -cfg.CONF.register_group(zone_purge_group) -cfg.CONF.register_opts(zone_purge_opts, group=zone_purge_group) - -# NOTE(trungnv): Get [producer_task:periodic_exists] config -periodic_exists_opts = tasks.PeriodicExistsTask.get_cfg_opts()[0][1] -periodic_exists_old_group = tasks.PeriodicExistsTask.get_cfg_opts()[0][0].name -periodic_exists_group = cfg.OptGroup(periodic_exists_old_group) -cfg.CONF.register_group(periodic_exists_group) -cfg.CONF.register_opts(periodic_exists_opts, group=periodic_exists_group) - -# NOTE(trungnv): Get [producer_task:periodic_secondary_refresh] config -psr_opts = tasks.PeriodicSecondaryRefreshTask.get_cfg_opts()[0][1] -psr_old_group = tasks.PeriodicSecondaryRefreshTask.get_cfg_opts()[0][0].name -psr_group = cfg.OptGroup(psr_old_group) -cfg.CONF.register_group(psr_group) -cfg.CONF.register_opts(psr_opts, group=psr_group) - -# NOTE(trungnv): Get [producer_task:delayed_notify] config -delayed_notify_opts =\ - tasks.PeriodicGenerateDelayedNotifyTask.get_cfg_opts()[0][1] -delayed_notify_old_group =\ - tasks.PeriodicGenerateDelayedNotifyTask.get_cfg_opts()[0][0].name -delayed_notify_group = cfg.OptGroup(delayed_notify_old_group) -cfg.CONF.register_group(delayed_notify_group) -cfg.CONF.register_opts(delayed_notify_opts, group=delayed_notify_group) - -# NOTE(trungnv): Get [producer_task:worker_periodic_recovery] config -wpr_opts = tasks.WorkerPeriodicRecovery.get_cfg_opts()[0][1] -wpr_old_group = tasks.WorkerPeriodicRecovery.get_cfg_opts()[0][0].name -wpr_group = cfg.OptGroup(wpr_old_group) -cfg.CONF.register_group(wpr_group) -cfg.CONF.register_opts(wpr_opts, group=wpr_group) - - -def list_opts(): - yield producer_group, OPTS - yield zone_manager_group, ZONEMGROPTS - yield zone_purge_group, zone_purge_opts - yield periodic_exists_group, periodic_exists_opts - yield psr_group, psr_opts - yield delayed_notify_group, delayed_notify_opts - yield wpr_group, wpr_opts diff --git a/designate/quota/__init__.py b/designate/quota/__init__.py index 28dc37d2e..a2e182196 100644 --- a/designate/quota/__init__.py +++ b/designate/quota/__init__.py @@ -21,23 +21,6 @@ from designate.quota import base LOG = logging.getLogger(__name__) -quota_opts = [ - cfg.StrOpt('quota-driver', default='storage', help='Quota driver to use'), - - cfg.IntOpt('quota-zones', default=10, - help='Number of zones allowed per tenant'), - cfg.IntOpt('quota-zone-recordsets', default=500, - help='Number of recordsets allowed per zone'), - cfg.IntOpt('quota-zone-records', default=500, - help='Number of records allowed per zone'), - cfg.IntOpt('quota-recordset-records', default=20, - help='Number of records allowed per recordset'), - cfg.IntOpt('quota-api-export-size', default=1000, - help='Number of recordsets allowed in a zone export'), -] - -cfg.CONF.register_opts(quota_opts) - def get_quota(): quota_driver = cfg.CONF.quota_driver diff --git a/designate/rpc.py b/designate/rpc.py index df6c8d463..74b9231f4 100644 --- a/designate/rpc.py +++ b/designate/rpc.py @@ -43,13 +43,6 @@ NOTIFIER = None TRANSPORT = None # NOTE: Additional entries to designate.exceptions goes here. -CONF.register_opts([ - cfg.ListOpt( - 'allowed_remote_exmods', - default=[], - help="Additional modules that contains allowed RPC exceptions.", - deprecated_name='allowed_rpc_exception_modules') -]) ALLOWED_EXMODS = [ designate.exceptions.__name__, 'designate.backend.impl_dynect' diff --git a/designate/scheduler/__init__.py b/designate/scheduler/__init__.py index 3169ac72b..c6ba983aa 100644 --- a/designate/scheduler/__init__.py +++ b/designate/scheduler/__init__.py @@ -12,23 +12,7 @@ # 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 designate.scheduler import base -from designate import central - -LOG = logging.getLogger(__name__) - -scheduler_opts = [ - cfg.ListOpt( - 'scheduler_filters', - default=['default_pool'], - help='Enabled Pool Scheduling filters'), -] - -cfg.CONF.register_group(central.central_group) -cfg.CONF.register_opts(scheduler_opts, group=central.central_group) def get_scheduler(storage): diff --git a/designate/service.py b/designate/service.py index 1078b8a51..83477eb85 100644 --- a/designate/service.py +++ b/designate/service.py @@ -25,13 +25,14 @@ import errno import six import eventlet.wsgi import eventlet.debug -import oslo_messaging as messaging from oslo_config import cfg +import oslo_messaging as messaging from oslo_log import log as logging from oslo_service import service from oslo_service import sslutils from oslo_utils import netutils +import designate.conf from designate.i18n import _ from designate.metrics import metrics from designate import policy @@ -43,19 +44,9 @@ from designate import utils # TODO(kiall): These options have been cut+paste from the old WSGI code, and # should be moved into service:api etc.. -wsgi_socket_opts = [ - cfg.IntOpt('backlog', - default=4096, - help="Number of backlog requests to configure the socket with"), - cfg.IntOpt('tcp_keepidle', - default=600, - help="Sets the value of TCP_KEEPIDLE in seconds for each " - "server socket. Not supported on OS X."), -] -CONF = cfg.CONF -CONF.register_opts(wsgi_socket_opts) +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -145,7 +136,7 @@ class RPCService(object): self._rpc_endpoints) emitter_cls = service_status.HeartBeatEmitter.get_driver( - cfg.CONF.heartbeat_emitter.emitter_type + CONF.heartbeat_emitter.emitter_type ) self.heartbeat_emitter = emitter_cls( self.service_name, self.tg, status_factory=self._get_status diff --git a/designate/service_status.py b/designate/service_status.py index 2a922a18e..bf4a2044b 100644 --- a/designate/service_status.py +++ b/designate/service_status.py @@ -13,32 +13,17 @@ # under the License. import abc -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils +import designate.conf from designate import context from designate import objects from designate import plugin from designate.central import rpcapi as central_rpcapi -heartbeat_group = cfg.OptGroup( - name='heartbeat_emitter', - title="Configuration for heartbeat_emitter" - ) - -heartbeat_opts = [ - cfg.FloatOpt('heartbeat_interval', - default=5.0, - help='Number of seconds between heartbeats for reporting ' - 'state'), - cfg.StrOpt('emitter_type', default="rpc", help="Emitter to use") -] - -CONF = cfg.CONF -CONF.register_group(heartbeat_group) -CONF.register_opts(heartbeat_opts, group=heartbeat_group) +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) @@ -55,7 +40,7 @@ class HeartBeatEmitter(plugin.DriverPlugin): self._running = False self._tg = threadgroup self._tg.add_timer( - cfg.CONF.heartbeat_emitter.heartbeat_interval, + CONF.heartbeat_emitter.heartbeat_interval, self._emit_heartbeat) self._status_factory = status_factory diff --git a/designate/sink/__init__.py b/designate/sink/__init__.py index c6557cfc6..e69de29bb 100644 --- a/designate/sink/__init__.py +++ b/designate/sink/__init__.py @@ -1,42 +0,0 @@ -# Copyright 2012 Hewlett-Packard Development Company, L.P. All Rights Reserved. -# -# Author: Kiall Mac Innes -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from oslo_config import cfg - -sink_group = cfg.OptGroup( - name='service:sink', title="Configuration for Sink Service" -) - -OPTS = [ - cfg.IntOpt('workers', - help='Number of sink worker processes to spawn'), - cfg.IntOpt('threads', default=1000, - help='Number of sink greenthreads to spawn'), - cfg.ListOpt('enabled-notification-handlers', default=[], - help='Enabled Notification Handlers'), - cfg.StrOpt('listener-pool-name', - help='pool name to use for oslo.messaging ' - 'notification listener. ' - 'Note that listener pooling is not supported ' - 'by all oslo.messaging drivers.'), -] - - -cfg.CONF.register_group(sink_group) -cfg.CONF.register_opts(OPTS, group=sink_group) - - -def list_opts(): - yield sink_group, OPTS diff --git a/designate/storage/impl_sqlalchemy/__init__.py b/designate/storage/impl_sqlalchemy/__init__.py index 03bc8b1a6..3c95aaad1 100644 --- a/designate/storage/impl_sqlalchemy/__init__.py +++ b/designate/storage/impl_sqlalchemy/__init__.py @@ -16,9 +16,7 @@ import time import hashlib -from oslo_config import cfg from oslo_log import log as logging -from oslo_db import options from sqlalchemy import select, distinct, func from sqlalchemy.sql.expression import or_ @@ -33,13 +31,6 @@ LOG = logging.getLogger(__name__) MAXIMUM_SUBZONE_DEPTH = 128 -storage_group = cfg.OptGroup( - name='storage:sqlalchemy', title="Configuration for SQLAlchemy Storage" -) - -cfg.CONF.register_group(storage_group) -cfg.CONF.register_opts(options.database_opts, group=storage_group) - class SQLAlchemyStorage(sqlalchemy_base.SQLAlchemy, storage_base.Storage): """SQLAlchemy connection""" diff --git a/designate/tests/__init__.py b/designate/tests/__init__.py index 7f7616703..bd7e66f1e 100644 --- a/designate/tests/__init__.py +++ b/designate/tests/__init__.py @@ -20,46 +20,46 @@ import inspect import os import time -from testtools import testcase -from oslotest import base -from oslo_log import log as logging +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 +from oslotest import base +from testtools import testcase -from designate import policy -from designate import utils +import designate.conf from designate import exceptions from designate import objects +from designate import policy from designate import storage +from designate import utils from designate.context import DesignateContext +from designate.manage import database as manage_database from designate.tests import fixtures from designate.tests import resources -from designate.manage import database as manage_database - -import eventlet eventlet.monkey_patch(os=False) - +CONF = designate.conf.CONF LOG = logging.getLogger(__name__) -cfg.CONF.import_opt('storage_driver', 'designate.central', - group='service:central') -cfg.CONF.import_opt('auth_strategy', 'designate.api', - group='service:api') -cfg.CONF.import_opt('connection', 'designate.storage.impl_sqlalchemy', - group='storage:sqlalchemy') -cfg.CONF.import_opt('cache_driver', 'designate.pool_manager', - group='service:pool_manager') -cfg.CONF.import_opt('connection', - 'designate.pool_manager.cache.impl_sqlalchemy', - group='pool_manager_cache:sqlalchemy') -cfg.CONF.import_opt('emitter_type', 'designate.service_status', - group="heartbeat_emitter") -cfg.CONF.import_opt('scheduler_filters', 'designate.scheduler', - group="service:central") -default_pool_id = cfg.CONF['service:central'].default_pool_id +CONF.import_opt('storage_driver', 'designate.central', + group='service:central') +CONF.import_opt('auth_strategy', 'designate.api', + group='service:api') +CONF.import_opt('connection', 'designate.storage.impl_sqlalchemy', + group='storage:sqlalchemy') +CONF.import_opt('cache_driver', 'designate.pool_manager', + group='service:pool_manager') +CONF.import_opt('connection', + 'designate.pool_manager.cache.impl_sqlalchemy', + group='pool_manager_cache:sqlalchemy') +CONF.import_opt('emitter_type', 'designate.service_status', + 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') @@ -327,16 +327,16 @@ class TestCase(base.BaseTestCase): def setUp(self): super(TestCase, self).setUp() - self.CONF = self.useFixture(cfg_fixture.Config(cfg.CONF)).conf + self.CONF = self.useFixture(cfg_fixture.Config(CONF)).conf - self.messaging_conf = messaging_fixture.ConfFixture(cfg.CONF) + self.messaging_conf = messaging_fixture.ConfFixture(CONF) self.messaging_conf.transport_url = 'fake:/' self.messaging_conf.response_timeout = 5 self.useFixture(self.messaging_conf) self.config(notification_driver=['test']) - self.useFixture(fixtures.RPCFixture(cfg.CONF)) + self.useFixture(fixtures.RPCFixture(CONF)) self.config( storage_driver='sqlalchemy', @@ -392,7 +392,7 @@ class TestCase(base.BaseTestCase): self.central_service = self.start_service('central') self.admin_context = self.get_admin_context() - storage_driver = cfg.CONF['service:central'].storage_driver + storage_driver = CONF['service:central'].storage_driver self.storage = storage.get_storage(storage_driver) # Setup the Default Pool with some useful settings diff --git a/designate/tests/test_agent/test_backends/test_djbdns.py b/designate/tests/test_agent/test_backends/test_djbdns.py index 7e0af0f35..5039a0b5a 100644 --- a/designate/tests/test_agent/test_backends/test_djbdns.py +++ b/designate/tests/test_agent/test_backends/test_djbdns.py @@ -61,7 +61,7 @@ class DjbdnsAgentBackendTestCase(TestCase): self.CONF.set_override( 'tinydns_datadir', tmp_datafiles_dir, - designate.backend.agent_backend.impl_djbdns.CFG_GROUP + designate.backend.agent_backend.impl_djbdns.CFG_GROUP_NAME, ) self.useFixture(fixtures.MockPatchObject( DjbdnsBackend, '_check_dirs' diff --git a/designate/tests/test_agent/test_backends/test_gdnsd.py b/designate/tests/test_agent/test_backends/test_gdnsd.py index 1d21bb834..8ab23ea59 100644 --- a/designate/tests/test_agent/test_backends/test_gdnsd.py +++ b/designate/tests/test_agent/test_backends/test_gdnsd.py @@ -37,7 +37,7 @@ import mock import testtools from designate import exceptions -from designate.backend.agent_backend.impl_gdnsd import CFG_GROUP +from designate.backend.agent_backend.impl_gdnsd import CFG_GROUP_NAME from designate.backend.agent_backend.impl_gdnsd import GdnsdBackend from designate.tests import TestCase @@ -62,8 +62,10 @@ class GdnsdAgentBackendTestCase(TestCase): self.zones_dir_path = os.path.join(self.conf_dir_path, 'zones') os.mkdir(self.zones_dir_path) self.CONF = self.useFixture(cfg_fixture.Config(cfg.CONF)).conf - cfg.CONF.set_override('confdir_path', self.conf_dir_path, CFG_GROUP) - cfg.CONF.set_override('gdnsd_cmd_name', GDNSD_BIN_PATH, CFG_GROUP) + cfg.CONF.set_override('confdir_path', self.conf_dir_path, + CFG_GROUP_NAME) + cfg.CONF.set_override('gdnsd_cmd_name', GDNSD_BIN_PATH, + CFG_GROUP_NAME) self.backend = GdnsdBackend('foo') diff --git a/designate/utils.py b/designate/utils.py index d0de864cc..487b88b6a 100644 --- a/designate/utils.py +++ b/designate/utils.py @@ -36,34 +36,6 @@ from designate.i18n import _ LOG = logging.getLogger(__name__) - -helper_opts = [ - cfg.StrOpt('root-helper', - default='sudo designate-rootwrap /etc/designate/rootwrap.conf', - help='designate-rootwrap configuration') -] - - -# Set some proxy options (Used for clients that need to communicate via a -# proxy) -proxy_group = cfg.OptGroup( - name='proxy', title="Configuration for Client Proxy" -) - -proxy_opts = [ - cfg.StrOpt('http_proxy', - help='Proxy HTTP requests via this proxy.'), - cfg.StrOpt('https_proxy', - help='Proxy HTTPS requests via this proxy'), - cfg.ListOpt('no_proxy', default=[], - help='These addresses should not be proxied') -] - - -cfg.CONF.register_opts(helper_opts) -cfg.CONF.register_group(proxy_group) -cfg.CONF.register_opts(proxy_opts, proxy_group) - # Default TCP/UDP ports DEFAULT_AGENT_PORT = 5358 diff --git a/designate/worker/__init__.py b/designate/worker/__init__.py index 4e6c9e232..e69de29bb 100644 --- a/designate/worker/__init__.py +++ b/designate/worker/__init__.py @@ -1,68 +0,0 @@ -# Copyright 2016 Rackspace Inc. -# -# Author: Tim Simmons -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from oslo_config import cfg - -CONF = cfg.CONF - -worker_group = cfg.OptGroup( - name='service:worker', title="Configuration for the Worker Service" -) - -OPTS = [ - cfg.BoolOpt('enabled', default=True, - help='Whether to send events to worker instead of ' - 'Pool Manager', - deprecated_for_removal=True, - deprecated_reason='In Train, this option will disappear' - 'because pool manager will be removed'), - cfg.IntOpt('workers', - help='Number of Worker worker processes to spawn'), - cfg.IntOpt('threads', default=200, - help='Number of Worker threads to spawn per process'), - # cfg.ListOpt('enabled_tasks', - # help='Enabled tasks to run'), - cfg.StrOpt('storage-driver', default='sqlalchemy', - help='The storage driver to use'), - cfg.IntOpt('threshold-percentage', default=100, - help='The percentage of servers requiring a successful update ' - 'for a domain change to be considered active'), - cfg.IntOpt('poll-timeout', default=30, - help='The time to wait for a response from a server'), - cfg.IntOpt('poll-retry-interval', default=15, - help='The time between retrying to send a request and ' - 'waiting for a response from a server'), - cfg.IntOpt('poll-max-retries', default=10, - help='The maximum number of times to retry sending a request ' - 'and wait for a response from a server'), - cfg.IntOpt('poll-delay', default=5, - help='The time to wait before sending the first request ' - 'to a server'), - cfg.BoolOpt('notify', default=True, - help='Whether to allow worker to send NOTIFYs, this will ' - 'noop NOTIFYs in mdns if true'), - cfg.BoolOpt('export-synchronous', default=True, - help='Whether to allow synchronous zone exports'), - cfg.StrOpt('worker_topic', default='worker', - help='RPC topic for worker component') -] - - -cfg.CONF.register_group(worker_group) -cfg.CONF.register_opts(OPTS, group=worker_group) - - -def list_opts(): - yield worker_group, OPTS diff --git a/doc/source/conf.py b/doc/source/conf.py index be6bcdc1e..feb1111b9 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -74,6 +74,7 @@ copyright = u'2012, Managed I.T.' # built documents. # # The short X.Y version. +import designate.conf # noqa from designate.version import version_info as designate_version version = designate_version.canonical_version_string() # The full version, including alpha/beta/rc tags. diff --git a/etc/designate/designate-config-generator.conf b/etc/designate/designate-config-generator.conf index 9539f8e28..d35bbceb8 100644 --- a/etc/designate/designate-config-generator.conf +++ b/etc/designate/designate-config-generator.conf @@ -1,19 +1,7 @@ [DEFAULT] -output_file = etc/designate/designate.conf +output_file = etc/designate/designate.conf.sample wrap_width = 80 - - -# NOTE(trungnv): generating a opts config location -namespace = designate.opts -namespace = designate.agent -namespace = designate.api -namespace = designate.central -namespace = designate.mdns -namespace = designate.pool_manager -namespace = designate.sink -namespace = designate.worker -namespace = designate.producer - +namespace = designate.conf namespace = oslo.log namespace = oslo.messaging namespace = oslo.policy diff --git a/setup.cfg b/setup.cfg index 7c4c4a4a8..83c282b18 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,18 +36,11 @@ data_files = [entry_points] oslo.config.opts = - designate.opts = designate.opts:list_opts - designate.agent = designate.agent:list_opts - designate.api = designate.api:list_opts - designate.central = designate.central:list_opts - designate.mdns = designate.mdns:list_opts - designate.pool_manager = designate.pool_manager:list_opts - designate.sink = designate.sink:list_opts - designate.worker = designate.worker:list_opts - designate.producer = designate.producer:list_opts + designate.conf = designate.conf.opts:list_opts + oslo.config.opts.defaults = - designate.api = designate.common.config:set_defaults + designate.conf = designate.common.config:set_defaults oslo.policy.policies = designate = designate.common.policies:list_rules