diff --git a/magnum/cmd/conductor.py b/magnum/cmd/conductor.py index c33dfd9d1c..595e20da3b 100644 --- a/magnum/cmd/conductor.py +++ b/magnum/cmd/conductor.py @@ -17,7 +17,6 @@ import os import sys -from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr from oslo_service import service @@ -29,9 +28,11 @@ from magnum.conductor.handlers import ca_conductor from magnum.conductor.handlers import cluster_conductor from magnum.conductor.handlers import conductor_listener from magnum.conductor.handlers import indirection_api +import magnum.conf from magnum.i18n import _LI from magnum import version +CONF = magnum.conf.CONF LOG = logging.getLogger(__name__) @@ -42,9 +43,7 @@ def main(): LOG.info(_LI('Starting server in PID %s'), os.getpid()) LOG.debug("Configuration:") - cfg.CONF.log_opt_values(LOG, logging.DEBUG) - - cfg.CONF.import_opt('topic', 'magnum.conductor.config', group='conductor') + CONF.log_opt_values(LOG, logging.DEBUG) conductor_id = short_id.generate_id() endpoints = [ @@ -54,8 +53,8 @@ def main(): ca_conductor.Handler(), ] - server = rpc_service.Service.create(cfg.CONF.conductor.topic, + server = rpc_service.Service.create(CONF.conductor.topic, conductor_id, endpoints, binary='magnum-conductor') - launcher = service.launch(cfg.CONF, server) + launcher = service.launch(CONF, server) launcher.wait() diff --git a/magnum/conductor/api.py b/magnum/conductor/api.py index 0e10975ef1..4d70616140 100644 --- a/magnum/conductor/api.py +++ b/magnum/conductor/api.py @@ -11,22 +11,21 @@ # limitations under the License. """API for interfacing with Magnum Backend.""" -from oslo_config import cfg from magnum.common import rpc_service +import magnum.conf +CONF = magnum.conf.CONF # The Backend API class serves as a AMQP client for communicating # on a topic exchange specific to the conductors. This allows the ReST # API to trigger operations on the conductors + class API(rpc_service.API): def __init__(self, transport=None, context=None, topic=None): - if topic is None: - cfg.CONF.import_opt('topic', 'magnum.conductor.config', - group='conductor') super(API, self).__init__(transport, context, - topic=cfg.CONF.conductor.topic) + topic=CONF.conductor.topic) # Cluster Operations diff --git a/magnum/conductor/config.py b/magnum/conductor/config.py deleted file mode 100644 index d2e725dd10..0000000000 --- a/magnum/conductor/config.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2014 - Rackspace Hosting -# -# 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. - -"""Config options for Magnum Backend service.""" - - -from oslo_config import cfg - -SERVICE_OPTS = [ - cfg.StrOpt('topic', - default='magnum-conductor', - help='The queue to add conductor tasks to.'), - cfg.IntOpt('conductor_life_check_timeout', - default=4, - help=('RPC timeout for the conductor liveness check that is ' - 'used for bay locking.')), -] - -opt_group = cfg.OptGroup( - name='conductor', - title='Options for the magnum-conductor service') -cfg.CONF.register_group(opt_group) -cfg.CONF.register_opts(SERVICE_OPTS, opt_group) diff --git a/magnum/conf/__init__.py b/magnum/conf/__init__.py index 85238ec9fe..0d119b9f2e 100644 --- a/magnum/conf/__init__.py +++ b/magnum/conf/__init__.py @@ -21,7 +21,7 @@ from magnum.conf import barbican from magnum.conf import cinder from magnum.conf import cluster # from magnum.conf import cluster_templates -# from magnum.conf import conductor +from magnum.conf import conductor # from magnum.conf import database # from magnum.conf import docker from magnum.conf import glance @@ -40,7 +40,7 @@ cluster.register_opts(CONF) # cluster_templates.register_opts(CONF) # certificates.register_opts(CONF) cinder.register_opts(CONF) -# conductor.register_opts(CONF) +conductor.register_opts(CONF) # database.register_opts(CONF) # docker.register_opts(CONF) glance.register_opts(CONF) diff --git a/magnum/conf/conductor.py b/magnum/conf/conductor.py new file mode 100644 index 0000000000..65a968dfc9 --- /dev/null +++ b/magnum/conf/conductor.py @@ -0,0 +1,38 @@ +# 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 + +conductor_group = cfg.OptGroup(name='conductor', + title='Options for the magnum-conductor ' + 'service') + +conductor_service_opts = [ + cfg.StrOpt('topic', + default='magnum-conductor', + help='The queue to add conductor tasks to.'), + cfg.IntOpt('conductor_life_check_timeout', + default=4, + help=('RPC timeout for the conductor liveness check that is ' + 'used for cluster locking.')), +] + + +def register_opts(conf): + conf.register_group(conductor_group) + conf.register_opts(conductor_service_opts, group=conductor_group) + + +def list_opts(): + return { + conductor_group: conductor_service_opts + } diff --git a/magnum/opts.py b/magnum/opts.py index 0cc6984b31..2bd604c224 100644 --- a/magnum/opts.py +++ b/magnum/opts.py @@ -22,7 +22,6 @@ import magnum.common.exception import magnum.common.rpc_service import magnum.common.service import magnum.common.x509.config -import magnum.conductor.config import magnum.conductor.handlers.cluster_conductor import magnum.db @@ -35,7 +34,6 @@ def list_opts(): magnum.common.rpc_service.periodic_opts, magnum.common.service.service_opts, )), - ('conductor', magnum.conductor.config.SERVICE_OPTS), ('database', magnum.db.sql_opts), ('docker', magnum.common.docker_utils.docker_opts), ('trust', magnum.common.keystone.trust_opts),