add initial oslo config framework

this adds just enough infrastructure to run the oslo-config
generator command to generate a sample config file.
This commit is contained in:
Steve Noyes 2015-11-18 17:40:12 -05:00
parent 78d0cc608a
commit 6f2bef054e
8 changed files with 117 additions and 3 deletions

View File

@ -42,6 +42,7 @@ Requires: python-babel >= 2.0
Requires: python-cliff >= 1.13.0
Requires: python-cliff-tablib >= 1.1
Requires: python-jsonpickle >= 0.9.2
Requires: python-oslo-config >= 2.3.0
Requires: python-oslo-i18n >= 2.5.0
Requires: python-oslo-utils >= 2.4.0
Requires: python-paramiko >= 1.15.1

View File

85
kollacli/common/config.py Normal file
View File

@ -0,0 +1,85 @@
# Copyright 2010-2011 OpenStack LLC.
#
# 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.
"""
Configuration setup for kollacli.
"""
import logging
import os
from oslo_config import cfg
from kollacli import i18n as u
from kollacli import version
MAX_LOG_SIZE = 500000
log_opts = [
cfg.IntOpt('max_size_of_log_in_bytes',
default=MAX_LOG_SIZE,
help=u._('The maximum log size in bytes.')),
]
def parse_args(conf, args=None, usage=None, default_config_files=None):
conf(args=args if args else [],
project='kollacli',
prog='kollacli',
version=version.__version__,
usage=usage,
default_config_files=default_config_files)
conf.pydev_debug_host = os.environ.get('PYDEV_DEBUG_HOST')
conf.pydev_debug_port = os.environ.get('PYDEV_DEBUG_PORT')
def list_opts():
yield None, log_opts
def new_config():
conf = cfg.ConfigOpts()
conf.register_opts(log_opts)
return conf
def setup_remote_pydev_debug():
"""Required setup for remote debugging."""
if CONF.pydev_debug_host and CONF.pydev_debug_port:
try:
try:
from pydev import pydevd
except ImportError:
import pydevd
pydevd.settrace(CONF.pydev_debug_host,
port=int(CONF.pydev_debug_port),
stdoutToServer=True,
stderrToServer=True)
except Exception:
LOG.exception('Unable to join debugger, please '
'make sure that the debugger processes is '
'listening on debug-host \'%s\' debug-port \'%s\'.',
CONF.pydev_debug_host, CONF.pydev_debug_port)
raise
CONF = new_config()
LOG = logging.getLogger(__name__)
parse_args(CONF)

19
kollacli/version.py Normal file
View File

@ -0,0 +1,19 @@
# Copyright 2010-2011 OpenStack LLC.
# All Rights Reserved.
#
# 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 pbr.version
version_info = pbr.version.VersionInfo('kollacli')
__version__ = version_info.release_string()

View File

@ -4,6 +4,7 @@ cliff>=1.13.0 # Apache-2.0
cliff-tablib>=1.1
docker-py>=1.3.1
jsonpickle>=0.9
oslo.config>=2.3.0 # Apache-2.0
oslo.i18n>=1.3.0 # Apache-2.0
oslo.utils!=2.6.0,>=2.4.0 # Apache-2.0
paramiko>=1.15

View File

@ -30,9 +30,12 @@ packages =
console_scripts =
kollacli = kollacli.shell:main
oslo.config.opts =
kollacli.common.config = kollacli.common.config:list_opts
kolla.cli =
deploy = kollacli.common:Deploy
dump = kollacli.common:Dump
deploy = kollacli.misc:Deploy
dump = kollacli.misc:Dump
group_add = kollacli.group:GroupAdd
group_addhost = kollacli.group:GroupAddhost
group_listhosts = kollacli.group:GroupListhosts
@ -55,7 +58,7 @@ kolla.cli =
service_list = kollacli.service:ServiceList
service_listgroups = kollacli.service:ServiceListGroups
service_removegroup = kollacli.service:ServiceRemoveGroup
setdeploy = kollacli.common:Setdeploy
setdeploy = kollacli.misc:Setdeploy
[extract_messages]
keywords = _ gettext ngettext l_ lazy_gettext

View File

@ -34,3 +34,8 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
[testenv:bandit]
deps = -r{toxinidir}/test-requirements.txt
commands = bandit -r kollacli
[testenv:genconfig]
commands =
oslo-config-generator --namespace kollacli.common.config