Centralize config option: paths section
Centralize config option of Paths section. Replace oslo_conf cfg to magnum.conf. Modify test_conf test case for covering DEFAULT section Change-Id: I45775016cdfd7e762c9faa5aa18fc020a07c8134 Implements: blueprint centralize-config-magnum
This commit is contained in:
parent
8f9eeb801a
commit
e4627ab6dd
|
@ -31,6 +31,7 @@ from magnum.conf import heat
|
|||
from magnum.conf import magnum_client
|
||||
from magnum.conf import neutron
|
||||
from magnum.conf import nova
|
||||
from magnum.conf import paths
|
||||
# from magnum.conf import x509
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -51,4 +52,5 @@ heat.register_opts(CONF)
|
|||
magnum_client.register_opts(CONF)
|
||||
neutron.register_opts(CONF)
|
||||
nova.register_opts(CONF)
|
||||
paths.register_opts(CONF)
|
||||
# x509.register_opts(CONF)
|
||||
|
|
|
@ -19,7 +19,7 @@ import os
|
|||
|
||||
from oslo_config import cfg
|
||||
|
||||
PATH_OPTS = [
|
||||
path_opts = [
|
||||
cfg.StrOpt('pybasedir',
|
||||
default=os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'../')),
|
||||
|
@ -32,9 +32,6 @@ PATH_OPTS = [
|
|||
help="Top-level directory for maintaining magnum's state."),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(PATH_OPTS)
|
||||
|
||||
|
||||
def basedir_def(*args):
|
||||
"""Return an uninterpolated path relative to $pybasedir."""
|
||||
|
@ -51,16 +48,11 @@ def state_path_def(*args):
|
|||
return os.path.join('$state_path', *args)
|
||||
|
||||
|
||||
def basedir_rel(*args):
|
||||
"""Return a path relative to $pybasedir."""
|
||||
return os.path.join(CONF.pybasedir, *args)
|
||||
def register_opts(conf):
|
||||
conf.register_opts(path_opts)
|
||||
|
||||
|
||||
def bindir_rel(*args):
|
||||
"""Return a path relative to $bindir."""
|
||||
return os.path.join(CONF.bindir, *args)
|
||||
|
||||
|
||||
def state_path_rel(*args):
|
||||
"""Return a path relative to $state_path."""
|
||||
return os.path.join(CONF.state_path, *args)
|
||||
def list_opts():
|
||||
return {
|
||||
"DEFAULT": path_opts
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
from oslo_config import cfg
|
||||
from oslo_db import options
|
||||
|
||||
from magnum.common import paths
|
||||
from magnum.conf import paths
|
||||
|
||||
|
||||
sql_opts = [
|
||||
|
|
|
@ -29,8 +29,7 @@ import magnum.drivers.common.template_def
|
|||
def list_opts():
|
||||
return [
|
||||
('DEFAULT',
|
||||
itertools.chain(magnum.common.paths.PATH_OPTS,
|
||||
magnum.common.utils.UTILS_OPTS,
|
||||
itertools.chain(magnum.common.utils.UTILS_OPTS,
|
||||
magnum.common.rpc_service.periodic_opts,
|
||||
magnum.common.service.service_opts,
|
||||
)),
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import collections
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from magnum.conf import opts
|
||||
from magnum.tests import base
|
||||
|
@ -24,7 +25,10 @@ class ConfTestCase(base.TestCase):
|
|||
|
||||
def test_list_opts(self):
|
||||
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:
|
||||
self.assertIsInstance(opt, cfg.Opt)
|
||||
|
||||
|
|
|
@ -18,11 +18,9 @@ from glob import glob
|
|||
from oslo_config import cfg
|
||||
from yaml import load
|
||||
|
||||
|
||||
from magnum.common import paths
|
||||
from magnum.conf import paths
|
||||
from magnum.tests import base
|
||||
|
||||
|
||||
cfg.CONF.register_opts([cfg.StrOpt('template_path',
|
||||
default=paths.basedir_def('templates'),
|
||||
help='Heat template path')])
|
||||
|
|
Loading…
Reference in New Issue