File: upgrade.sh

package info (click to toggle)
zaqar 21.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,964 kB
  • sloc: python: 28,819; sh: 513; java: 135; makefile: 63; javascript: 50
file content (116 lines) | stat: -rwxr-xr-x 3,657 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash

# ``upgrade-zaqar``

echo "*********************************************************************"
echo "Begin $0"
echo "*********************************************************************"

# Clean up any resources that may be in use
cleanup() {
    set +o errexit

    echo "*********************************************************************"
    echo "ERROR: Abort $0"
    echo "*********************************************************************"

    # Kill ourselves to signal any calling process
    trap 2; kill -2 $$
}

trap cleanup SIGHUP SIGINT SIGTERM

# Keep track of the grenade directory
RUN_DIR=$(cd $(dirname "$0") && pwd)

# Source params
source $GRENADE_DIR/grenaderc

source $TOP_DIR/openrc admin admin

# Import common functions
source $GRENADE_DIR/functions

# This script exits on an error so that errors don't compound and you see
# only the first error that occurred.
set -o errexit

if grep -q '_store *= *mongodb' /etc/zaqar/zaqar.conf; then
    # mongo-tools is the name of the package which includes mongodump on
    # basically all distributions (Ubuntu, Debian, Fedora, CentOS and
    # openSUSE).
    install_package mongo-tools
fi

if grep -q 'management_store *= *mongodb' /etc/zaqar/zaqar.conf; then
    mongodump --db zaqar_mgmt --out $SAVE_DIR/zaqar-mongodb-mgmt-dump.$BASE_RELEASE
fi

if grep -q 'message_store *= *mongodb' /etc/zaqar/zaqar.conf; then
    mongodump --db zaqar --out $SAVE_DIR/zaqar-mongodb-message-dump.$BASE_RELEASE
fi

if grep -q 'message_store *= *redis' /etc/zaqar/zaqar.conf; then
    redis-cli save
    sudo cp /var/lib/redis/dump.rdb $SAVE_DIR/zaqar-redis-message-dump-$BASE_RELEASE.rdb
fi

# Upgrade Zaqar
# =============

# Duplicate some setup bits from target DevStack
source $TARGET_DEVSTACK_DIR/stackrc
source $TARGET_DEVSTACK_DIR/lib/tls

# Keep track of the DevStack directory
ZAQAR_DEVSTACK_DIR=$(dirname "$0")/..
source $ZAQAR_DEVSTACK_DIR/settings
source $ZAQAR_DEVSTACK_DIR/plugin.sh

# Print the commands being run so that we can see the command that triggers
# an error.  It is also useful for following allowing as the install occurs.
set -o xtrace

function wait_for_keystone {
    local www_authenticate_uri=http://${ZAQAR_SERVICE_HOST}/identity
    if ! wait_for_service $SERVICE_TIMEOUT ${www_authenticate_uri}/v$IDENTITY_API_VERSION/; then
        die $LINENO "keystone did not start"
    fi
}

# Save current config files for posterity
[[ -d $SAVE_DIR/etc.zaqar ]] || cp -pr $ZAQAR_CONF_DIR $SAVE_DIR/etc.zaqar

stack_install_service zaqar

if grep -q 'management_store *= *sqlalchemy' /etc/zaqar/zaqar.conf; then
    $ZAQAR_BIN_DIR/zaqar-sql-db-manage --config-file $ZAQAR_CONF upgrade head || die $LINENO "DB sync error"
fi

# calls upgrade-zaqar for specific release
upgrade_project zaqar $RUN_DIR $BASE_DEVSTACK_BRANCH $TARGET_DEVSTACK_BRANCH

wait_for_keystone
start_zaqar


# Don't succeed unless the services come up
ensure_services_started zaqar-server

if grep -q 'management_store *= *mongodb' /etc/zaqar/zaqar.conf; then
    mongodump --db zaqar_mgmt --out $SAVE_DIR/zaqar-mongodb-mgmt-dump.$TARGET_RELEASE
fi

if grep -q 'message_store *= *mongodb' /etc/zaqar/zaqar.conf; then
    mongodump --db zaqar --out $SAVE_DIR/zaqar-mongodb-message-dump.$TARGET_RELEASE
fi

if grep -q 'message_store *= *redis' /etc/zaqar/zaqar.conf; then
    redis-cli save
    sudo cp /var/lib/redis/dump.rdb $SAVE_DIR/zaqar-redis-message-dump-$TARGET_RELEASE.rdb
fi

set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End $0"
echo "*********************************************************************"