Add CLI for kingbird management
Version information as well as database migration tools are now available via manage.py. Change-Id: I201b82502840b55f7b0534fc9465a4bea63dd8b4
This commit is contained in:
parent
9763df7187
commit
b0ae3071be
@ -1,17 +0,0 @@
|
||||
===============================
|
||||
cmd
|
||||
===============================
|
||||
|
||||
Scripts to start the API, JobDaemon and JobWorker service
|
||||
|
||||
api.py:
|
||||
start API service
|
||||
python api.py --config-file=../etc/api.conf
|
||||
|
||||
jobdaemon.py:
|
||||
start JobDaemon service
|
||||
python jobdaemon.py --config-file=../etc/jobdaemon.conf
|
||||
|
||||
jobworker.py:
|
||||
start JobWorker service
|
||||
python jobworker.py --config-file=../etc/jobworker.conf
|
@ -134,7 +134,7 @@ auth_strategy = noauth
|
||||
# connection = mysql://root:pass@127.0.0.1:3306/neutron
|
||||
# Replace 127.0.0.1 above with the IP address of the database used by the
|
||||
# main neutron server. (Leave it as is if the database runs on this host.)
|
||||
# connection = sqlite://
|
||||
connection = sqlite:///kingbird.db
|
||||
# NOTE: In deployment the [database] section and its connection attribute may
|
||||
# be set in the corresponding core plugin '.ini' file. However, it is suggested
|
||||
# to put the [database] section and its connection attribute in this
|
||||
|
@ -42,7 +42,7 @@ rpc_backend=rabbit
|
||||
# connection = mysql+pymysql://root:pass@127.0.0.1:3306/neutron
|
||||
# Replace 127.0.0.1 above with the IP address of the database used by the
|
||||
# main neutron server. (Leave it as is if the database runs on this host.)
|
||||
# connection = sqlite://
|
||||
connection = sqlite:///kingbird.db
|
||||
# NOTE: In deployment the [database] section and its connection attribute may
|
||||
# be set in the corresponding core plugin '.ini' file. However, it is suggested
|
||||
# to put the [database] section and its connection attribute in this
|
||||
|
18
kingbird/cmd/README.rst
Executable file
18
kingbird/cmd/README.rst
Executable file
@ -0,0 +1,18 @@
|
||||
===============================
|
||||
cmd
|
||||
===============================
|
||||
|
||||
Scripts to start the API, JobDaemon and JobWorker service
|
||||
|
||||
api.py:
|
||||
start API service
|
||||
python api.py --config-file=../etc/api.conf
|
||||
|
||||
engine.py:
|
||||
start Engine service
|
||||
python engine.py --config-file=../etc/engine.conf
|
||||
|
||||
manage.py:
|
||||
CLI interface for kingbird management
|
||||
kingbird-manage --config-file ../../etc/api.conf db_sync
|
||||
kingbird-manage --config-file ../../etc/api.conf db_version
|
0
kingbird/cmd/__init__.py
Normal file
0
kingbird/cmd/__init__.py
Normal file
75
kingbird/cmd/manage.py
Normal file
75
kingbird/cmd/manage.py
Normal file
@ -0,0 +1,75 @@
|
||||
# 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.
|
||||
|
||||
"""
|
||||
CLI interface for kingbird management.
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from kingbird.common import config
|
||||
from kingbird.db import api
|
||||
from kingbird import version
|
||||
|
||||
config.register_options()
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
def do_db_version():
|
||||
'''Print database's current migration level.'''
|
||||
print(api.db_version(api.get_engine()))
|
||||
|
||||
|
||||
def do_db_sync():
|
||||
'''Place a database under migration control and upgrade.
|
||||
|
||||
DB is created first if necessary.
|
||||
'''
|
||||
api.db_sync(api.get_engine(), CONF.command.version)
|
||||
|
||||
|
||||
def add_command_parsers(subparsers):
|
||||
parser = subparsers.add_parser('db_version')
|
||||
parser.set_defaults(func=do_db_version)
|
||||
|
||||
parser = subparsers.add_parser('db_sync')
|
||||
parser.set_defaults(func=do_db_sync)
|
||||
parser.add_argument('version', nargs='?')
|
||||
parser.add_argument('current_version', nargs='?')
|
||||
|
||||
command_opt = cfg.SubCommandOpt('command',
|
||||
title='Commands',
|
||||
help='Show available commands.',
|
||||
handler=add_command_parsers)
|
||||
|
||||
|
||||
def main():
|
||||
logging.register_options(CONF)
|
||||
logging.setup(CONF, 'kingbird-manage')
|
||||
CONF.register_cli_opt(command_opt)
|
||||
|
||||
try:
|
||||
default_config_files = cfg.find_config_files('kingbird',
|
||||
'kingbird-engine')
|
||||
CONF(sys.argv[1:], project='kingbird', prog='kingbird-manage',
|
||||
version=version.version_info.version_string(),
|
||||
default_config_files=default_config_files)
|
||||
except RuntimeError as e:
|
||||
sys.exit("ERROR: %s" % e)
|
||||
|
||||
try:
|
||||
CONF.command.func()
|
||||
except Exception as e:
|
||||
sys.exit("ERROR: %s" % e)
|
16
kingbird/version.py
Normal file
16
kingbird/version.py
Normal file
@ -0,0 +1,16 @@
|
||||
# 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('kingbird')
|
Loading…
x
Reference in New Issue
Block a user