summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristi Nikolla <knikolla@bu.edu>2017-09-01 13:42:09 -0400
committerKristi Nikolla <knikolla@bu.edu>2017-09-05 11:46:08 -0400
commit1cb775fcf452fb8890a279be2ed2bd2f222a3dce (patch)
treec4dc9d38925724cbe1ea4898cee009d71200d8d1
parenta686c739d6af70f6fbfff9d72f51434ff342f2f8 (diff)
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
Notes
Notes (review): Code-Review+2: Kristi Nikolla <knikolla@bu.edu> Workflow+1: Kristi Nikolla <knikolla@bu.edu> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 05 Sep 2017 18:29:40 +0000 Reviewed-on: https://review.openstack.org/500140 Project: openstack/mixmatch Branch: refs/heads/master
-rw-r--r--devstack/mixmatch.sh2
-rw-r--r--mixmatch/cli.py50
-rw-r--r--mixmatch/proxy.py1
-rw-r--r--setup.cfg2
4 files changed, 54 insertions, 1 deletions
diff --git a/devstack/mixmatch.sh b/devstack/mixmatch.sh
index 219e87d..d859645 100644
--- a/devstack/mixmatch.sh
+++ b/devstack/mixmatch.sh
@@ -67,6 +67,8 @@ function configure_mixmatch {
67 iniset $GLANCE_CONF oslo_messaging_notifications driver messaging 67 iniset $GLANCE_CONF oslo_messaging_notifications driver messaging
68 iniset $CINDER_CONF oslo_messaging_notifications topics notifications 68 iniset $CINDER_CONF oslo_messaging_notifications topics notifications
69 69
70 mixmatch-manage db_sync
71
70 sudo cp $MIXMATCH_DIR/httpd/mixmatch-uwsgi.conf $(apache_site_config_for mixmatch) 72 sudo cp $MIXMATCH_DIR/httpd/mixmatch-uwsgi.conf $(apache_site_config_for mixmatch)
71 enable_apache_site mixmatch 73 enable_apache_site mixmatch
72 restart_apache_server 74 restart_apache_server
diff --git a/mixmatch/cli.py b/mixmatch/cli.py
new file mode 100644
index 0000000..931abf3
--- /dev/null
+++ b/mixmatch/cli.py
@@ -0,0 +1,50 @@
1# Copyright 2017 Massachusetts Open Cloud
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from oslo_config import cfg
16
17from mixmatch import config
18from mixmatch import model
19
20CONF = config.CONF
21
22
23def do_db_sync():
24 model.create_tables()
25
26
27def register_parsers(subparsers):
28
29 db_sync = subparsers.add_parser(
30 'db_sync',
31 description='Prepares the database. Needs to be executed before'
32 ' starting the service.',
33 help='Prepares the database.'
34 )
35 db_sync.set_defaults(func=do_db_sync)
36
37
38def main():
39 command = cfg.SubCommandOpt('command',
40 title='Command',
41 help='Mixmatch management commands.',
42 handler=register_parsers)
43 CONF.register_cli_opt(command)
44 config.load_from_file()
45
46 CONF.command.func()
47
48
49if __name__ == '__main__':
50 main()
diff --git a/mixmatch/proxy.py b/mixmatch/proxy.py
index fd25522..446ddd1 100644
--- a/mixmatch/proxy.py
+++ b/mixmatch/proxy.py
@@ -374,7 +374,6 @@ def proxy(path):
374 374
375def main(): 375def main():
376 config.configure() 376 config.configure()
377 model.create_tables()
378 extend.load_extensions() 377 extend.load_extensions()
379 378
380 379
diff --git a/setup.cfg b/setup.cfg
index eab1847..4b52ce1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -36,6 +36,8 @@ data_files =
36[entry_points] 36[entry_points]
37wsgi_scripts = 37wsgi_scripts =
38 mixmatch = mixmatch.wsgi:get_application 38 mixmatch = mixmatch.wsgi:get_application
39console_scripts =
40 mixmatch-manage = mixmatch.cli:main
39 41
40oslo.config.opts = 42oslo.config.opts =
41 mixmatch = mixmatch.config:list_opts 43 mixmatch = mixmatch.config:list_opts