diff --git a/designate/__init__.py b/designate/__init__.py index e83d2ed99..1baea0fb3 100644 --- a/designate/__init__.py +++ b/designate/__init__.py @@ -27,7 +27,7 @@ from oslo_concurrency import lockutils import oslo_messaging as messaging -cfg.CONF.register_opts([ +designate_opts = [ cfg.StrOpt('host', default=socket.gethostname(), help='Name of this node'), cfg.StrOpt( @@ -46,21 +46,23 @@ cfg.CONF.register_opts([ cfg.StrOpt('worker-topic', default='worker', help='Worker Topic'), # Default TTL - cfg.IntOpt('default-ttl', default=3600), + 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'), - cfg.IntOpt('default-soa-refresh-max', default=3600), - cfg.IntOpt('default-soa-retry', default=600), - cfg.IntOpt('default-soa-expire', default=86400), - cfg.IntOpt('default-soa-minimum', default=3600), + 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']), -]) +] # Set some Oslo Log defaults log.set_defaults(default_log_levels=[ @@ -84,3 +86,5 @@ 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 3dbb8d08e..e17f24903 100644 --- a/designate/agent/__init__.py +++ b/designate/agent/__init__.py @@ -17,12 +17,19 @@ 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 -cfg.CONF.register_group(cfg.OptGroup( + +agent_group = cfg.OptGroup( name='service:agent', title="Configuration for the Agent Service" -)) +) -OPTS = [ +agent_opts = [ cfg.IntOpt('workers', help='Number of agent worker processes to spawn'), cfg.IntOpt('threads', default=1000, @@ -55,4 +62,15 @@ OPTS = [ 'will pause and drop subsequent NOTIFYs for that zone'), ] -cfg.CONF.register_opts(OPTS, group='service:agent') +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 5903e7e2e..8e18c8d23 100644 --- a/designate/api/__init__.py +++ b/designate/api/__init__.py @@ -16,18 +16,23 @@ from oslo_config import cfg -cfg.CONF.register_group(cfg.OptGroup( +api_group = cfg.OptGroup( name='service:api', title="Configuration for API Service" -)) +) -cfg.CONF.register_opts([ +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/'), + 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", @@ -46,13 +51,73 @@ cfg.CONF.register_opts([ 'keystone'), cfg.BoolOpt('enable-api-v1', default=False, deprecated_for_removal=True, - deprecated_reason=("V1 API is being removed in a future" - "release")), - cfg.BoolOpt('enable-api-v2', default=True), - cfg.BoolOpt('enable-api-admin', default=False), + deprecated_reason="V1 API is being removed in a future" + "release", + help='enable-api-v1 which removed in a future'), + 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)."), -], group='service:api') +] + +api_v1_opts = [ + cfg.ListOpt('enabled-extensions-v1', default=[], + help='Enabled API Extensions'), +] + +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'), +] + +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_v1_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_v1_opts + yield api_group, api_v2_opts + yield api_group, api_admin_opts + yield api_group, api_middleware_opts diff --git a/designate/api/admin/__init__.py b/designate/api/admin/__init__.py index 0a617fec4..1ac7bd6e9 100644 --- a/designate/api/admin/__init__.py +++ b/designate/api/admin/__init__.py @@ -18,18 +18,6 @@ from oslo_log import log as logging LOG = logging.getLogger(__name__) -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'), -] - -cfg.CONF.register_opts(OPTS, group='service:api') - def factory(global_config, **local_conf): if not cfg.CONF['service:api'].enable_api_admin: diff --git a/designate/api/middleware.py b/designate/api/middleware.py index 0a941de89..15acacc84 100644 --- a/designate/api/middleware.py +++ b/designate/api/middleware.py @@ -37,22 +37,6 @@ from designate.i18n import _LC LOG = logging.getLogger(__name__) -cfg.CONF.register_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.") -], group='service:api') - def auth_pipeline_factory(loader, global_conf, **local_conf): """ diff --git a/designate/api/v1/__init__.py b/designate/api/v1/__init__.py index d285b7461..e76e17868 100644 --- a/designate/api/v1/__init__.py +++ b/designate/api/v1/__init__.py @@ -31,11 +31,6 @@ from designate import utils LOG = logging.getLogger(__name__) -cfg.CONF.register_opts([ - cfg.ListOpt('enabled-extensions-v1', default=[], - help='Enabled API Extensions'), -], group='service:api') - class DesignateRequest(flask.Request, wrappers.AcceptMixin, wrappers.CommonRequestDescriptorsMixin): diff --git a/designate/api/v2/__init__.py b/designate/api/v2/__init__.py index 482ccff59..e7cda5a14 100644 --- a/designate/api/v2/__init__.py +++ b/designate/api/v2/__init__.py @@ -20,18 +20,6 @@ from oslo_log import log as logging LOG = logging.getLogger(__name__) -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.CONF.register_opts(OPTS, group='service:api') - def factory(global_config, **local_conf): if not cfg.CONF['service:api'].enable_api_v2: diff --git a/designate/backend/agent_backend/impl_bind9.py b/designate/backend/agent_backend/impl_bind9.py index 461b4bab5..1acdca63c 100644 --- a/designate/backend/agent_backend/impl_bind9.py +++ b/designate/backend/agent_backend/impl_bind9.py @@ -26,9 +26,31 @@ from designate import exceptions from designate import utils from designate.i18n import _LI + 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' @@ -37,23 +59,7 @@ class Bind9Backend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - group = cfg.OptGroup( - name='backend:agent:bind9', title="Configuration for bind9 backend" - ) - - 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') - ] - - return [(group, opts)] + return [(bind9_group, bind9_opts)] def start(self): LOG.info(_LI("Started bind9 backend")) diff --git a/designate/backend/agent_backend/impl_denominator.py b/designate/backend/agent_backend/impl_denominator.py index 9ad5a2a64..c110d2605 100644 --- a/designate/backend/agent_backend/impl_denominator.py +++ b/designate/backend/agent_backend/impl_denominator.py @@ -31,6 +31,22 @@ from designate.i18n import _LI 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): @@ -98,19 +114,7 @@ class DenominatorBackend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - group = cfg.OptGroup( - name=CFG_GROUP, - title='Backend options for 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') - ] - - return [(group, opts)] + return [(denominator_group, denominator_opts)] def start(self): LOG.info(_LI("Started Denominator backend")) diff --git a/designate/backend/agent_backend/impl_djbdns.py b/designate/backend/agent_backend/impl_djbdns.py index 3546ea66e..19e5830b1 100755 --- a/designate/backend/agent_backend/impl_djbdns.py +++ b/designate/backend/agent_backend/impl_djbdns.py @@ -57,6 +57,7 @@ from designate.i18n import _LI from designate.i18n import _LE from designate.utils import execute + LOG = logging.getLogger(__name__) CFG_GROUP = 'backend:agent:djbdns' # rootwrap requires a command name instead of full path @@ -67,6 +68,39 @@ 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 @@ -94,35 +128,7 @@ class DjbdnsBackend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - group = cfg.OptGroup( - name='backend:agent:djbdns', - title="Configuration for Djbdns backend" - ) - opts = [ - cfg.StrOpt( - 'tcpclient-cmd-name', - help='tcpclient executable path or rootwrap command name', - default=TCPCLIENT_DEFAULT_PATH - ), - cfg.StrOpt( - 'axfr-get-cmd-name', - help='axfr-get executable path or rootwrap command name', - default=AXFR_GET_DEFAULT_PATH - ), - cfg.StrOpt( - 'tinydns-data-cmd-name', - help='tinydns-data executable path or rootwrap command name', - default=TINYDNS_DATA_DEFAULT_PATH - ), - cfg.StrOpt( - 'tinydns-datadir', - help='TinyDNS data directory', - default=TINYDNS_DATADIR_DEFAULT_PATH - ), - cfg.StrOpt('query-destination', default='127.0.0.1', - help='Host to query when finding zones') - ] - return [(group, opts)] + return [(djbdns_group, djbdns_opts)] def __init__(self, *a, **kw): """Configure the backend""" diff --git a/designate/backend/agent_backend/impl_gdnsd.py b/designate/backend/agent_backend/impl_gdnsd.py index 46724c9af..838bb3828 100644 --- a/designate/backend/agent_backend/impl_gdnsd.py +++ b/designate/backend/agent_backend/impl_gdnsd.py @@ -54,6 +54,7 @@ from designate.backend.agent_backend import base from designate.i18n import _LI from designate.i18n import _LE + LOG = logging.getLogger(__name__) CFG_GROUP = 'backend:agent:gdnsd' # rootwrap requires a command name instead of full path @@ -63,6 +64,25 @@ 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() @@ -84,20 +104,7 @@ class GdnsdBackend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - group = cfg.OptGroup( - name=CFG_GROUP, title="Configuration for gdnsd backend" - ) - opts = [ - cfg.StrOpt('gdnsd-cmd-name', - help='gdnsd executable path or rootwrap command name', - default=GDNSD_DEFAULT_PATH), - cfg.StrOpt('confdir-path', - help='gdnsd configuration directory path', - default=CONFDIR_PATH), - cfg.StrOpt('query-destination', default='127.0.0.1', - help='Host to query when finding zones') - ] - return [(group, opts)] + return [(gdnsd_group, gdnsd_opts)] def __init__(self, *a, **kw): """Configure the backend""" diff --git a/designate/backend/agent_backend/impl_knot2.py b/designate/backend/agent_backend/impl_knot2.py index bf72ab785..5d76a08c9 100755 --- a/designate/backend/agent_backend/impl_knot2.py +++ b/designate/backend/agent_backend/impl_knot2.py @@ -49,6 +49,7 @@ from designate.i18n import _LI from designate.i18n import _LE from designate.utils import execute + LOG = logging.getLogger(__name__) CFG_GROUP = 'backend:agent:knot2' # rootwrap requires a command name instead of full path @@ -58,6 +59,30 @@ 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' @@ -66,17 +91,7 @@ class Knot2Backend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - group = cfg.OptGroup( - name='backend:agent:knot2', title="Configuration for Knot2 backend" - ) - opts = [ - cfg.StrOpt('knotc-cmd-name', - help='knotc executable path or rootwrap command name', - default=KNOTC_DEFAULT_PATH), - cfg.StrOpt('query-destination', default='127.0.0.1', - help='Host to query when finding zones') - ] - return [(group, opts)] + return [(knot2_group, knot2_opts)] def __init__(self, *a, **kw): """Configure the backend""" diff --git a/designate/backend/agent_backend/impl_msdns.py b/designate/backend/agent_backend/impl_msdns.py index c86a128c3..0f9ee1abf 100644 --- a/designate/backend/agent_backend/impl_msdns.py +++ b/designate/backend/agent_backend/impl_msdns.py @@ -29,11 +29,17 @@ from designate.i18n import _LI LOG = logging.getLogger(__name__) CFG_GROUP = 'backend:agent:msdns' -GROUP = cfg.OptGroup( - name=CFG_GROUP, +"""GROUP = backend:agent:msdns""" +msdns_group = cfg.OptGroup( + name='backend:agent:msdns', title="Configuration for Microsoft DNS Server" ) -OPTS = [] +msdns_opts = [ + +] + +cfg.CONF.register_group(msdns_group) +cfg.CONF.register_opts(msdns_opts, group=msdns_group) class MSDNSBackend(base.AgentBackend): @@ -57,7 +63,7 @@ class MSDNSBackend(base.AgentBackend): @classmethod def get_cfg_opts(cls): - return [(GROUP, OPTS)] + return [(msdns_group, msdns_opts)] def start(self): """Start the backend""" diff --git a/designate/central/__init__.py b/designate/central/__init__.py index c964f4ba0..801cd516a 100644 --- a/designate/central/__init__.py +++ b/designate/central/__init__.py @@ -15,11 +15,11 @@ # under the License. from oslo_config import cfg -cfg.CONF.register_group(cfg.OptGroup( +central_group = cfg.OptGroup( name='service:central', title="Configuration for Central Service" -)) +) -cfg.CONF.register_opts([ +OPTS = [ cfg.IntOpt('workers', help='Number of central worker processes to spawn'), cfg.IntOpt('threads', default=1000, @@ -46,4 +46,11 @@ cfg.CONF.register_opts([ cfg.StrOpt('central_topic', default='central', help="RPC topic name of central service."), -], group='service:central') +] + +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/coordination.py b/designate/coordination.py index 541d6aaa5..21641d36f 100644 --- a/designate/coordination.py +++ b/designate/coordination.py @@ -32,7 +32,11 @@ from designate.i18n import _LE LOG = log.getLogger(__name__) -OPTS = [ +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 ' @@ -47,7 +51,8 @@ OPTS = [ 'membership has changed') ] -cfg.CONF.register_opts(OPTS, group='coordination') +cfg.CONF.register_group(coordination_group) +cfg.CONF.register_opts(coordination_opts, group=coordination_group) CONF = cfg.CONF diff --git a/designate/dnsutils.py b/designate/dnsutils.py index 39c594182..a763881c2 100644 --- a/designate/dnsutils.py +++ b/designate/dnsutils.py @@ -41,6 +41,8 @@ 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""" diff --git a/designate/mdns/__init__.py b/designate/mdns/__init__.py index 0a15c42d4..de1a3fae1 100644 --- a/designate/mdns/__init__.py +++ b/designate/mdns/__init__.py @@ -20,9 +20,9 @@ from designate import dnsutils from designate.utils import DEFAULT_MDNS_PORT -cfg.CONF.register_group(cfg.OptGroup( +mdns_group = cfg.OptGroup( name='service:mdns', title="Configuration for mDNS Service" -)) +) OPTS = [ cfg.IntOpt('workers', @@ -57,5 +57,11 @@ OPTS = [ help='RPC topic name for mini-DNS') ] -cfg.CONF.register_opts(OPTS, group='service:mdns') -cfg.CONF.register_opts(dnsutils.util_opts, group='service:mdns') + +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 68569516a..614386f46 100644 --- a/designate/metrics.py +++ b/designate/metrics.py @@ -49,15 +49,18 @@ stats_client = importutils.import_any('monascastatsd', LOG = logging.getLogger(__name__) CFG_GROUP = 'monasca:statsd' -cfg.CONF.register_group(cfg.OptGroup( +metrics_group = cfg.OptGroup( name=CFG_GROUP, title="Configuration for Monasca Statsd" -)) +) -cfg.CONF.register_opts([ +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') -], group=CFG_GROUP) +] + +cfg.CONF.register_group(metrics_group) +cfg.CONF.register_opts(metrics_opts, group=metrics_group) # Global metrics client to be imported by other modules diff --git a/designate/network_api/__init__.py b/designate/network_api/__init__.py index ee8c3dcf2..56ec35eb5 100644 --- a/designate/network_api/__init__.py +++ b/designate/network_api/__init__.py @@ -22,9 +22,11 @@ from designate.network_api import base LOG = log.getLogger(__name__) -cfg.CONF.register_opts([ +neutron_opts = [ cfg.StrOpt('network_api', default='neutron', help='Which API to use.') -]) +] + +cfg.CONF.register_opts(neutron_opts) def get_network_api(network_api_driver): diff --git a/designate/network_api/neutron.py b/designate/network_api/neutron.py index cf11e3351..095245e91 100644 --- a/designate/network_api/neutron.py +++ b/designate/network_api/neutron.py @@ -31,6 +31,10 @@ 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 ' @@ -61,7 +65,8 @@ neutron_opts = [ 'neutron client requests.'), ] -cfg.CONF.register_opts(neutron_opts, group='network_api:neutron') +cfg.CONF.register_group(neutron_group) +cfg.CONF.register_opts(neutron_opts, group=neutron_group) def get_client(context, endpoint): diff --git a/designate/notification_handler/neutron.py b/designate/notification_handler/neutron.py index 5cacffcb3..47bc6058b 100644 --- a/designate/notification_handler/neutron.py +++ b/designate/notification_handler/neutron.py @@ -21,21 +21,27 @@ from designate.notification_handler import base LOG = logging.getLogger(__name__) -cfg.CONF.register_group(cfg.OptGroup( +# 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" -)) +) -cfg.CONF.register_opts([ - cfg.ListOpt('notification-topics', default=['notifications']), - cfg.StrOpt('control-exchange', default='neutron'), - cfg.StrOpt('zone-id'), - cfg.MultiStrOpt('formatv4'), +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'", - ), - cfg.MultiStrOpt('formatv6') -], group='handler:neutron_floatingip') + 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): diff --git a/designate/notification_handler/nova.py b/designate/notification_handler/nova.py index e3c676e27..a9e5eb5f9 100644 --- a/designate/notification_handler/nova.py +++ b/designate/notification_handler/nova.py @@ -21,21 +21,27 @@ from designate.notification_handler.base import BaseAddressHandler LOG = logging.getLogger(__name__) -cfg.CONF.register_group(cfg.OptGroup( +# 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" -)) +) -cfg.CONF.register_opts([ - cfg.ListOpt('notification-topics', default=['notifications']), - cfg.StrOpt('control-exchange', default='nova'), - cfg.StrOpt('zone-id'), - cfg.MultiStrOpt('formatv4'), +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'", - ), - cfg.MultiStrOpt('formatv6') -], group='handler:nova_fixed') + 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): diff --git a/designate/opts.py b/designate/opts.py new file mode 100644 index 000000000..4349b4b3b --- /dev/null +++ b/designate/opts.py @@ -0,0 +1,60 @@ +# 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 +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): create and genconfig for: +# Deleted domains purging; Delayed zones NOTIFY; Worker Periodic Recovery +# And 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 diff --git a/designate/pool_manager/__init__.py b/designate/pool_manager/__init__.py index d10d2907e..1a3182ec4 100644 --- a/designate/pool_manager/__init__.py +++ b/designate/pool_manager/__init__.py @@ -17,9 +17,9 @@ from oslo_config import cfg CONF = cfg.CONF -CONF.register_group(cfg.OptGroup( +pool_manager_group = cfg.OptGroup( name='service:pool_manager', title="Configuration for Pool Manager Service" -)) +) OPTS = [ cfg.IntOpt('workers', @@ -74,8 +74,6 @@ OPTS = [ help='RPC topic name for pool-manager') ] -CONF.register_opts(OPTS, group='service:pool_manager') - def register_dynamic_pool_options(): # Pool Options Registration Pass One @@ -128,3 +126,11 @@ 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 759b5c975..7918defad 100644 --- a/designate/pool_manager/cache/impl_memcache/__init__.py +++ b/designate/pool_manager/cache/impl_memcache/__init__.py @@ -29,10 +29,10 @@ from designate import objects from designate.common import memorycache from designate.pool_manager.cache import base as cache_base -cfg.CONF.register_group(cfg.OptGroup( +memcache_group = cfg.OptGroup( name='pool_manager_cache:memcache', title="Configuration for memcache Pool Manager Cache" -)) +) OPTS = [ @@ -41,8 +41,6 @@ OPTS = [ ] OPTS.extend(memorycache.memcache_opts) -cfg.CONF.register_opts(OPTS, - group='pool_manager_cache:memcache') DEFAULT_STATUS = 'NONE' @@ -127,3 +125,6 @@ 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 925f8dee7..56e4b90a1 100644 --- a/designate/pool_manager/cache/impl_sqlalchemy/__init__.py +++ b/designate/pool_manager/cache/impl_sqlalchemy/__init__.py @@ -26,13 +26,10 @@ from designate.pool_manager.cache.impl_sqlalchemy import tables LOG = logging.getLogger(__name__) -cfg.CONF.register_group(cfg.OptGroup( +sqlalchemy_group = cfg.OptGroup( name='pool_manager_cache:sqlalchemy', title="Configuration for SQLAlchemy Pool Manager Cache" -)) - -cfg.CONF.register_opts(options.database_opts, - group='pool_manager_cache:sqlalchemy') +) class SQLAlchemyPoolManagerCache(sqlalchemy_base.SQLAlchemy, @@ -76,3 +73,6 @@ 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 357df3833..885240ce7 100644 --- a/designate/producer/__init__.py +++ b/designate/producer/__init__.py @@ -17,9 +17,9 @@ from oslo_config import cfg CONF = cfg.CONF -CONF.register_group(cfg.OptGroup( +producer_group = cfg.OptGroup( name='service:producer', title="Configuration for Producer Service" -)) +) OPTS = [ cfg.IntOpt('workers', @@ -36,12 +36,10 @@ OPTS = [ deprecated_reason='Migrated to designate-worker'), ] -CONF.register_opts(OPTS, group='service:producer') - # TODO(timsim): Remove these when zone-manager is removed -CONF.register_group(cfg.OptGroup( +zone_manager_group = cfg.OptGroup( name='service:zone_manager', title="Configuration for Zone Manager Service" -)) +) ZONEMGROPTS = [ cfg.IntOpt('workers', @@ -66,4 +64,14 @@ ZONEMGROPTS = [ deprecated_reason='Migrated to designate-worker'), ] -CONF.register_opts(ZONEMGROPTS, group='service:zone_manager') + +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) + + +def list_opts(): + yield producer_group, OPTS + yield zone_manager_group, ZONEMGROPTS diff --git a/designate/quota/__init__.py b/designate/quota/__init__.py index f60596098..79d1e8b6c 100644 --- a/designate/quota/__init__.py +++ b/designate/quota/__init__.py @@ -21,7 +21,7 @@ from designate.quota import base LOG = logging.getLogger(__name__) -cfg.CONF.register_opts([ +quota_opts = [ cfg.StrOpt('quota-driver', default='storage', help='Quota driver to use'), cfg.IntOpt('quota-zones', default=10, @@ -34,7 +34,9 @@ cfg.CONF.register_opts([ 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(): diff --git a/designate/scheduler/__init__.py b/designate/scheduler/__init__.py index 9466d7f56..3169ac72b 100644 --- a/designate/scheduler/__init__.py +++ b/designate/scheduler/__init__.py @@ -16,17 +16,20 @@ 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__) -cfg.CONF.register_opts([ +scheduler_opts = [ cfg.ListOpt( 'scheduler_filters', default=['default_pool'], help='Enabled Pool Scheduling filters'), -], group='service:central') +] + +cfg.CONF.register_group(central.central_group) +cfg.CONF.register_opts(scheduler_opts, group=central.central_group) def get_scheduler(storage): - return base.Scheduler(storage=storage) diff --git a/designate/service_status.py b/designate/service_status.py index c3e4eadbd..2a922a18e 100644 --- a/designate/service_status.py +++ b/designate/service_status.py @@ -22,6 +22,11 @@ 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, @@ -31,7 +36,8 @@ heartbeat_opts = [ ] CONF = cfg.CONF -CONF.register_opts(heartbeat_opts, group="heartbeat_emitter") +CONF.register_group(heartbeat_group) +CONF.register_opts(heartbeat_opts, group=heartbeat_group) LOG = logging.getLogger(__name__) diff --git a/designate/sink/__init__.py b/designate/sink/__init__.py index 9c5c5801c..adf4c2c51 100644 --- a/designate/sink/__init__.py +++ b/designate/sink/__init__.py @@ -15,15 +15,23 @@ # under the License. from oslo_config import cfg -cfg.CONF.register_group(cfg.OptGroup( +sink_group = cfg.OptGroup( name='service:sink', title="Configuration for Sink Service" -)) +) -cfg.CONF.register_opts([ +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'), -], group='service:sink') +] + + +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 8490271b1..9f7d17454 100644 --- a/designate/storage/impl_sqlalchemy/__init__.py +++ b/designate/storage/impl_sqlalchemy/__init__.py @@ -34,11 +34,12 @@ LOG = logging.getLogger(__name__) MAXIMUM_SUBZONE_DEPTH = 128 -cfg.CONF.register_group(cfg.OptGroup( +storage_group = cfg.OptGroup( name='storage:sqlalchemy', title="Configuration for SQLAlchemy Storage" -)) +) -cfg.CONF.register_opts(options.database_opts, group='storage:sqlalchemy') +cfg.CONF.register_group(storage_group) +cfg.CONF.register_opts(options.database_opts, group=storage_group) class SQLAlchemyStorage(sqlalchemy_base.SQLAlchemy, storage_base.Storage): diff --git a/designate/utils.py b/designate/utils.py index 7c3d87869..a61f600a9 100644 --- a/designate/utils.py +++ b/designate/utils.py @@ -39,17 +39,18 @@ from designate.i18n import _LI LOG = logging.getLogger(__name__) -cfg.CONF.register_opts([ +helper_opts = [ cfg.StrOpt('root-helper', - default='sudo designate-rootwrap /etc/designate/rootwrap.conf') -]) + 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) -cfg.CONF.register_group(cfg.OptGroup( +proxy_group = cfg.OptGroup( name='proxy', title="Configuration for Client Proxy" -)) +) proxy_opts = [ cfg.StrOpt('http_proxy', @@ -60,7 +61,10 @@ proxy_opts = [ help='These addresses should not be proxied') ] -cfg.CONF.register_opts(proxy_opts, group='proxy') + +cfg.CONF.register_opts(helper_opts) +cfg.CONF.register_group(proxy_group) +cfg.CONF.register_opts(proxy_opts, proxy_group) # Default TCP/UDP ports diff --git a/designate/worker/__init__.py b/designate/worker/__init__.py index 27fcfa55f..a8aa83b44 100644 --- a/designate/worker/__init__.py +++ b/designate/worker/__init__.py @@ -17,9 +17,9 @@ from oslo_config import cfg CONF = cfg.CONF -CONF.register_group(cfg.OptGroup( +worker_group = cfg.OptGroup( name='service:worker', title="Configuration for the Worker Service" -)) +) OPTS = [ cfg.BoolOpt('enabled', default=False, @@ -59,4 +59,10 @@ OPTS = [ help='RPC topic for worker component') ] -CONF.register_opts(OPTS, group='service:worker') + +cfg.CONF.register_group(worker_group) +cfg.CONF.register_opts(OPTS, group=worker_group) + + +def list_opts(): + yield worker_group, OPTS diff --git a/etc/designate/README-designate.conf.txt b/etc/designate/README-designate.conf.txt new file mode 100644 index 000000000..5ce3ae5ab --- /dev/null +++ b/etc/designate/README-designate.conf.txt @@ -0,0 +1,4 @@ +To generate the sample designate.conf file, run the following command from the top +level of the designate directory: + + tox -e genconfig \ No newline at end of file diff --git a/etc/designate/designate-config-generator.conf b/etc/designate/designate-config-generator.conf new file mode 100644 index 000000000..bce0e17a4 --- /dev/null +++ b/etc/designate/designate-config-generator.conf @@ -0,0 +1,26 @@ +[DEFAULT] +output_file = etc/designate/designate_full.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 = oslo.log +namespace = oslo.messaging +namespace = oslo.policy +namespace = oslo.service.periodic_task +namespace = oslo.service.service +namespace = oslo.service.sslutils +namespace = oslo.db +namespace = oslo.middleware +namespace = oslo.concurrency +namespace = keystonemiddleware.auth_token \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 058906f2b..1e59673b9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,6 +37,20 @@ data_files = etc/designate/rootwrap.d/bind9.filters [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 + +oslo.config.opts.defaults = + designate.api = designate.common.config:set_defaults + console_scripts = designate-rootwrap = oslo_rootwrap.cmd:main designate-api = designate.cmd.api:main diff --git a/tox.ini b/tox.ini index 3683d448d..deb3b86f7 100644 --- a/tox.ini +++ b/tox.ini @@ -68,6 +68,9 @@ basepython = python2.7 commands = sh tools/pretty_flake8.sh {[testenv:bandit]commands} +[testenv:genconfig] +commands = oslo-config-generator --config-file=etc/designate/designate-config-generator.conf + [testenv:bashate] deps = bashate whitelist_externals = bash