Merge "Fix use of the oslo-config-generator"

This commit is contained in:
Jenkins 2014-12-18 15:49:22 +00:00 committed by Gerrit Code Review
commit e8cdd14bc8
9 changed files with 71 additions and 31 deletions

View File

@ -1,5 +0,0 @@
[DEFAULT]
output_file = etc/muranoagent/muranoagent.conf.sample
namespace = muranoagent.common.config
namespace = muranoagent.openstack.common.log
namespace = muranoagent.openstack.common.eventlet_backdoor

View File

@ -0,0 +1,3 @@
[DEFAULT]
output_file = etc/muranoagent/muranoagent.conf.sample
namespace = muranoagent

View File

@ -17,7 +17,6 @@
Routines for configuring Murano-Agent
"""
import copy
import logging
import logging.config
import logging.handlers
@ -29,9 +28,12 @@ from oslo.config import cfg
from muranoagent import version
CONF = cfg.CONF
CONF.register_cli_opt(cfg.StrOpt('storage',
default='/var/murano/plans',
help='Directory to store execution plans'))
storage_opt = [
cfg.StrOpt('storage',
default='/var/murano/plans',
help='Directory to store execution plans')
]
rabbit_opts = [
cfg.StrOpt('host',
@ -66,13 +68,10 @@ rabbit_opts = [
]
CONF.register_cli_opts(storage_opt)
CONF.register_opts(rabbit_opts, group='rabbitmq')
def list_opts():
return [('rabbitmq', copy.deepcopy(rabbit_opts))]
def parse_args(args=None, usage=None, default_config_files=None):
version_string = version.version_info.version_string()
CONF(args=args,

View File

@ -17,7 +17,6 @@
from __future__ import print_function
import errno
import copy
import gc
import os
import pprint
@ -58,9 +57,6 @@ class EventletBackdoorConfigValueError(Exception):
super(EventletBackdoorConfigValueError, self).__init__(msg)
self.port_range = port_range
def list_opts():
return [(None, copy.deepcopy(eventlet_backdoor_opts))]
def _dont_use_this():
print("Don't use this, just disconnect instead")

View File

@ -27,7 +27,6 @@ It also allows setting of formatting information through conf.
"""
import copy
import inspect
import itertools
import logging
@ -184,14 +183,6 @@ CONF.register_opts(log_opts)
logging.AUDIT = logging.INFO + 1
logging.addLevelName(logging.AUDIT, 'AUDIT')
def list_opts():
yield None, copy.deepcopy(common_cli_opts)
yield None, copy.deepcopy(logging_cli_opts)
yield None, copy.deepcopy(generic_log_opts)
yield None, copy.deepcopy(log_opts)
try:
NullHandler = logging.NullHandler
except AttributeError: # NOTE(jkoelker) NullHandler added in Python 2.7

59
muranoagent/opts.py Normal file
View File

@ -0,0 +1,59 @@
# Copyright (c) 2014 Mirantis, Inc.
#
# 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.
import copy
import itertools
import muranoagent.common.config
import muranoagent.openstack.common.eventlet_backdoor
import muranoagent.openstack.common.log
def build_list(opt_list):
return list(itertools.chain(*opt_list))
# List of *all* options in [DEFAULT] namespace of murano.
# Any new option list or option needs to be registered here.
_opt_lists = [
('rabbitmq', muranoagent.common.config.rabbit_opts),
(None, build_list([
muranoagent.common.config.storage_opt,
muranoagent.openstack.common.eventlet_backdoor.eventlet_backdoor_opts,
muranoagent.openstack.common.log.common_cli_opts,
muranoagent.openstack.common.log.generic_log_opts,
muranoagent.openstack.common.log.log_opts,
muranoagent.openstack.common.log.logging_cli_opts
]))
]
def list_opts():
"""Return a list of oslo.config options available in Murano-Agent.
Each element of the list is a tuple. The first element is the name of the
group under which the list of elements in the second element will be
registered. A group name of None corresponds to the [DEFAULT] group in
config files.
This function is also discoverable via the 'muranoagent' entry point
under the 'oslo.config.opts' namespace.
The purpose of this is to allow tools like the Oslo sample config file
generator to discover the options exposed to users by Murano.
:returns: a list of (group_name, opts) tuples
"""
return [(g, copy.deepcopy(o)) for g, o in _opt_lists]

View File

@ -7,7 +7,6 @@ module=importutils
module=jsonutils
module=log
module=install_venv_common
module=config
module=service
module=strutils

View File

@ -27,9 +27,7 @@ setup-hooks =
[entry_points]
oslo.config.opts =
muranoagent.common.config = muranoagent.common.config:list_opts
muranoagent.openstack.common.eventlet_backdoor = muranoagent.openstack.common.eventlet_backdoor:list_opts
muranoagent.openstack.common.log = muranoagent.openstack.common.log:list_opts
muranoagent = muranoagent.opts:list_opts
console_scripts =
muranoagent = muranoagent.cmd.run:main

View File

@ -32,7 +32,7 @@ deps = flake8
commands = flake8
[testenv:genconfig]
commands = oslo-config-generator --config-file config-generator.conf
commands = oslo-config-generator --config-file etc/oslo-config-generator/muranoagent.conf
[flake8]
# H301 one import per line