Oslo config integration (#1)
* DECKHAND-11: Add oslo.config integration to Deckhand This commit adds oslo.config integration to Deckhand. It also creates a lot of preliminary files/configuration settings needed to run tox as well as lint and oslo-config-generator jobs. * Remove sample config file.
This commit is contained in:
parent
98cb4bc958
commit
eab524abd8
1
.gitignore
vendored
1
.gitignore
vendored
@ -24,6 +24,7 @@ wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
etc/*.sample
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
|
2
AUTHORS
Normal file
2
AUTHORS
Normal file
@ -0,0 +1,2 @@
|
||||
Alan Meadows <alan.meadows@gmail.com>
|
||||
Felipe Monteiro <felipe.monteiro@att.com>
|
@ -1,4 +1,6 @@
|
||||
CHANGES
|
||||
=======
|
||||
|
||||
* DECKHAND-11: Add oslo.config integration to Deckhand
|
||||
* Add ChangeLog
|
||||
* Initial commit
|
||||
|
@ -1,2 +0,0 @@
|
||||
# deckhand
|
||||
A foundational python REST YAML processing engine providing data and secrets management to other platform services.
|
4
README.rst
Normal file
4
README.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Deckhand
|
||||
========
|
||||
A foundational python REST YAML processing engine providing data and secrets
|
||||
management to other platform services.
|
0
deckhand/__init__.py
Normal file
0
deckhand/__init__.py
Normal file
0
deckhand/conf/__init__.py
Normal file
0
deckhand/conf/__init__.py
Normal file
33
deckhand/conf/config.py
Normal file
33
deckhand/conf/config.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Copyright 2017 AT&T Intellectual Property. All other 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
barbican_group = cfg.OptGroup(
|
||||
name='barbican',
|
||||
title='Barbican Options',
|
||||
help="""
|
||||
Barbican options for allowing Deckhand to communicate with Barbican.
|
||||
""")
|
||||
|
||||
barbican_opts = []
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(barbican_group)
|
||||
conf.register_opts(barbican_opts, group=barbican_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {barbican_group: barbican_opts}
|
78
deckhand/conf/opts.py
Normal file
78
deckhand/conf/opts.py
Normal file
@ -0,0 +1,78 @@
|
||||
# Copyright 2017 AT&T Intellectual Property. All other 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 collections
|
||||
import importlib
|
||||
import os
|
||||
import pkgutil
|
||||
|
||||
LIST_OPTS_FUNC_NAME = "list_opts"
|
||||
|
||||
|
||||
def _tupleize(dct):
|
||||
"""Take the dict of options and convert to the 2-tuple format."""
|
||||
return [(key, val) for key, val in dct.items()]
|
||||
|
||||
|
||||
def list_opts():
|
||||
"""Entry point used only in the context of sample file generation.
|
||||
|
||||
This is the single point of entry to generate the sample configuration
|
||||
file for Deckhand. It collects all the necessary info from the other
|
||||
modules in this package. It is assumed that:
|
||||
|
||||
* every other module in this package has a 'list_opts' function which
|
||||
return a dict where
|
||||
* the keys are strings which are the group names
|
||||
* the value of each key is a list of config options for that group
|
||||
* the deckhand.conf package doesn't have further packages with config
|
||||
options
|
||||
"""
|
||||
opts = collections.defaultdict(list)
|
||||
module_names = _list_module_names()
|
||||
imported_modules = _import_modules(module_names)
|
||||
_append_config_options(imported_modules, opts)
|
||||
return _tupleize(opts)
|
||||
|
||||
|
||||
def _list_module_names():
|
||||
module_names = []
|
||||
package_path = os.path.dirname(os.path.abspath(__file__))
|
||||
for _, modname, ispkg in pkgutil.iter_modules(path=[package_path]):
|
||||
if modname == "opts" or ispkg:
|
||||
continue
|
||||
else:
|
||||
module_names.append(modname)
|
||||
return module_names
|
||||
|
||||
|
||||
def _import_modules(module_names):
|
||||
imported_modules = []
|
||||
for modname in module_names:
|
||||
mod = importlib.import_module("deckhand.conf." + modname)
|
||||
if not hasattr(mod, LIST_OPTS_FUNC_NAME):
|
||||
msg = "The module 'deckhand.conf.%s' should have a '%s' "\
|
||||
"function which returns the config options." % \
|
||||
(modname, LIST_OPTS_FUNC_NAME)
|
||||
raise Exception(msg)
|
||||
else:
|
||||
imported_modules.append(mod)
|
||||
return imported_modules
|
||||
|
||||
|
||||
def _append_config_options(imported_modules, config_options):
|
||||
for mod in imported_modules:
|
||||
configs = mod.list_opts()
|
||||
for key, val in configs.items():
|
||||
config_options[key].extend(val)
|
4
etc/deckhand/config-generator.conf
Normal file
4
etc/deckhand/config-generator.conf
Normal file
@ -0,0 +1,4 @@
|
||||
[DEFAULT]
|
||||
output_file = etc/deckhand/deckhand.conf.sample
|
||||
wrap_width = 80
|
||||
namespace = deckhand.conf
|
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# API
|
||||
falcon==1.1.0
|
||||
|
||||
# Oslo
|
||||
oslo.config>=3.22.0 # Apache-2.0
|
28
setup.cfg
Normal file
28
setup.cfg
Normal file
@ -0,0 +1,28 @@
|
||||
[metadata]
|
||||
name = deckhand
|
||||
summary = Secrets management persistence tool.
|
||||
description-file = README.rst
|
||||
|
||||
author = deckhand team
|
||||
home-page = http://deckhand-helm.readthedocs.io/en/latest/
|
||||
classifier =
|
||||
Intended Audience :: Information Technology
|
||||
Intended Audience :: System Administrators
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2
|
||||
Programming Language :: Python :: 2.7
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.5
|
||||
|
||||
[files]
|
||||
packages =
|
||||
deckhand
|
||||
|
||||
[entry_points]
|
||||
oslo.config.opts =
|
||||
deckhand.conf = deckhand.conf.opts:list_opts
|
||||
|
||||
[pbr]
|
||||
warnerrors = True
|
27
setup.py
Normal file
27
setup.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright 2017 AT&T Intellectual Property. All other 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 setuptools
|
||||
|
||||
# In python < 2.7.4, a lazy loading of package `pbr` will break
|
||||
# setuptools if some other modules registered functions in `atexit`.
|
||||
# solution from: http://bugs.python.org/issue15881#msg170215
|
||||
try:
|
||||
import multiprocessing # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr>=2.0.0'],
|
||||
pbr=True)
|
0
test-requirements.txt
Normal file
0
test-requirements.txt
Normal file
24
tox.ini
Normal file
24
tox.ini
Normal file
@ -0,0 +1,24 @@
|
||||
[tox]
|
||||
envlist = py35,py27,pep8
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
LANGUAGE=en_US
|
||||
LC_ALL=en_US.utf-8
|
||||
deps=
|
||||
-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
whitelist_externals = flake8
|
||||
|
||||
[testenv:genconfig]
|
||||
commands = oslo-config-generator --config-file=etc/deckhand/config-generator.conf
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8 {posargs}
|
||||
|
||||
[flake8]
|
||||
# D100, D103, D104 deal with docstrings in public functions
|
||||
# D205, D400, D401 deal with docstring formatting
|
||||
ignore=E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405,D100,D103,D104,D205,D400,D401
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools/xenserver*,releasenotes
|
Loading…
Reference in New Issue
Block a user