From df6b42b168d0c6fd513bd7475920e532186e5b2e Mon Sep 17 00:00:00 2001 From: Hieu LE Date: Mon, 22 Aug 2016 10:42:44 +0700 Subject: [PATCH] Centralize config option: service section Centralize config option of service section. Replace oslo_conf cfg to magnum.conf. Change-Id: I1d6f4ffb599e2dd3614bb7533d4d50b67c0a1d24 Implements: blueprint centralize-config-magnum --- magnum/common/rpc.py | 4 ++-- magnum/common/service.py | 20 ++++---------------- magnum/conf/__init__.py | 2 ++ magnum/conf/services.py | 35 +++++++++++++++++++++++++++++++++++ magnum/opts.py | 2 -- 5 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 magnum/conf/services.py diff --git a/magnum/common/rpc.py b/magnum/common/rpc.py index 73aa067096..22b2bc9ec8 100644 --- a/magnum/common/rpc.py +++ b/magnum/common/rpc.py @@ -30,15 +30,15 @@ __all__ = [ import socket -from oslo_config import cfg import oslo_messaging as messaging from oslo_serialization import jsonutils from magnum.common import context as magnum_context from magnum.common import exception +import magnum.conf -CONF = cfg.CONF +CONF = magnum.conf.CONF TRANSPORT = None NOTIFIER = None diff --git a/magnum/common/service.py b/magnum/common/service.py index 823bf7b2e1..d92afdc516 100644 --- a/magnum/common/service.py +++ b/magnum/common/service.py @@ -12,31 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from oslo_config import cfg from oslo_log import log as logging from magnum.common import config -from magnum.i18n import _ +import magnum.conf - -service_opts = [ - cfg.StrOpt('host', - default=None, - 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.')), -] - -cfg.CONF.register_opts(service_opts) +CONF = magnum.conf.CONF def prepare_service(argv=None): if argv is None: argv = [] - logging.register_options(cfg.CONF) + logging.register_options(CONF) config.parse_args(argv) config.set_config_defaults() - logging.setup(cfg.CONF, 'magnum') + logging.setup(CONF, 'magnum') diff --git a/magnum/conf/__init__.py b/magnum/conf/__init__.py index 847eb12688..75f03b00d1 100644 --- a/magnum/conf/__init__.py +++ b/magnum/conf/__init__.py @@ -33,6 +33,7 @@ from magnum.conf import neutron from magnum.conf import nova from magnum.conf import paths from magnum.conf import rpc +from magnum.conf import services from magnum.conf import utils # from magnum.conf import x509 @@ -56,5 +57,6 @@ neutron.register_opts(CONF) nova.register_opts(CONF) paths.register_opts(CONF) rpc.register_opts(CONF) +services.register_opts(CONF) utils.register_opts(CONF) # x509.register_opts(CONF) diff --git a/magnum/conf/services.py b/magnum/conf/services.py new file mode 100644 index 0000000000..3e6a61cca4 --- /dev/null +++ b/magnum/conf/services.py @@ -0,0 +1,35 @@ +# 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 magnum.i18n import _ + +service_opts = [ + cfg.StrOpt('host', + default=None, + 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.')), +] + + +def register_opts(conf): + conf.register_opts(service_opts) + + +def list_opts(): + return { + "DEFAULT": service_opts + } diff --git a/magnum/opts.py b/magnum/opts.py index b9d58a21d5..7967bfc073 100644 --- a/magnum/opts.py +++ b/magnum/opts.py @@ -19,7 +19,6 @@ import magnum.common.cert_manager from magnum.common.cert_manager import local_cert_manager import magnum.common.docker_utils import magnum.common.exception -import magnum.common.service import magnum.common.x509.config import magnum.db import magnum.drivers.common.template_def @@ -27,7 +26,6 @@ import magnum.drivers.common.template_def def list_opts(): return [ - ('DEFAULT', magnum.common.service.service_opts), ('docker', magnum.common.docker_utils.docker_opts), ('trust', magnum.common.keystone.trust_opts), ('x509', magnum.common.x509.config.x509_opts),