Add mixmatch-manage cli command with db_sync
This adds a cli for management commands that is run through `mixmatch-manage`. Also added `db_sync` which is creates the tables in the database based on the model. No upgrade functionality exists yet. Change-Id: I18187967bb62865529712c83ef60482c3d1ed8ca
This commit is contained in:
parent
a686c739d6
commit
1cb775fcf4
@ -67,6 +67,8 @@ function configure_mixmatch {
|
|||||||
iniset $GLANCE_CONF oslo_messaging_notifications driver messaging
|
iniset $GLANCE_CONF oslo_messaging_notifications driver messaging
|
||||||
iniset $CINDER_CONF oslo_messaging_notifications topics notifications
|
iniset $CINDER_CONF oslo_messaging_notifications topics notifications
|
||||||
|
|
||||||
|
mixmatch-manage db_sync
|
||||||
|
|
||||||
sudo cp $MIXMATCH_DIR/httpd/mixmatch-uwsgi.conf $(apache_site_config_for mixmatch)
|
sudo cp $MIXMATCH_DIR/httpd/mixmatch-uwsgi.conf $(apache_site_config_for mixmatch)
|
||||||
enable_apache_site mixmatch
|
enable_apache_site mixmatch
|
||||||
restart_apache_server
|
restart_apache_server
|
||||||
|
50
mixmatch/cli.py
Normal file
50
mixmatch/cli.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Copyright 2017 Massachusetts Open Cloud
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
from mixmatch import config
|
||||||
|
from mixmatch import model
|
||||||
|
|
||||||
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
|
def do_db_sync():
|
||||||
|
model.create_tables()
|
||||||
|
|
||||||
|
|
||||||
|
def register_parsers(subparsers):
|
||||||
|
|
||||||
|
db_sync = subparsers.add_parser(
|
||||||
|
'db_sync',
|
||||||
|
description='Prepares the database. Needs to be executed before'
|
||||||
|
' starting the service.',
|
||||||
|
help='Prepares the database.'
|
||||||
|
)
|
||||||
|
db_sync.set_defaults(func=do_db_sync)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
command = cfg.SubCommandOpt('command',
|
||||||
|
title='Command',
|
||||||
|
help='Mixmatch management commands.',
|
||||||
|
handler=register_parsers)
|
||||||
|
CONF.register_cli_opt(command)
|
||||||
|
config.load_from_file()
|
||||||
|
|
||||||
|
CONF.command.func()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -374,7 +374,6 @@ def proxy(path):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
config.configure()
|
config.configure()
|
||||||
model.create_tables()
|
|
||||||
extend.load_extensions()
|
extend.load_extensions()
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ data_files =
|
|||||||
[entry_points]
|
[entry_points]
|
||||||
wsgi_scripts =
|
wsgi_scripts =
|
||||||
mixmatch = mixmatch.wsgi:get_application
|
mixmatch = mixmatch.wsgi:get_application
|
||||||
|
console_scripts =
|
||||||
|
mixmatch-manage = mixmatch.cli:main
|
||||||
|
|
||||||
oslo.config.opts =
|
oslo.config.opts =
|
||||||
mixmatch = mixmatch.config:list_opts
|
mixmatch = mixmatch.config:list_opts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user