From cc839e86afac6bd1f3cc7a6fc5fc8ccc326f6ea7 Mon Sep 17 00:00:00 2001 From: Hieu LE Date: Mon, 22 Aug 2016 10:20:47 +0700 Subject: [PATCH] Centralize config option: utils section Centralize config option of utils section. Replace oslo_conf cfg to magnum.conf. Change-Id: I0014d8dfaf81d845bc92e145ffff9fecaed7240d Implements: blueprint centralize-config-magnum --- magnum/common/utils.py | 25 ++---------------------- magnum/conf/__init__.py | 2 ++ magnum/conf/utils.py | 42 +++++++++++++++++++++++++++++++++++++++++ magnum/opts.py | 4 +--- 4 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 magnum/conf/utils.py diff --git a/magnum/common/utils.py b/magnum/common/utils.py index dc2682afc6..c4d7f07827 100644 --- a/magnum/common/utils.py +++ b/magnum/common/utils.py @@ -26,36 +26,15 @@ import shutil import tempfile from oslo_concurrency import processutils -from oslo_config import cfg from oslo_log import log as logging import six from magnum.common import exception +import magnum.conf from magnum.i18n import _LE from magnum.i18n import _LW - -# Default symbols to use for passwords. Avoids visually confusing characters. -# ~6 bits per symbol -DEFAULT_PASSWORD_SYMBOLS = ['23456789', # Removed: 0,1 - 'ABCDEFGHJKLMNPQRSTUVWXYZ', # Removed: I, O - 'abcdefghijkmnopqrstuvwxyz'] # Removed: l - -UTILS_OPTS = [ - cfg.StrOpt('rootwrap_config', - default="/etc/magnum/rootwrap.conf", - help='Path to the rootwrap configuration file to use for ' - 'running commands as root.'), - cfg.StrOpt('tempdir', - help='Explicitly specify the temporary working directory.'), - cfg.ListOpt('password_symbols', - default=DEFAULT_PASSWORD_SYMBOLS, - help='Symbols to use for passwords') -] - -CONF = cfg.CONF -CONF.register_opts(UTILS_OPTS) - +CONF = magnum.conf.CONF LOG = logging.getLogger(__name__) MEMORY_UNITS = { diff --git a/magnum/conf/__init__.py b/magnum/conf/__init__.py index 0303abcdff..fbfcdc3d6b 100644 --- a/magnum/conf/__init__.py +++ b/magnum/conf/__init__.py @@ -32,6 +32,7 @@ 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 utils # from magnum.conf import x509 CONF = cfg.CONF @@ -53,4 +54,5 @@ magnum_client.register_opts(CONF) neutron.register_opts(CONF) nova.register_opts(CONF) paths.register_opts(CONF) +utils.register_opts(CONF) # x509.register_opts(CONF) diff --git a/magnum/conf/utils.py b/magnum/conf/utils.py new file mode 100644 index 0000000000..d7acb35b7e --- /dev/null +++ b/magnum/conf/utils.py @@ -0,0 +1,42 @@ +# 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 + + +# Default symbols to use for passwords. Avoids visually confusing characters. +# ~6 bits per symbol +DEFAULT_PASSWORD_SYMBOLS = ['23456789', # Removed: 0,1 + 'ABCDEFGHJKLMNPQRSTUVWXYZ', # Removed: I, O + 'abcdefghijkmnopqrstuvwxyz'] # Removed: l + +utils_opts = [ + cfg.StrOpt('rootwrap_config', + default="/etc/magnum/rootwrap.conf", + help='Path to the rootwrap configuration file to use for ' + 'running commands as root.'), + cfg.StrOpt('tempdir', + help='Explicitly specify the temporary working directory.'), + cfg.ListOpt('password_symbols', + default=DEFAULT_PASSWORD_SYMBOLS, + help='Symbols to use for passwords') +] + + +def register_opts(conf): + conf.register_opts(utils_opts) + + +def list_opts(): + return { + "DEFAULT": utils_opts + } diff --git a/magnum/opts.py b/magnum/opts.py index 95ad52514c..36ee04cb7b 100644 --- a/magnum/opts.py +++ b/magnum/opts.py @@ -20,7 +20,6 @@ from magnum.common.cert_manager import local_cert_manager import magnum.common.exception import magnum.common.rpc_service import magnum.common.service -import magnum.common.utils import magnum.common.x509.config import magnum.db import magnum.drivers.common.template_def @@ -29,8 +28,7 @@ import magnum.drivers.common.template_def def list_opts(): return [ ('DEFAULT', - itertools.chain(magnum.common.utils.UTILS_OPTS, - magnum.common.rpc_service.periodic_opts, + itertools.chain(magnum.common.rpc_service.periodic_opts, magnum.common.service.service_opts, )), ('docker', magnum.common.docker_utils.docker_opts),