Browse Source

Generate the karbor.conf.sample with oslo-config-generator

It's hard to maintain karbor.conf by hand, let's switch to use
oslo-config-generator and follow OpenStack convention.

Change-Id: I0dd0a63267e14321ff723d32bd6d90db07cc5f95
changes/18/470218/7
Jeremy Liu 4 years ago
parent
commit
dba51806f2
8 changed files with 128 additions and 32 deletions
  1. +1
    -0
      .gitignore
  2. +5
    -0
      devstack/plugin.sh
  3. +0
    -31
      etc/karbor.conf
  4. +9
    -0
      etc/oslo-config-generator/karbor.conf
  5. +101
    -0
      karbor/common/opts.py
  6. +4
    -0
      releasenotes/notes/use-oslo-config-generator-f2a9be9e71d90b1f.yaml
  7. +2
    -0
      setup.cfg
  8. +6
    -1
      tox.ini

+ 1
- 0
.gitignore View File

@ -51,3 +51,4 @@ ChangeLog
.*sw?
releasenotes/build
etc/karbor.conf.sample

+ 5
- 0
devstack/plugin.sh View File

@ -114,6 +114,11 @@ function configure_karbor_api {
if is_service_enabled karbor-api ; then
echo "Configuring Karbor API"
# generate configuration file
cd $KARBOR_DIR
tox -e genconfig
cp etc/karbor.conf.sample etc/karbor.conf
cp $KARBOR_DIR/etc/karbor.conf $KARBOR_API_CONF
cp $KARBOR_DIR/etc/api-paste.ini $KARBOR_CONF_DIR
cp $KARBOR_DIR/etc/policy.json $KARBOR_CONF_DIR


+ 0
- 31
etc/karbor.conf View File

@ -1,31 +0,0 @@
[keystone_authtoken]
#signing_dir = /var/cache/karbor
#cafile = /opt/stack/data/ca-bundle.pem
#auth_uri = http://192.168.1.102:5000
#project_domain_id = default
#project_name = service
#user_domain_id = default
#password = nomoresecrete
#username = karbor
#auth_url = http://192.168.1.102:35357
#auth_plugin = password
[DEFAULT]
#api_paste_config = /etc/karbor/api-paste.ini
#logging_context_format_string = %(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [%(request_id)s %(user_id)s %(project_id)s%(color)s] %(instance)s%(color)s%(message)s
#logging_debug_format_suffix = from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d
#logging_default_format_string = %(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s
#logging_exception_prefix = %(color)s%(asctime)s.%(msecs)03d TRACE %(name)s %(instance)s
#verbose = True
#debug = True
#auth_strategy = noauth
#log_dir = /var/log/
#rpc_backend = rabbit
#[database]
#connection = mysql+pymysql://root:stackdb@127.0.0.1/karbor?charset=utf8
#[oslo_messaging_rabbit]
#rabbit_userid = stackrabbit
#rabbit_password = stackqueue
#rabbit_hosts = 10.229.50.225

+ 9
- 0
etc/oslo-config-generator/karbor.conf View File

@ -0,0 +1,9 @@
[DEFAULT]
output_file = etc/karbor.conf.sample
namespace = karbor.common.opts
namespace = keystonemiddleware.auth_token
namespace = oslo.messaging
namespace = oslo.concurrency
namespace = oslo.db
namespace = oslo.log
namespace = oslo.policy

+ 101
- 0
karbor/common/opts.py View File

@ -0,0 +1,101 @@
# 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 karbor.api.common
import karbor.api.v1.protectables
import karbor.api.v1.providers
import karbor.common.config
import karbor.db.api
import karbor.exception
import karbor.service
import karbor.services.operationengine.engine.executors.green_thread_executor as green_thread_executor # noqa
import karbor.services.operationengine.engine.executors.thread_pool_executor as thread_pool_executor # noqa
import karbor.services.operationengine.engine.triggers.timetrigger.time_trigger as time_trigger # noqa
import karbor.services.operationengine.karbor_client
import karbor.services.operationengine.manager
import karbor.services.operationengine.operations.base as base
import karbor.services.protection.clients.cinder
import karbor.services.protection.clients.glance
import karbor.services.protection.clients.heat
import karbor.services.protection.clients.manila
import karbor.services.protection.clients.neutron
import karbor.services.protection.clients.nova
import karbor.services.protection.flows.restore
import karbor.services.protection.flows.worker
import karbor.services.protection.manager
import karbor.services.protection.protection_plugins.image.image_protection_plugin as image_protection_plugin # noqa
import karbor.services.protection.protection_plugins.share.share_snapshot_plugin as share_snapshot_plugin # noqa
import karbor.services.protection.protection_plugins.volume.cinder_protection_plugin as cinder_protection_plugin # noqa
import karbor.services.protection.protection_plugins.volume.volume_snapshot_plugin as volume_snapshot_plugin # noqa
import karbor.wsgi.eventlet_server
__all__ = ['list_opts']
_opts = [
('clients_keystone', list(itertools.chain(
karbor.common.config.keystone_client_opts))),
('operationengine', list(itertools.chain(
green_thread_executor.green_thread_executor_opts,
karbor.services.operationengine.manager.trigger_manager_opts))),
('karbor_client', list(itertools.chain(
karbor.common.config.service_client_opts))),
('cinder_client', list(itertools.chain(
karbor.common.config.service_client_opts,
karbor.services.protection.clients.cinder.cinder_client_opts))),
('glance_client', list(itertools.chain(
karbor.common.config.service_client_opts,
karbor.services.protection.clients.glance.glance_client_opts))),
('heat_client', list(itertools.chain(
karbor.common.config.service_client_opts,
karbor.services.protection.clients.heat.heat_client_opts))),
('manila_client', list(itertools.chain(
karbor.common.config.service_client_opts,
karbor.services.protection.clients.manila.manila_client_opts))),
('neutron_client', list(itertools.chain(
karbor.common.config.service_client_opts,
karbor.services.protection.clients.neutron.neutron_client_opts))),
('nova_client', list(itertools.chain(
karbor.common.config.service_client_opts,
karbor.services.protection.clients.nova.nova_client_opts))),
('image_backup_plugin', list(itertools.chain(
image_protection_plugin.image_backup_opts))),
('cinder_backup_protection_plugin', list(itertools.chain(
cinder_protection_plugin.cinder_backup_opts))),
('volume_snapshot_plugin', list(itertools.chain(
volume_snapshot_plugin.volume_snapshot_opts))),
('manila_snapshot_plugin', list(itertools.chain(
share_snapshot_plugin.manila_snapshot_opts))),
(None, list(itertools.chain(
karbor.common.config.core_opts,
karbor.common.config.debug_opts,
karbor.common.config.global_opts,
karbor.api.common.api_common_opts,
karbor.api.v1.protectables.query_instance_filters_opts,
karbor.api.v1.providers.query_provider_filters_opts,
karbor.api.v1.providers.query_checkpoint_filters_opts,
karbor.db.api.db_opts,
thread_pool_executor.executor_opts,
time_trigger.time_trigger_opts,
base.record_operation_log_executor_opts,
karbor.services.protection.flows.restore.sync_status_opts,
karbor.services.protection.flows.worker.workflow_opts,
karbor.services.protection.manager.protection_manager_opts,
karbor.wsgi.eventlet_server.socket_opts,
karbor.exception.exc_log_opts,
karbor.service.service_opts)))]
def list_opts():
return [(g, copy.deepcopy(o)) for g, o in _opts]

+ 4
- 0
releasenotes/notes/use-oslo-config-generator-f2a9be9e71d90b1f.yaml View File

@ -0,0 +1,4 @@
---
other:
- oslo-config-generator is now used to generate a
karbor.conf.sample file

+ 2
- 0
setup.cfg View File

@ -35,6 +35,8 @@ console_scripts =
karbor-manage = karbor.cmd.manage:main
karbor-operationengine = karbor.cmd.operationengine:main
karbor-protection = karbor.cmd.protection:main
oslo.config.opts =
karbor.common.opts = karbor.common.opts:list_opts
wsgi_scripts =
karbor-wsgi = karbor.wsgi.wsgi:initialize_application
karbor.database.migration_backend =


+ 6
- 1
tox.ini View File

@ -19,7 +19,9 @@ commands = python setup.py test --slowest --testr-args='{posargs}'
basepython = python2.7
setenv = OS_TEST_PATH=./karbor/tests/fullstack
OS_TEST_TIMEOUT=3600
commands = python setup.py test --slowest --testr-args="--concurrency=2 {posargs}"
commands =
oslo-config-generator --config-file etc/oslo-config-generator/karbor.conf --output-file etc/karbor.conf
python setup.py test --slowest --testr-args="--concurrency=2 {posargs}"
[testenv:pep8]
commands = flake8
@ -53,6 +55,9 @@ commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenote
[testenv:install-guide]
commands = sphinx-build -a -E -W -d install-guide/build/doctrees -b html install-guide/source install-guide/build/html
[testenv:genconfig]
commands = oslo-config-generator --config-file etc/oslo-config-generator/karbor.conf
[flake8]
show-source = True
ignore =


Loading…
Cancel
Save