Merge "Centralize config option: conductor section"

This commit is contained in:
Jenkins 2016-09-24 01:40:41 +00:00 committed by Gerrit Code Review
commit b7890e5fb2
6 changed files with 49 additions and 49 deletions

View File

@ -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()

View File

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

View File

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

View File

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

38
magnum/conf/conductor.py Normal file
View File

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

View File

@ -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),