-
Notifications
You must be signed in to change notification settings - Fork 19
/
prep-target
executable file
·132 lines (98 loc) · 3.64 KB
/
prep-target
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
set -o error
# ``prep-target`` handles the preparations for installing and configuring
# the "target" configuration of DevStack.
# Keep track of the devstack directory
GRENADE_DIR=$(cd $(dirname "$0") && pwd)
# Source params
source $GRENADE_DIR/inc/bootstrap
source $GRENADE_DIR/grenaderc
# Import common functions
source $GRENADE_DIR/functions
# Determine what system we are running on. This provides ``os_VENDOR``,
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
# and ``DISTRO``
GetDistro
# For debugging
set -o xtrace
# System Preparation
# ==================
# Load up a copy of the downloaded images if not present
if [[ -d $BASE_RELEASE_DIR/images ]]; then
rsync -a $BASE_RELEASE_DIR/images $TARGET_DEVSTACK_DIR/files
fi
# Get target config (stackrc grabs devstack "functions" too)
source $TARGET_DEVSTACK_DIR/stackrc
# Build a wheel cache
if [[ -n ${WHEELHOUSE:-} && ! -d ${WHEELHOUSE:-} ]]; then
WHEELHOUSE=$WHEELHOUSE source $TARGET_DEVSTACK_DIR/tools/build_wheels.sh
fi
# Find additional Python packages for venvs
install_database_python
# Set up Screen
# =============
# Set a reasonable screen statusbar
SCREEN_HARDSTATUS=${SCREEN_HARDSTATUS:-'%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'}
screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"
# Set up needed directories
# =========================
#
# This ensures that we have a clean service status directory so that
# we know for sure if services are coming up / down when we expect
# them.
init_service_check
# Set up Logging
# ==============
# Set up logging for ``stack.sh``
# Set ``LOGFILE`` to turn on logging
# Append '.xxxxxxxx' to the given name to maintain history
# where 'xxxxxxxx' is a representation of the date the file was created
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then
LOGDAYS=${LOGDAYS:-7}
CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT")
fi
if [[ -n "$LOGFILE" ]]; then
# First clean up old log files. Use the user-specified ``LOGFILE``
# as the template to search for, appending '.*' to match the date
# we added on earlier runs.
LOGDIR=$(dirname "$LOGFILE")
LOGNAME=$(basename "$LOGFILE")
mkdir -p $LOGDIR
find $LOGDIR -maxdepth 1 -name $LOGNAME.\* -mtime +$LOGDAYS -exec rm {} \;
LOGFILE=$LOGFILE.${CURRENT_LOG_TIME}
SUMFILE=$LOGFILE.${CURRENT_LOG_TIME}.summary
fi
if [[ -n "$SCREEN_LOGDIR" ]]; then
mkdir -p $SCREEN_LOGDIR
fi
# Retain credentials
# ==================
# Preserve accrc files for future usage
cp -a $BASE_DEVSTACK_DIR/accrc $TARGET_DEVSTACK_DIR/accrc
# Install package requirements from new devstack
# ==============================================
echo_summary "Installing package prerequisites"
FILES=$TARGET_DEVSTACK_DIR/files
source $TARGET_DEVSTACK_DIR/tools/install_prereqs.sh
# Set up requirements
# ===================
# Pull down the new global requirements repository
#
# this also pulls in new pbr which is needed because older
# releases of various libraries trigger downgrades which then
# would break, and pbr as a setup_requires can't be sanely
# minimum-versioned.
source $TARGET_DEVSTACK_DIR/lib/infra
git_clone $REQUIREMENTS_REPO $REQUIREMENTS_DIR $REQUIREMENTS_BRANCH
install_infra
# force any oslo upgrades that might be required
source $TARGET_DEVSTACK_DIR/lib/libraries
install_oslo
# Start helper services
# =====================
# Start dstat if it's in the ENABLED_SERVICES list. We really want
# this running before any services start to see what's going on when
# they start up, especially if there are failures.
source $TARGET_DEVSTACK_DIR/lib/dstat
start_dstat