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
This commit is contained in:
Hieu LE 2016-08-22 10:42:44 +07:00
parent 1a97476593
commit df6b42b168
5 changed files with 43 additions and 20 deletions

View File

@ -30,15 +30,15 @@ __all__ = [
import socket import socket
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 magnum.common import context as magnum_context from magnum.common import context as magnum_context
from magnum.common import exception from magnum.common import exception
import magnum.conf
CONF = cfg.CONF CONF = magnum.conf.CONF
TRANSPORT = None TRANSPORT = None
NOTIFIER = None NOTIFIER = None

View File

@ -12,31 +12,19 @@
# 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_log import log as logging from oslo_log import log as logging
from magnum.common import config from magnum.common import config
from magnum.i18n import _ import magnum.conf
CONF = magnum.conf.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)
def prepare_service(argv=None): def prepare_service(argv=None):
if argv is None: if argv is None:
argv = [] argv = []
logging.register_options(cfg.CONF) logging.register_options(CONF)
config.parse_args(argv) config.parse_args(argv)
config.set_config_defaults() config.set_config_defaults()
logging.setup(cfg.CONF, 'magnum') logging.setup(CONF, 'magnum')

View File

@ -33,6 +33,7 @@ from magnum.conf import neutron
from magnum.conf import nova from magnum.conf import nova
from magnum.conf import paths from magnum.conf import paths
from magnum.conf import rpc from magnum.conf import rpc
from magnum.conf import services
from magnum.conf import utils from magnum.conf import utils
# from magnum.conf import x509 # from magnum.conf import x509
@ -56,5 +57,6 @@ neutron.register_opts(CONF)
nova.register_opts(CONF) nova.register_opts(CONF)
paths.register_opts(CONF) paths.register_opts(CONF)
rpc.register_opts(CONF) rpc.register_opts(CONF)
services.register_opts(CONF)
utils.register_opts(CONF) utils.register_opts(CONF)
# x509.register_opts(CONF) # x509.register_opts(CONF)

35
magnum/conf/services.py Normal file
View File

@ -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
}

View File

@ -19,7 +19,6 @@ import magnum.common.cert_manager
from magnum.common.cert_manager import local_cert_manager from magnum.common.cert_manager import local_cert_manager
import magnum.common.docker_utils import magnum.common.docker_utils
import magnum.common.exception import magnum.common.exception
import magnum.common.service
import magnum.common.x509.config import magnum.common.x509.config
import magnum.db import magnum.db
import magnum.drivers.common.template_def import magnum.drivers.common.template_def
@ -27,7 +26,6 @@ import magnum.drivers.common.template_def
def list_opts(): def list_opts():
return [ return [
('DEFAULT', magnum.common.service.service_opts),
('docker', magnum.common.docker_utils.docker_opts), ('docker', magnum.common.docker_utils.docker_opts),
('trust', magnum.common.keystone.trust_opts), ('trust', magnum.common.keystone.trust_opts),
('x509', magnum.common.x509.config.x509_opts), ('x509', magnum.common.x509.config.x509_opts),