Browse Source

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
Kristi Nikolla 1 year ago
parent
commit
1cb775fcf4
4 changed files with 54 additions and 1 deletions
  1. 2
    0
      devstack/mixmatch.sh
  2. 50
    0
      mixmatch/cli.py
  3. 0
    1
      mixmatch/proxy.py
  4. 2
    0
      setup.cfg

+ 2
- 0
devstack/mixmatch.sh View File

@@ -67,6 +67,8 @@ function configure_mixmatch {
67 67
     iniset $GLANCE_CONF oslo_messaging_notifications driver messaging
68 68
     iniset $CINDER_CONF oslo_messaging_notifications topics notifications
69 69
 
70
+    mixmatch-manage db_sync
71
+
70 72
     sudo cp $MIXMATCH_DIR/httpd/mixmatch-uwsgi.conf $(apache_site_config_for mixmatch)
71 73
     enable_apache_site mixmatch
72 74
     restart_apache_server

+ 50
- 0
mixmatch/cli.py View File

@@ -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
+
15
+from oslo_config import cfg
16
+
17
+from mixmatch import config
18
+from mixmatch import model
19
+
20
+CONF = config.CONF
21
+
22
+
23
+def do_db_sync():
24
+    model.create_tables()
25
+
26
+
27
+def 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
+
38
+def 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
+
49
+if __name__ == '__main__':
50
+    main()

+ 0
- 1
mixmatch/proxy.py View File

@@ -374,7 +374,6 @@ def proxy(path):
374 374
 
375 375
 def main():
376 376
     config.configure()
377
-    model.create_tables()
378 377
     extend.load_extensions()
379 378
 
380 379
 

+ 2
- 0
setup.cfg View File

@@ -36,6 +36,8 @@ data_files =
36 36
 [entry_points]
37 37
 wsgi_scripts =
38 38
     mixmatch = mixmatch.wsgi:get_application
39
+console_scripts =
40
+    mixmatch-manage = mixmatch.cli:main
39 41
 
40 42
 oslo.config.opts =
41 43
     mixmatch = mixmatch.config:list_opts

Loading…
Cancel
Save