move config and opt generation to new kuryr-lib

The config generation was from back when we did not have keystone v3
support, which moved around how it all is generated. This patch puts
kuryr-kubernetes in line with the rest of Kuryr.

Change-Id: I877fa57308aa4c2128bb5d12e801e7e566aef108
Closes-bug: #1626014
Signed-off-by: Antoni Segura Puimedon <antonisp@celebdor.com>
This commit is contained in:
Antoni Segura Puimedon 2016-09-21 15:19:53 +02:00 committed by Antoni Segura Puimedon
parent 2f82bb7ebe
commit ca64e1d5f1
6 changed files with 100 additions and 18 deletions

View File

@ -13,6 +13,39 @@ Note that this is a hard requirement.
* Source: http://git.openstack.org/cgit/openstack/kuryr-kubernetes
* Bugs: http://bugs.launchpad.net/kuryr-kubernetes
Configuring Kuryr
~~~~~~~~~~~~~~~~~
Generate sample config, `etc/kuryr.conf.sample`, running the following::
$ ./tools/generate_config_file_samples.sh
Rename and copy config file at required path::
$ cp etc/kuryr.conf.sample /etc/kuryr/kuryr.conf
Edit Neutron section in `/etc/kuryr/kuryr.conf`, replace ADMIN_PASSWORD::
[neutron]
auth_url = http://127.0.0.1:35357/v3/
username = admin
user_domain_name = Default
password = ADMIN_PASSWORD
project_name = service
project_domain_name = Default
auth_type = password
In the same file uncomment the `bindir` parameter with the path to the Kuryr
vif binding executables. For example, if you installed it on Debian or Ubuntu::
[DEFAULT]
bindir = /usr/local/libexec/kuryr
Features
--------

View File

@ -1,6 +0,0 @@
To generate the sample kuryr.conf file, run the following
command from the top level of the kuryr directory:
tox -e genconfig
The sample file will be generated at etc/kuryr-k8s.conf.sample

View File

@ -2,4 +2,3 @@
output_file = etc/kuryr.conf.sample
wrap_width = 79
namespace = kuryr_kubernetes
namespace = kuryr_lib

View File

@ -16,8 +16,7 @@ from kuryr.lib._i18n import _, _LI
from kuryr.lib import config as lib_config
from oslo_config import cfg
from oslo_log import log as logging
from pbr import version as pbr_version
import pbr.version
LOG = logging.getLogger(__name__)
@ -42,19 +41,18 @@ k8s_opts = [
CONF = cfg.CONF
CONF.register_opts(lib_config.core_opts)
CONF.register_opts(lib_config.neutron_opts, group='neutron_client')
CONF.register_opts(lib_config.keystone_opts, group='keystone_client')
CONF.register_opts(lib_config.binding_opts, 'binding')
CONF.register_opts(kuryr_k8s_opts)
CONF.register_opts(k8s_opts, group='kubernetes')
CONF.register_opts(lib_config.core_opts)
CONF.register_opts(lib_config.binding_opts, 'binding')
lib_config.register_neutron_opts(CONF)
logging.register_options(CONF)
def init(args, **kwargs):
version_k8s = pbr_version.VersionInfo('kuryr-kubernetes').version_string()
version_k8s = pbr.version.VersionInfo('kuryr-kubernetes').version_string()
CONF(args=args, project='kuryr-k8s', version=version_k8s, **kwargs)
@ -62,7 +60,7 @@ def setup_logging():
logging.setup(CONF, 'kuryr-kubernetes')
logging.set_defaults(default_log_levels=logging.get_default_log_levels())
version_k8s = pbr_version.VersionInfo('kuryr-kubernetes').version_string()
version_k8s = pbr.version.VersionInfo('kuryr-kubernetes').version_string()
LOG.info(_LI("Logging enabled!"))
LOG.info(_LI("%(prog)s version %(version)s"),
{'prog': sys.argv[0],

View File

@ -11,6 +11,9 @@
# under the License.
import copy
from oslo_log import _options
from kuryr.lib import opts as lib_opts
from kuryr_kubernetes import config
_kuryr_k8s_opts = [
@ -36,4 +39,5 @@ def list_kuryr_opts():
:returns: a list of (group_name, opts) tuples
"""
return [(k, copy.deepcopy(o)) for k, o in _kuryr_k8s_opts]
return ([(k, copy.deepcopy(o)) for k, o in _kuryr_k8s_opts] +
lib_opts.list_kuryr_opts() + _options.list_opts())

View File

@ -0,0 +1,54 @@
#!/bin/sh
#
# 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.
set -e
GEN_CMD=oslo-config-generator
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
DIST_PATH=$(dirname "$SCRIPT_PATH")
prerequisites() (
if ! command -v "$GEN_CMD" > /dev/null; then
echo "ERROR: $GEN_CMD not installed on the system."
return 1
fi
if ! [ -f "${DIST_PATH}/kuryr_kubernetes.egg-info/entry_points.txt" ]; then
curr_dir=$(pwd)
cd "${DIST_PATH}"
python setup.py egg_info # Generate entrypoints for config generation
cd "${curr_dir}"
fi
return 0
)
generate() (
curr_dir=$(pwd)
cd "${DIST_PATH}"
# Set PYTHONPATH so that it will use the generated egg-info
PYTHONPATH=. find "etc/oslo-config-generator" -type f -exec "$GEN_CMD" --config-file="{}" \;
cd "${curr_dir}"
)
prerequisites
rc=$?
if [ $rc -ne 0 ]; then
exit $rc
fi
generate
set -x