~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/schema/full-update.py

  • Committer: Stuart Bishop
  • Date: 2011-04-26 13:56:48 UTC
  • mto: (7675.1045.296 db-devel)
  • mto: This revision was merged to the branch mainline in revision 12957.
  • Revision ID: stuart.bishop@canonical.com-20110426135648-r0v0ze3ivxrmnoms
Full database update script for fast deployments

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python2.6 -S
 
2
# Copyright 2011 Canonical Ltd.  This software is licensed under the
 
3
# GNU Affero General Public License version 3 (see the file LICENSE).
 
4
 
 
5
"""Full update process."""
 
6
 
 
7
import _pythonpath
 
8
 
 
9
import os.path
 
10
from optparse import OptionParser
 
11
import subprocess
 
12
import sys
 
13
 
 
14
from canonical.launchpad.scripts import (
 
15
    db_options,
 
16
    logger_options,
 
17
    )
 
18
 
 
19
 
 
20
def run_script(script, *extra_args):
 
21
    script_path = os.path.join(os.path.dirname(__file__), script)
 
22
    return subprocess.call([script_path] + sys.argv[1:] + list(extra_args))
 
23
 
 
24
 
 
25
def main():
 
26
    parser = OptionParser()
 
27
 
 
28
    # Add all the command command line arguments.
 
29
    db_options(parser)
 
30
    logger_options(parser)
 
31
    (options, args) = parser.parse_args()
 
32
    if args:
 
33
        parser.error("Too many arguments")
 
34
 
 
35
    preflight_rc = run_script('preflight.py')
 
36
    if preflight_rc != 0:
 
37
        return preflight_rc
 
38
 
 
39
    upgrade_rc = run_script('upgrade.py')
 
40
    if upgrade_rc != 0:
 
41
        return upgrade_rc
 
42
 
 
43
    fti_rc = run_script('fti.py')
 
44
    if fti_rc != 0:
 
45
        return fti_rc
 
46
 
 
47
    security_rc = run_script('security.py', '--cluster')
 
48
    if security_rc != 0:
 
49
        return security_rc
 
50
 
 
51
    preflight_rc = run_script('preflight.py')
 
52
    return preflight_rc
 
53
 
 
54
 
 
55
if __name__ == '__main__':
 
56
    sys.exit(main())