Move all conf option to centralize conf directory

Currently, all config options of Zun were found in
separate package/module. This is somehow hard for new
developer joining Zun team to use/add new config options.
This patch moves all config option to central place.

Change-Id: I2940d295b413b9c802f09be8d418c3721e2f423c
This commit is contained in:
Pradeep Kumar Singh 2016-10-27 14:19:43 +00:00
parent 648aa26d55
commit d06613e3e9
49 changed files with 553 additions and 333 deletions

View File

@ -2,4 +2,13 @@
output_file = etc/zun/zun.conf.sample output_file = etc/zun/zun.conf.sample
wrap_width = 79 wrap_width = 79
namespace=zun.conf namespace = zun.conf
namespace = keystonemiddleware.auth_token
namespace = oslo.concurrency
namespace = oslo.db
namespace = oslo.log
namespace = oslo.messaging
namespace = oslo.middleware.cors
namespace = oslo.policy
namespace = oslo.service.periodic_task
namespace = oslo.service.service

View File

@ -52,7 +52,7 @@ console_scripts =
oslo.config.opts = oslo.config.opts =
zun = zun.opts:list_opts zun = zun.opts:list_opts
zun.conf = zun.opts:list_opts zun.conf = zun.conf.opts:list_opts
oslo.config.opts.defaults = oslo.config.opts.defaults =
zun = zun.common.config:set_cors_middleware_defaults zun = zun.common.config:set_cors_middleware_defaults

View File

@ -2,7 +2,7 @@
output_file = etc/zun/zun.conf.sample output_file = etc/zun/zun.conf.sample
wrap_width = 79 wrap_width = 79
namespace = zun namespace = zun.conf
namespace = keystonemiddleware.auth_token namespace = keystonemiddleware.auth_token
namespace = oslo.concurrency namespace = oslo.concurrency
namespace = oslo.db namespace = oslo.db

View File

@ -64,4 +64,4 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen
[testenv:genconfig] [testenv:genconfig]
envdir = {toxworkdir}/venv envdir = {toxworkdir}/venv
commands = commands =
{toxinidir}/tools/gen-config oslo-config-generator --config-file etc/zun/zun-config-generator.conf

View File

@ -20,44 +20,10 @@ import pecan
from zun.api import config as api_config from zun.api import config as api_config
from zun.api import middleware from zun.api import middleware
from zun.common import config as common_config from zun.common import config as common_config
from zun.common.i18n import _
from zun.common.i18n import _LI from zun.common.i18n import _LI
import zun.conf
CONF = zun.conf.CONF
# Register options for the service
API_SERVICE_OPTS = [
cfg.PortOpt('port',
default=9512,
help='The port for the zun API server.'),
cfg.IPOpt('host',
default='127.0.0.1',
help='The listen IP for the zun API server.'),
cfg.BoolOpt('enable_ssl_api',
default=False,
help=_("Enable the integrated stand-alone API to service "
"requests via HTTPS instead of HTTP. If there is a "
"front-end service performing HTTPS offloading from "
"the service, this option should be False; note, you "
"will want to change public API endpoint to represent "
"SSL termination URL with 'public_endpoint' option.")),
cfg.IntOpt('workers',
help=_("Number of workers for zun-api service. "
"The default will be the number of CPUs available.")),
cfg.IntOpt('max_limit',
default=1000,
help='The maximum number of items returned in a single '
'response from a collection resource.'),
cfg.StrOpt('api_paste_config',
default="api-paste.ini",
help="Configuration file for WSGI definition of API.")
]
CONF = cfg.CONF
opt_group = cfg.OptGroup(name='api',
title='Options for the zun-api service')
CONF.register_group(opt_group)
CONF.register_opts(API_SERVICE_OPTS, opt_group)
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -86,14 +52,14 @@ def setup_app(config=None):
def load_app(): def load_app():
cfg_file = None cfg_file = None
cfg_path = cfg.CONF.api.api_paste_config cfg_path = CONF.api.api_paste_config
if not os.path.isabs(cfg_path): if not os.path.isabs(cfg_path):
cfg_file = CONF.find_file(cfg_path) cfg_file = CONF.find_file(cfg_path)
elif os.path.exists(cfg_path): elif os.path.exists(cfg_path):
cfg_file = cfg_path cfg_file = cfg_path
if not cfg_file: if not cfg_file:
raise cfg.ConfigFilesNotFoundError([cfg.CONF.api.api_paste_config]) raise cfg.ConfigFilesNotFoundError([CONF.api.api_paste_config])
LOG.info(_LI("Full WSGI config used: %s"), cfg_file) LOG.info(_LI("Full WSGI config used: %s"), cfg_file)
return deploy.loadapp("config:" + cfg_file) return deploy.loadapp("config:" + cfg_file)

View File

@ -18,8 +18,9 @@ from pecan import hooks
from zun.common import context from zun.common import context
from zun.compute import api as compute_api from zun.compute import api as compute_api
import zun.conf
CONF = cfg.CONF CONF = zun.conf.CONF
CONF.import_opt('auth_uri', 'keystonemiddleware.auth_token', CONF.import_opt('auth_uri', 'keystonemiddleware.auth_token',
group='keystone_authtoken') group='keystone_authtoken')

View File

@ -11,20 +11,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from oslo_config import cfg
from oslo_utils import timeutils from oslo_utils import timeutils
import zun.conf
from zun import objects from zun import objects
periodic_opts = [ CONF = zun.conf.CONF
cfg.IntOpt('service_down_time',
default=180,
help='Max interval size between periodic tasks execution in '
'seconds.'),
]
CONF = cfg.CONF
CONF.register_opts(periodic_opts)
class ServiceGroup(object): class ServiceGroup(object):

View File

@ -14,16 +14,16 @@
# under the License. # under the License.
import jsonpatch import jsonpatch
from oslo_config import cfg
from oslo_utils import uuidutils from oslo_utils import uuidutils
import pecan import pecan
import wsme import wsme
from zun.common import exception from zun.common import exception
from zun.common.i18n import _ from zun.common.i18n import _
import zun.conf
from zun import objects from zun import objects
CONF = cfg.CONF CONF = zun.conf.CONF
JSONPATCH_EXCEPTIONS = (jsonpatch.JsonPatchException, JSONPATCH_EXCEPTIONS = (jsonpatch.JsonPatchException,

View File

@ -19,11 +19,10 @@
import sys import sys
from oslo_config import cfg
from zun.common import service as zun_service from zun.common import service as zun_service
import zun.conf
CONF = cfg.CONF CONF = zun.conf.CONF
def main(): def main():

View File

@ -15,7 +15,6 @@
import os import os
import sys import sys
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_service import service from oslo_service import service
@ -24,7 +23,9 @@ from zun.common import rpc_service
from zun.common import service as zun_service from zun.common import service as zun_service
from zun.common import short_id from zun.common import short_id
from zun.compute import manager as compute_manager from zun.compute import manager as compute_manager
import zun.conf
CONF = zun.conf.CONF
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -32,16 +33,16 @@ def main():
zun_service.prepare_service(sys.argv) zun_service.prepare_service(sys.argv)
LOG.info(_LI('Starting server in PID %s'), os.getpid()) LOG.info(_LI('Starting server in PID %s'), os.getpid())
cfg.CONF.log_opt_values(LOG, logging.DEBUG) CONF.log_opt_values(LOG, logging.DEBUG)
cfg.CONF.import_opt('topic', 'zun.compute.config', group='compute') CONF.import_opt('topic', 'zun.conf.compute', group='compute')
compute_id = short_id.generate_id() compute_id = short_id.generate_id()
endpoints = [ endpoints = [
compute_manager.Manager(), compute_manager.Manager(),
] ]
server = rpc_service.Service.create(cfg.CONF.compute.topic, compute_id, server = rpc_service.Service.create(CONF.compute.topic, compute_id,
endpoints, binary='zun-compute') endpoints, binary='zun-compute')
launcher = service.launch(cfg.CONF, server) launcher = service.launch(CONF, server)
launcher.wait() launcher.wait()

View File

@ -13,54 +13,11 @@
# under the License. # under the License.
from glanceclient import client as glanceclient from glanceclient import client as glanceclient
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from zun.common import exception from zun.common import exception
from zun.common.i18n import _
from zun.common import keystone from zun.common import keystone
import zun.conf
common_security_opts = [
cfg.StrOpt('ca_file',
help=_('Optional CA cert file to use in SSL connections.')),
cfg.StrOpt('cert_file',
help=_('Optional PEM-formatted certificate chain file.')),
cfg.StrOpt('key_file',
help=_('Optional PEM-formatted file that contains the '
'private key.')),
cfg.BoolOpt('insecure',
default=False,
help=_("If set, then the server's certificate will not "
"be verified."))]
zun_client_opts = [
cfg.StrOpt('region_name',
help=_('Region in Identity service catalog to use for '
'communication with the OpenStack service.')),
cfg.StrOpt('endpoint_type',
default='publicURL',
help=_(
'Type of endpoint in Identity service catalog to use '
'for communication with the OpenStack service.'))]
glance_client_opts = [
cfg.StrOpt('region_name',
help=_('Region in Identity service catalog to use for '
'communication with the OpenStack service.')),
cfg.StrOpt('endpoint_type',
default='publicURL',
help=_(
'Type of endpoint in Identity service catalog to use '
'for communication with the OpenStack service.')),
cfg.StrOpt('api_version',
default='2',
help=_('Version of Glance API to use in glanceclient.'))]
cfg.CONF.register_opts(zun_client_opts, group='zun_client')
cfg.CONF.register_opts(glance_client_opts, group='glance_client')
cfg.CONF.register_opts(common_security_opts, group='glance_client')
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -99,7 +56,7 @@ class OpenStackClients(object):
return self._keystone return self._keystone
def _get_client_option(self, client, option): def _get_client_option(self, client, option):
return getattr(getattr(cfg.CONF, '%s_client' % client), option) return getattr(getattr(zun.conf.CONF, '%s_client' % client), option)
@exception.wrap_keystone_exception @exception.wrap_keystone_exception
def glance(self): def glance(self):

View File

@ -19,16 +19,17 @@ from oslo_config import cfg
from oslo_middleware import cors from oslo_middleware import cors
from zun.common import rpc from zun.common import rpc
import zun.conf
from zun import version from zun import version
def parse_args(argv, default_config_files=None): def parse_args(argv, default_config_files=None):
rpc.set_defaults(control_exchange='zun') rpc.set_defaults(control_exchange='zun')
cfg.CONF(argv[1:], zun.conf.CONF(argv[1:],
project='zun', project='zun',
version=version.version_info.release_string(), version=version.version_info.release_string(),
default_config_files=default_config_files) default_config_files=default_config_files)
rpc.init(cfg.CONF) rpc.init(zun.conf.CONF)
def set_config_defaults(): def set_config_defaults():

View File

@ -11,11 +11,8 @@
# under the License. # under the License.
from eventlet.green import threading from eventlet.green import threading
from oslo_config import cfg
from oslo_context import context from oslo_context import context
CONF = cfg.CONF
class RequestContext(context.RequestContext): class RequestContext(context.RequestContext):
"""Extends security contexts from the OpenStack common library.""" """Extends security contexts from the OpenStack common library."""

View File

@ -33,11 +33,11 @@ import six
from zun.common.i18n import _ from zun.common.i18n import _
from zun.common.i18n import _LE from zun.common.i18n import _LE
import zun.conf
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CONF = cfg.CONF CONF = zun.conf.CONF
try: try:
CONF.import_opt('fatal_exception_format_errors', CONF.import_opt('fatal_exception_format_errors',

View File

@ -15,13 +15,13 @@ from keystoneauth1.identity import access as ka_access_plugin
from keystoneauth1.identity import v3 as ka_v3 from keystoneauth1.identity import v3 as ka_v3
from keystoneauth1 import loading as ka_loading from keystoneauth1 import loading as ka_loading
from keystoneclient.v3 import client as kc_v3 from keystoneclient.v3 import client as kc_v3
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from zun.common import exception from zun.common import exception
from zun.common.i18n import _LE from zun.common.i18n import _LE
import zun.conf
CONF = cfg.CONF CONF = zun.conf.CONF
CFG_GROUP = 'keystone_auth' CFG_GROUP = 'keystone_auth'
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,23 +12,9 @@
import os import os
from oslo_config import cfg import zun.conf
PATH_OPTS = [ CONF = zun.conf.CONF
cfg.StrOpt('pybasedir',
default=os.path.abspath(os.path.join(os.path.dirname(__file__),
'../')),
help='Directory where the zun python module is installed.'),
cfg.StrOpt('bindir',
default='$pybasedir/bin',
help='Directory where zun binaries are installed.'),
cfg.StrOpt('state_path',
default='$pybasedir',
help="Top-level directory for maintaining zun's state."),
]
CONF = cfg.CONF
CONF.register_opts(PATH_OPTS)
def basedir_def(*args): def basedir_def(*args):
@ -48,14 +34,14 @@ def state_path_def(*args):
def basedir_rel(*args): def basedir_rel(*args):
"""Return a path relative to $pybasedir.""" """Return a path relative to $pybasedir."""
return os.path.join(CONF.pybasedir, *args) return os.path.join(CONF.common.pybasedir, *args)
def bindir_rel(*args): def bindir_rel(*args):
"""Return a path relative to $bindir.""" """Return a path relative to $bindir."""
return os.path.join(CONF.bindir, *args) return os.path.join(CONF.common.bindir, *args)
def state_path_rel(*args): def state_path_rel(*args):
"""Return a path relative to $state_path.""" """Return a path relative to $state_path."""
return os.path.join(CONF.state_path, *args) return os.path.join(CONF.common.state_path, *args)

View File

@ -16,16 +16,15 @@
"""Policy Engine For zun.""" """Policy Engine For zun."""
import decorator import decorator
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_policy import policy from oslo_policy import policy
import pecan import pecan
from zun.common import exception from zun.common import exception
import zun.conf
_ENFORCER = None _ENFORCER = None
CONF = cfg.CONF CONF = zun.conf.CONF
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -26,15 +26,14 @@ __all__ = [
'get_notifier', 'get_notifier',
] ]
from oslo_config import cfg
import oslo_messaging as messaging import oslo_messaging as messaging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from zun.common import context as zun_context from zun.common import context as zun_context
from zun.common import exception from zun.common import exception
import zun.conf
CONF = zun.conf.CONF
CONF = cfg.CONF
TRANSPORT = None TRANSPORT = None
NOTIFIER = None NOTIFIER = None
@ -131,5 +130,5 @@ def get_server(target, endpoints, serializer=None):
def get_notifier(service='container', host=None, publisher_id=None): def get_notifier(service='container', host=None, publisher_id=None):
assert NOTIFIER is not None assert NOTIFIER is not None
if not publisher_id: if not publisher_id:
publisher_id = "%s.%s" % (service, host or CONF.host) publisher_id = "%s.%s" % (service, host or CONF.common.host)
return NOTIFIER.prepare(publisher_id=publisher_id) return NOTIFIER.prepare(publisher_id=publisher_id)

View File

@ -15,11 +15,11 @@
"""Common RPC service and API tools for Zun.""" """Common RPC service and API tools for Zun."""
import eventlet import eventlet
from oslo_config import cfg
import oslo_messaging as messaging import oslo_messaging as messaging
from oslo_service import service from oslo_service import service
from zun.common import rpc from zun.common import rpc
import zun.conf
from zun.objects import base as objects_base from zun.objects import base as objects_base
from zun.servicegroup import zun_service_periodic as servicegroup from zun.servicegroup import zun_service_periodic as servicegroup
@ -30,15 +30,7 @@ from zun.servicegroup import zun_service_periodic as servicegroup
# to use libamqp instead. # to use libamqp instead.
eventlet.monkey_patch() eventlet.monkey_patch()
periodic_opts = [ CONF = zun.conf.CONF
cfg.IntOpt('periodic_interval_max',
default=60,
help='Max interval size between periodic tasks execution in '
'seconds.'),
]
CONF = cfg.CONF
CONF.register_opts(periodic_opts)
class Service(service.Service): class Service(service.Service):
@ -47,7 +39,7 @@ class Service(service.Service):
super(Service, self).__init__() super(Service, self).__init__()
serializer = rpc.RequestContextSerializer( serializer = rpc.RequestContextSerializer(
objects_base.ZunObjectSerializer()) objects_base.ZunObjectSerializer())
transport = messaging.get_transport(cfg.CONF) transport = messaging.get_transport(CONF)
# TODO(asalkeld) add support for version='x.y' # TODO(asalkeld) add support for version='x.y'
target = messaging.Target(topic=topic, server=server) target = messaging.Target(topic=topic, server=server)
self._server = messaging.get_rpc_server(transport, target, handlers, self._server = messaging.get_rpc_server(transport, target, handlers,
@ -77,7 +69,7 @@ class API(object):
objects_base.ZunObjectSerializer()) objects_base.ZunObjectSerializer())
if transport is None: if transport is None:
exmods = rpc.get_allowed_exmods() exmods = rpc.get_allowed_exmods()
transport = messaging.get_transport(cfg.CONF, transport = messaging.get_transport(CONF,
allowed_remote_exmods=exmods) allowed_remote_exmods=exmods)
self._context = context self._context = context
if topic is None: if topic is None:

View File

@ -14,10 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import socket
from oslo_concurrency import processutils from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import log from oslo_log import log
from oslo_service import service from oslo_service import service
from oslo_service import wsgi from oslo_service import wsgi
@ -26,23 +24,11 @@ from zun.api import app
from zun.common import config from zun.common import config
from zun.common import exception from zun.common import exception
from zun.common.i18n import _ from zun.common.i18n import _
import zun.conf
CONF = zun.conf.CONF
service_opts = [
cfg.StrOpt('host',
default=socket.getfqdn(),
help=_('Name of this node. This can be an opaque identifier. '
'It is not necessarily a hostname, FQDN, or IP address. '
'However, the node name must be valid within '
'an AMQP key, and if using ZeroMQ, a valid '
'hostname, FQDN, or IP address.')),
]
CONF = cfg.CONF
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
CONF.register_opts(service_opts)
def prepare_service(argv=None): def prepare_service(argv=None):
if argv is None: if argv is None:

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg
from zun.common import rpc_service from zun.common import rpc_service
import zun.conf
class API(rpc_service.API): class API(rpc_service.API):
@ -28,11 +28,11 @@ class API(rpc_service.API):
def __init__(self, transport=None, context=None, topic=None): def __init__(self, transport=None, context=None, topic=None):
if topic is None: if topic is None:
cfg.CONF.import_opt( zun.conf.CONF.import_opt(
'topic', 'zun.compute.config', group='compute') 'topic', 'zun.conf.compute', group='compute')
super(API, self).__init__( super(API, self).__init__(
transport, context, topic=cfg.CONF.compute.topic) transport, context, topic=zun.conf.CONF.compute.topic)
def container_create(self, context, container): def container_create(self, context, container):
return self._cast('container_create', container=container) return self._cast('container_create', container=container)

View File

@ -14,18 +14,24 @@
from oslo_config import cfg from oslo_config import cfg
# from zun.conf import api from zun.conf import api
# from zun.conf import compute from zun.conf import compute
# from zun.conf import database from zun.conf import container_driver
# from zun.conf import glance_client from zun.conf import database
# from zun.conf import keystone from zun.conf import docker
# from zun.conf import zun_client from zun.conf import glance_client
from zun.conf import path
from zun.conf import services
from zun.conf import zun_client
CONF = cfg.CONF CONF = cfg.CONF
# api.register_opts(CONF) api.register_opts(CONF)
# compute.register_opts(CONF) compute.register_opts(CONF)
# database.register_opts(CONF) container_driver.register_opts(CONF)
# glance_client.register_opts(CONF) database.register_opts(CONF)
# keystone.register_opts(CONF) docker.register_opts(CONF)
# zun_client.register_opts(CONF) glance_client.register_opts(CONF)
path.register_opts(CONF)
services.register_opts(CONF)
zun_client.register_opts(CONF)

60
zun/conf/api.py Normal file
View File

@ -0,0 +1,60 @@
# 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 zun.common.i18n import _
api_service_opts = [
cfg.PortOpt('port',
default=9512,
help='The port for the zun API server.'),
cfg.IPOpt('host',
default='127.0.0.1',
help='The listen IP for the zun API server.'),
cfg.BoolOpt('enable_ssl_api',
default=False,
help=_("Enable the integrated stand-alone API to service "
"requests via HTTPS instead of HTTP. If there is a "
"front-end service performing HTTPS offloading from "
"the service, this option should be False; note, you "
"will want to change public API endpoint to represent "
"SSL termination URL with 'public_endpoint' option.")),
cfg.IntOpt('workers',
help=_("Number of workers for zun-api service. "
"The default will be the number of CPUs available.")),
cfg.IntOpt('max_limit',
default=1000,
help='The maximum number of items returned in a single '
'response from a collection resource.'),
cfg.StrOpt('api_paste_config',
default="api-paste.ini",
help="Configuration file for WSGI definition of API.")
]
api_group = cfg.OptGroup(name='api',
title='Options for the zun-api service')
ALL_OPTS = (api_service_opts)
def register_opts(conf):
conf.register_group(api_group)
conf.register_opts(ALL_OPTS, api_group)
def list_opts():
return {
api_group: ALL_OPTS
}

View File

@ -14,7 +14,8 @@
from oslo_config import cfg from oslo_config import cfg
SERVICE_OPTS = [
service_opts = [
cfg.StrOpt( cfg.StrOpt(
'topic', 'topic',
default='zun-compute', default='zun-compute',
@ -23,5 +24,14 @@ SERVICE_OPTS = [
opt_group = cfg.OptGroup( opt_group = cfg.OptGroup(
name='compute', title='Options for the zun-compute service') name='compute', title='Options for the zun-compute service')
cfg.CONF.register_group(opt_group)
cfg.CONF.register_opts(SERVICE_OPTS, opt_group) ALL_OPTS = (service_opts)
def register_opts(conf):
conf.register_group(opt_group)
conf.register_opts(ALL_OPTS, opt_group)
def list_opts():
return {opt_group: ALL_OPTS}

View File

@ -0,0 +1,43 @@
# 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
driver_opts = [
cfg.StrOpt('container_driver',
default='docker.driver.DockerDriver',
help="""Defines which driver to use for controlling container.
Possible values:
* ``docker.driver.DockerDriver``
Services which consume this:
* ``zun-compute``
Interdependencies to other options:
* None
""")
]
ALL_OPTS = (driver_opts)
def register_opts(conf):
conf.register_opts(ALL_OPTS)
def list_opts():
return {"DEFAULT": ALL_OPTS}

29
zun/conf/database.py Normal file
View File

@ -0,0 +1,29 @@
# Copyright 2015 NEC Corporation. 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
sql_opts = [
cfg.StrOpt('mysql_engine',
default='InnoDB',
help='MySQL engine to use.')
]
def register_opts(conf):
conf.register_opts(sql_opts, 'database')
def list_opts():
return {"DEFAULT": sql_opts}

54
zun/conf/docker.py Normal file
View File

@ -0,0 +1,54 @@
# 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
docker_group = cfg.OptGroup(name='docker',
title='Options for docker')
docker_opts = [
cfg.StrOpt('docker_remote_api_version',
default='1.20',
help='Docker remote api version. Override it according to '
'specific docker api version in your environment.'),
cfg.IntOpt('default_timeout',
default=60,
help='Default timeout in seconds for docker client '
'operations.'),
cfg.StrOpt('api_url',
default='unix:///var/run/docker.sock',
help='API endpoint of docker daemon'),
cfg.BoolOpt('api_insecure',
default=False,
help='If set, ignore any SSL validation issues'),
cfg.StrOpt('ca_file',
help='Location of CA certificates file for '
'securing docker api requests (tlscacert).'),
cfg.StrOpt('cert_file',
help='Location of TLS certificate file for '
'securing docker api requests (tlscert).'),
cfg.StrOpt('key_file',
help='Location of TLS private key file for '
'securing docker api requests (tlskey).'),
]
ALL_OPTS = (docker_opts)
def register_opts(conf):
conf.register_group(docker_group)
conf.register_opts(ALL_OPTS, docker_group)
def list_opts():
return {docker_group: ALL_OPTS}

61
zun/conf/glance_client.py Normal file
View File

@ -0,0 +1,61 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 eNovance <licensing@enovance.com>
#
# 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 zun.common.i18n import _
glance_group = cfg.OptGroup(name='glance_client',
title='Options for the Glance client')
common_security_opts = [
cfg.StrOpt('ca_file',
help=_('Optional CA cert file to use in SSL connections.')),
cfg.StrOpt('cert_file',
help=_('Optional PEM-formatted certificate chain file.')),
cfg.StrOpt('key_file',
help=_('Optional PEM-formatted file that contains the '
'private key.')),
cfg.BoolOpt('insecure',
default=False,
help=_("If set, then the server's certificate will not "
"be verified."))]
glance_client_opts = [
cfg.StrOpt('region_name',
help=_('Region in Identity service catalog to use for '
'communication with the OpenStack service.')),
cfg.StrOpt('endpoint_type',
default='publicURL',
help=_(
'Type of endpoint in Identity service catalog to use '
'for communication with the OpenStack service.')),
cfg.StrOpt('api_version',
default='2',
help=_('Version of Glance API to use in glanceclient.'))]
ALL_OPTS = (glance_client_opts + common_security_opts)
def register_opts(conf):
conf.register_group(glance_group)
conf.register_opts(ALL_OPTS, group=glance_group)
def list_opts():
return {glance_group: ALL_OPTS}

41
zun/conf/path.py Normal file
View File

@ -0,0 +1,41 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 eNovance <licensing@enovance.com>
#
# 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
path_opts = [
cfg.StrOpt('pybasedir',
default=os.path.abspath(os.path.join(os.path.dirname(__file__),
'../')),
help='Directory where the zun python module is installed.'),
cfg.StrOpt('bindir',
default='$pybasedir/bin',
help='Directory where zun binaries are installed.'),
cfg.StrOpt('state_path',
default='$pybasedir',
help="Top-level directory for maintaining zun's state."),
]
def register_opts(conf):
conf.register_opts(path_opts)
def list_opts():
return {"DEFAULT": path_opts}

52
zun/conf/services.py Normal file
View File

@ -0,0 +1,52 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 eNovance <licensing@enovance.com>
#
# 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
from zun.common.i18n import _
service_opts = [
cfg.StrOpt('host',
default=socket.getfqdn(),
help=_('Name of this node. This can be an opaque identifier. '
'It is not necessarily a hostname, FQDN, or IP address. '
'However, the node name must be valid within '
'an AMQP key, and if using ZeroMQ, a valid '
'hostname, FQDN, or IP address.')),
]
periodic_opts = [
cfg.IntOpt('periodic_interval_max',
default=60,
help='Max interval size between periodic tasks execution in '
'seconds.'),
cfg.IntOpt('service_down_time',
default=180,
help='Max interval size between periodic tasks execution in '
'seconds.'),
]
ALL_OPTS = (service_opts + periodic_opts)
def register_opts(conf):
conf.register_opts(ALL_OPTS)
def list_opts():
return {"DEFAULT": ALL_OPTS}

57
zun/conf/zun_client.py Normal file
View File

@ -0,0 +1,57 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 eNovance <licensing@enovance.com>
#
# 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 zun.common.i18n import _
zun_group = cfg.OptGroup(name='zun_client',
title='Options for the Zun client')
zun_client_opts = [
cfg.StrOpt('region_name',
help=_('Region in Identity service catalog to use for '
'communication with the OpenStack service.')),
cfg.StrOpt('endpoint_type',
default='publicURL',
help=_(
'Type of endpoint in Identity service catalog to use '
'for communication with the OpenStack service.'))]
common_security_opts = [
cfg.StrOpt('ca_file',
help=_('Optional CA cert file to use in SSL connections.')),
cfg.StrOpt('cert_file',
help=_('Optional PEM-formatted certificate chain file.')),
cfg.StrOpt('key_file',
help=_('Optional PEM-formatted file that contains the '
'private key.')),
cfg.BoolOpt('insecure',
default=False,
help=_("If set, then the server's certificate will not "
"be verified."))]
ALL_OPTS = (zun_client_opts + common_security_opts)
def register_opts(conf):
conf.register_group(zun_group)
conf.register_opts(zun_client_opts, group=zun_group)
def list_opts():
return {zun_group: ALL_OPTS}

View File

@ -14,7 +14,6 @@
from docker import errors from docker import errors
import six import six
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from zun.common.utils import check_container_id from zun.common.utils import check_container_id
@ -24,7 +23,6 @@ from zun.objects import fields
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CONF = cfg.CONF
class DockerDriver(driver.ContainerDriver): class DockerDriver(driver.ContainerDriver):

View File

@ -17,40 +17,12 @@ from docker import client
from docker import errors from docker import errors
from docker import tls from docker import tls
from docker.utils import utils from docker.utils import utils
from oslo_config import cfg
from zun.common import exception from zun.common import exception
import zun.conf
from zun import objects from zun import objects
CONF = zun.conf.CONF
docker_opts = [
cfg.StrOpt('docker_remote_api_version',
default='1.20',
help='Docker remote api version. Override it according to '
'specific docker api version in your environment.'),
cfg.IntOpt('default_timeout',
default=60,
help='Default timeout in seconds for docker client '
'operations.'),
cfg.StrOpt('api_url',
default='unix:///var/run/docker.sock',
help='API endpoint of docker daemon'),
cfg.BoolOpt('api_insecure',
default=False,
help='If set, ignore any SSL validation issues'),
cfg.StrOpt('ca_file',
help='Location of CA certificates file for '
'securing docker api requests (tlscacert).'),
cfg.StrOpt('cert_file',
help='Location of TLS certificate file for '
'securing docker api requests (tlscert).'),
cfg.StrOpt('key_file',
help='Location of TLS private key file for '
'securing docker api requests (tlskey).'),
]
CONF = cfg.CONF
CONF.register_opts(docker_opts, 'docker')
def parse_docker_image(image): def parse_docker_image(image):

View File

@ -13,36 +13,15 @@
import sys import sys
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
from zun.common.i18n import _LE from zun.common.i18n import _LE
from zun.common.i18n import _LI from zun.common.i18n import _LI
import zun.conf
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CONF = zun.conf.CONF
driver_opts = [
cfg.StrOpt('container_driver',
default='docker.driver.DockerDriver',
help="""Defines which driver to use for controlling container.
Possible values:
* ``docker.driver.DockerDriver``
Services which consume this:
* ``zun-compute``
Interdependencies to other options:
* None
""")
]
CONF = cfg.CONF
CONF.register_opts(driver_opts)
def load_container_driver(container_driver=None): def load_container_driver(container_driver=None):

View File

@ -12,20 +12,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg
from oslo_db import options from oslo_db import options
from zun.common import paths from zun.common import paths
import zun.conf
sql_opts = [
cfg.StrOpt('mysql_engine',
default='InnoDB',
help='MySQL engine to use.')
]
_DEFAULT_SQL_CONNECTION = 'sqlite:///' + paths.state_path_def('zun.sqlite') _DEFAULT_SQL_CONNECTION = 'sqlite:///' + paths.state_path_def('zun.sqlite')
cfg.CONF.register_opts(sql_opts, 'database') options.set_defaults(zun.conf.CONF)
options.set_defaults(cfg.CONF) options.set_defaults(zun.conf.CONF, _DEFAULT_SQL_CONNECTION, 'zun.sqlite')
options.set_defaults(cfg.CONF, _DEFAULT_SQL_CONNECTION, 'zun.sqlite')

View File

@ -17,14 +17,16 @@ Base API for Database
import abc import abc
from oslo_config import cfg
from oslo_db import api as db_api from oslo_db import api as db_api
import six import six
import zun.conf
"""Add the database backend mapping here""" """Add the database backend mapping here"""
_BACKEND_MAPPING = {'sqlalchemy': 'zun.db.sqlalchemy.api'} _BACKEND_MAPPING = {'sqlalchemy': 'zun.db.sqlalchemy.api'}
IMPL = db_api.DBAPI.from_config(cfg.CONF, backend_mapping=_BACKEND_MAPPING, IMPL = db_api.DBAPI.from_config(zun.conf.CONF,
backend_mapping=_BACKEND_MAPPING,
lazy=True) lazy=True)

View File

@ -13,18 +13,20 @@
"""Database setup and migration commands.""" """Database setup and migration commands."""
from oslo_config import cfg
from stevedore import driver from stevedore import driver
import zun.conf
_IMPL = None _IMPL = None
def get_backend(): def get_backend():
global _IMPL global _IMPL
if not _IMPL: if not _IMPL:
cfg.CONF.import_opt('backend', 'oslo_db.options', group='database') zun.conf.CONF.import_opt('backend',
'oslo_db.options', group='database')
_IMPL = driver.DriverManager("zun.database.migration_backend", _IMPL = driver.DriverManager("zun.database.migration_backend",
cfg.CONF.database.backend).driver zun.conf.CONF.database.backend).driver
return _IMPL return _IMPL

View File

@ -14,7 +14,6 @@
"""SQLAlchemy storage backend.""" """SQLAlchemy storage backend."""
from oslo_config import cfg
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_db.sqlalchemy import session as db_session from oslo_db.sqlalchemy import session as db_session
from oslo_db.sqlalchemy import utils as db_utils from oslo_db.sqlalchemy import utils as db_utils
@ -26,10 +25,11 @@ from sqlalchemy.orm.exc import NoResultFound
from zun.common import exception from zun.common import exception
from zun.common.i18n import _ from zun.common.i18n import _
import zun.conf
from zun.db import api from zun.db import api
from zun.db.sqlalchemy import models from zun.db.sqlalchemy import models
CONF = cfg.CONF CONF = zun.conf.CONF
_FACADE = None _FACADE = None

View File

@ -16,9 +16,10 @@
import os import os
from oslo_config import cfg
from oslo_db.sqlalchemy.migration_cli import manager from oslo_db.sqlalchemy.migration_cli import manager
import zun.conf
_MANAGER = None _MANAGER = None
@ -31,7 +32,7 @@ def get_manager():
os.path.join(os.path.dirname(__file__), 'alembic')) os.path.join(os.path.dirname(__file__), 'alembic'))
migration_config = {'alembic_ini_path': alembic_path, migration_config = {'alembic_ini_path': alembic_path,
'alembic_repo_path': migrate_path, 'alembic_repo_path': migrate_path,
'db_url': cfg.CONF.database.connection} 'db_url': zun.conf.CONF.database.connection}
_MANAGER = manager.MigrationManager(migration_config) _MANAGER = manager.MigrationManager(migration_config)
return _MANAGER return _MANAGER

View File

@ -16,7 +16,6 @@ SQLAlchemy models for container service
import json import json
from oslo_config import cfg
from oslo_db.sqlalchemy import models from oslo_db.sqlalchemy import models
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
from sqlalchemy import Boolean from sqlalchemy import Boolean
@ -29,11 +28,13 @@ from sqlalchemy import schema
from sqlalchemy import String from sqlalchemy import String
from sqlalchemy.types import TypeDecorator, TEXT from sqlalchemy.types import TypeDecorator, TEXT
import zun.conf
def table_args(): def table_args():
engine_name = urlparse.urlparse(cfg.CONF.database.connection).scheme engine_name = urlparse.urlparse(zun.conf.CONF.database.connection).scheme
if engine_name == 'mysql': if engine_name == 'mysql':
return {'mysql_engine': cfg.CONF.database.mysql_engine, return {'mysql_engine': zun.conf.CONF.database.mysql_engine,
'mysql_charset': "utf8"} 'mysql_charset': "utf8"}
return None return None

View File

@ -1,32 +0,0 @@
# 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 itertools
import zun.api.app
import zun.common.keystone
import zun.common.rpc_service
import zun.common.service
import zun.compute.config
def list_opts():
return [
('DEFAULT',
itertools.chain(
zun.common.rpc_service.periodic_opts,
zun.common.service.service_opts,
)),
('api', zun.api.app.API_SERVICE_OPTS),
('compute', zun.compute.config.SERVICE_OPTS),
('keystone_auth', zun.common.keystone.keystone_auth_opts),
]

View File

@ -24,13 +24,14 @@ import pecan
import testscenarios import testscenarios
from zun.common import context as zun_context from zun.common import context as zun_context
import zun.conf
from zun.objects import base as objects_base from zun.objects import base as objects_base
from zun.tests import conf_fixture from zun.tests import conf_fixture
from zun.tests import policy_fixture from zun.tests import policy_fixture
CONF = cfg.CONF CONF = zun.conf.CONF
try: try:
log.register_options(CONF) log.register_options(CONF)
except cfg.ArgsAlreadyParsedError: except cfg.ArgsAlreadyParsedError:
@ -43,7 +44,7 @@ class BaseTestCase(testscenarios.WithScenarios, base.BaseTestCase):
def setUp(self): def setUp(self):
super(BaseTestCase, self).setUp() super(BaseTestCase, self).setUp()
self.addCleanup(cfg.CONF.reset) self.addCleanup(CONF.reset)
class TestCase(base.BaseTestCase): class TestCase(base.BaseTestCase):

View File

@ -13,15 +13,15 @@
import os import os
import fixtures import fixtures
from oslo_config import cfg
from oslo_policy import _parser from oslo_policy import _parser
from oslo_policy import opts as policy_opts from oslo_policy import opts as policy_opts
from zun.common import policy as zun_policy from zun.common import policy as zun_policy
import zun.conf
from zun.tests import fake_policy from zun.tests import fake_policy
CONF = cfg.CONF CONF = zun.conf.CONF
class PolicyFixture(fixtures.Fixture): class PolicyFixture(fixtures.Fixture):

View File

@ -16,12 +16,12 @@
# NOTE(deva): import auth_token so we can override a config option # NOTE(deva): import auth_token so we can override a config option
from keystonemiddleware import auth_token # noqa from keystonemiddleware import auth_token # noqa
from oslo_config import cfg
import pecan import pecan
import pecan.testing import pecan.testing
from six.moves.urllib import parse as urlparse from six.moves.urllib import parse as urlparse
from zun.api import hooks from zun.api import hooks
import zun.conf
from zun.tests.unit.db import base from zun.tests.unit.db import base
PATH_PREFIX = '/v1' PATH_PREFIX = '/v1'
@ -37,10 +37,12 @@ class FunctionalTest(base.DbTestCase):
def setUp(self): def setUp(self):
super(FunctionalTest, self).setUp() super(FunctionalTest, self).setUp()
cfg.CONF.set_override("auth_version", "v2.0", zun.conf.CONF.set_override("auth_version", "v2.0",
group='keystone_authtoken', enforce_type=True) group='keystone_authtoken',
cfg.CONF.set_override("admin_user", "admin", enforce_type=True)
group='keystone_authtoken', enforce_type=True) zun.conf.CONF.set_override("admin_user", "admin",
group='keystone_authtoken',
enforce_type=True)
# Determine where we are so we can set up paths in the config # Determine where we are so we can set up paths in the config
root_dir = self.get_path() root_dir = self.get_path()

View File

@ -14,10 +14,9 @@ import mock
from glanceclient import client as glanceclient from glanceclient import client as glanceclient
from oslo_config import cfg
from zun.common import clients from zun.common import clients
from zun.common import exception from zun.common import exception
import zun.conf
from zun.tests import base from zun.tests import base
@ -26,10 +25,10 @@ class ClientsTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(ClientsTest, self).setUp() super(ClientsTest, self).setUp()
cfg.CONF.set_override('auth_uri', 'http://server.test:5000/v2.0', zun.conf.CONF.set_override('auth_uri', 'http://server.test:5000/v2.0',
group='keystone_authtoken') group='keystone_authtoken')
cfg.CONF.import_opt('api_version', 'zun.common.clients', zun.conf.CONF.import_opt('api_version', 'zun.conf.glance_client',
group='glance_client') group='glance_client')
@mock.patch.object(clients.OpenStackClients, 'keystone') @mock.patch.object(clients.OpenStackClients, 'keystone')
def test_url_for(self, mock_keystone): def test_url_for(self, mock_keystone):
@ -44,10 +43,10 @@ class ClientsTest(base.BaseTestCase):
def test_zun_url(self, mock_keystone): def test_zun_url(self, mock_keystone):
fake_region = 'fake_region' fake_region = 'fake_region'
fake_endpoint = 'fake_endpoint' fake_endpoint = 'fake_endpoint'
cfg.CONF.set_override('region_name', fake_region, zun.conf.CONF.set_override('region_name', fake_region,
group='zun_client') group='zun_client')
cfg.CONF.set_override('endpoint_type', fake_endpoint, zun.conf.CONF.set_override('endpoint_type', fake_endpoint,
group='zun_client') group='zun_client')
obj = clients.OpenStackClients(None) obj = clients.OpenStackClients(None)
obj.zun_url() obj.zun_url()
@ -70,7 +69,7 @@ class ClientsTest(base.BaseTestCase):
obj._glance = None obj._glance = None
obj.glance() obj.glance()
mock_call.assert_called_once_with( mock_call.assert_called_once_with(
cfg.CONF.glance_client.api_version, zun.conf.CONF.glance_client.api_version,
endpoint='url_from_keystone', username=None, endpoint='url_from_keystone', username=None,
token='3bcc3d3a03f44e3d8377f9247b0ad155', token='3bcc3d3a03f44e3d8377f9247b0ad155',
auth_url='keystone_url', auth_url='keystone_url',
@ -83,7 +82,8 @@ class ClientsTest(base.BaseTestCase):
self._test_clients_glance(None) self._test_clients_glance(None)
def test_clients_glance_region(self): def test_clients_glance_region(self):
cfg.CONF.set_override('region_name', 'myregion', group='glance_client') zun.conf.CONF.set_override('region_name',
'myregion', group='glance_client')
self._test_clients_glance('myregion') self._test_clients_glance('myregion')
def test_clients_glance_noauth(self): def test_clients_glance_noauth(self):

View File

@ -14,10 +14,10 @@
import mock import mock
from oslo_config import cfg
from zun.common import exception from zun.common import exception
from zun.compute import manager from zun.compute import manager
import zun.conf
from zun.objects.container import Container from zun.objects.container import Container
from zun.objects import fields from zun.objects import fields
from zun.tests import base from zun.tests import base
@ -29,7 +29,7 @@ class TestManager(base.TestCase):
def setUp(self): def setUp(self):
super(TestManager, self).setUp() super(TestManager, self).setUp()
cfg.CONF.set_override( zun.conf.CONF.set_override(
'container_driver', 'container_driver',
'zun.tests.unit.container.fake_driver.FakeDriver') 'zun.tests.unit.container.fake_driver.FakeDriver')
self.compute_manager = manager.Manager() self.compute_manager = manager.Manager()

View File

@ -13,6 +13,7 @@
import collections import collections
import mock import mock
from oslo_config import cfg from oslo_config import cfg
import six
from zun.conf import opts from zun.conf import opts
from zun.tests import base from zun.tests import base
@ -22,7 +23,10 @@ class ConfTestCase(base.TestCase):
def test_list_opts(self): def test_list_opts(self):
for group, opt_list in opts.list_opts(): for group, opt_list in opts.list_opts():
self.assertIsInstance(group, cfg.OptGroup) if isinstance(group, six.string_types):
self.assertEqual(group, 'DEFAULT')
else:
self.assertIsInstance(group, cfg.OptGroup)
for opt in opt_list: for opt in opt_list:
self.assertIsInstance(opt, cfg.Opt) self.assertIsInstance(opt, cfg.Opt)

View File

@ -13,8 +13,8 @@
"""Zun DB test base class.""" """Zun DB test base class."""
import fixtures import fixtures
from oslo_config import cfg
import zun.conf
from zun.db import api as db_api from zun.db import api as db_api
from zun.db.sqlalchemy import api as sqla_api from zun.db.sqlalchemy import api as sqla_api
from zun.db.sqlalchemy import migration from zun.db.sqlalchemy import migration
@ -22,7 +22,7 @@ from zun.db.sqlalchemy import models
from zun.tests import base from zun.tests import base
CONF = cfg.CONF CONF = zun.conf.CONF
_DB_CACHE = None _DB_CACHE = None

View File

@ -12,7 +12,7 @@
import mock import mock
from zun.common.rpc_service import CONF import zun.conf
from zun import objects from zun import objects
from zun.servicegroup import zun_service_periodic as periodic from zun.servicegroup import zun_service_periodic as periodic
from zun.tests import base from zun.tests import base
@ -37,7 +37,7 @@ class ZunServicePeriodicTestCase(base.BaseTestCase):
mock_srv_create, mock_srv_create,
mock_srv_get mock_srv_get
): ):
p_task = periodic.ZunServicePeriodicTasks(CONF, p_task = periodic.ZunServicePeriodicTasks(zun.conf.CONF,
'fake-conductor') 'fake-conductor')
mock_srv_get.return_value = None mock_srv_get.return_value = None
@ -53,7 +53,7 @@ class ZunServicePeriodicTestCase(base.BaseTestCase):
def test_update_zun_service_on_restart(self, def test_update_zun_service_on_restart(self,
mock_srv_create, mock_srv_create,
mock_srv_get): mock_srv_get):
p_task = periodic.ZunServicePeriodicTasks(CONF, p_task = periodic.ZunServicePeriodicTasks(zun.conf.CONF,
'fake-conductor') 'fake-conductor')
mock_srv_get.return_value = self.fake_srv mock_srv_get.return_value = self.fake_srv
@ -64,7 +64,7 @@ class ZunServicePeriodicTestCase(base.BaseTestCase):
self.fake_srv_refresh.assert_called_once_with() self.fake_srv_refresh.assert_called_once_with()
def test_update_zun_service_regular(self): def test_update_zun_service_regular(self):
p_task = periodic.ZunServicePeriodicTasks(CONF, p_task = periodic.ZunServicePeriodicTasks(zun.conf.CONF,
'fake-conductor') 'fake-conductor')
p_task.zun_service_ref = self.fake_srv p_task.zun_service_ref = self.fake_srv