blob: edc4bf9aefeea7fbb6095771d65dfe8f017fb894 [file] [log] [blame]
Dean Troyer7f9aa712012-01-31 12:11:56 -06001# functions - Common functions used by DevStack components
Dean Troyer13dc5cc2012-03-27 14:50:45 -05002#
Dean Troyer4a43b7b2012-08-28 17:43:40 -05003# The following variables are assumed to be defined by certain functions:
Dean Troyer4a43b7b2012-08-28 17:43:40 -05004# ``ENABLED_SERVICES``
5# ``EROR_ON_CLONE``
6# ``FILES``
7# ``GLANCE_HOSTPORT``
8# ``OFFLINE``
9# ``PIP_DOWNLOAD_CACHE``
Maru Newby3a87edd2012-10-25 23:01:06 +000010# ``PIP_USE_MIRRORS``
Dean Troyer4a43b7b2012-08-28 17:43:40 -050011# ``RECLONE``
12# ``TRACK_DEPENDS``
13# ``http_proxy``, ``https_proxy``, ``no_proxy``
Dean Troyer13dc5cc2012-03-27 14:50:45 -050014
Dean Troyer7f9aa712012-01-31 12:11:56 -060015
Dean Troyer27e32692012-03-16 16:16:56 -050016# Save trace setting
17XTRACE=$(set +o | grep xtrace)
18set +o xtrace
19
Dean Troyer7f9aa712012-01-31 12:11:56 -060020
Dean Troyer4a43b7b2012-08-28 17:43:40 -050021# Exit 0 if address is in network or 1 if address is not in
22# network or netaddr library is not installed.
23# address_in_net ip-address ip-range
Vishvananda Ishayac9ad14b2012-07-03 20:29:01 +000024function address_in_net() {
25 python -c "
26import netaddr
27import sys
28sys.exit(netaddr.IPAddress('$1') not in netaddr.IPNetwork('$2'))
29"
30}
31
32
Dean Troyer4a43b7b2012-08-28 17:43:40 -050033# Wrapper for ``apt-get`` to set cache and proxy environment variables
34# Uses globals ``OFFLINE``, ``*_proxy`
Dean Troyer13dc5cc2012-03-27 14:50:45 -050035# apt_get operation package [package ...]
Dean Troyer7f9aa712012-01-31 12:11:56 -060036function apt_get() {
Dean Troyerd0b21e22012-03-07 14:52:25 -060037 [[ "$OFFLINE" = "True" || -z "$@" ]] && return
Dean Troyer7f9aa712012-01-31 12:11:56 -060038 local sudo="sudo"
39 [[ "$(id -u)" = "0" ]] && sudo="env"
40 $sudo DEBIAN_FRONTEND=noninteractive \
41 http_proxy=$http_proxy https_proxy=$https_proxy \
Osamu Habuka7abe4f22012-07-25 12:39:32 +090042 no_proxy=$no_proxy \
Dean Troyer7f9aa712012-01-31 12:11:56 -060043 apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
44}
45
46
47# Gracefully cp only if source file/dir exists
48# cp_it source destination
49function cp_it {
50 if [ -e $1 ] || [ -d $1 ]; then
51 cp -pRL $1 $2
52 fi
53}
54
55
Dean Troyerac93efb2013-03-13 14:30:54 -050056# Prints line number and "message" then exits
57# die $LINENO "message"
Dean Troyer27e32692012-03-16 16:16:56 -050058function die() {
Dean Troyer489bd2a2012-03-02 10:44:29 -060059 local exitcode=$?
Nachi Ueno07115eb2013-02-26 12:38:18 -080060 if [ $exitcode == 0 ]; then
61 exitcode=1
62 fi
Dean Troyer27e32692012-03-16 16:16:56 -050063 set +o xtrace
Nachi Ueno07115eb2013-02-26 12:38:18 -080064 local msg="[ERROR] $0:$1 $2"
65 echo $msg 1>&2;
66 if [[ -n ${SCREEN_LOGDIR} ]]; then
67 echo $msg >> "${SCREEN_LOGDIR}/error.log"
68 fi
Dean Troyer27e32692012-03-16 16:16:56 -050069 exit $exitcode
Dean Troyer489bd2a2012-03-02 10:44:29 -060070}
71
72
73# Checks an environment variable is not set or has length 0 OR if the
74# exit code is non-zero and prints "message" and exits
75# NOTE: env-var is the variable name without a '$'
Dean Troyerac93efb2013-03-13 14:30:54 -050076# die_if_not_set $LINENO env-var "message"
Dean Troyer489bd2a2012-03-02 10:44:29 -060077function die_if_not_set() {
Dean Troyer27e32692012-03-16 16:16:56 -050078 (
79 local exitcode=$?
80 set +o xtrace
Nachi Ueno07115eb2013-02-26 12:38:18 -080081 local evar=$2; shift
Dean Troyer27e32692012-03-16 16:16:56 -050082 if ! is_set $evar || [ $exitcode != 0 ]; then
Nachi Ueno07115eb2013-02-26 12:38:18 -080083 die $@
Dean Troyer27e32692012-03-16 16:16:56 -050084 fi
85 )
Dean Troyer489bd2a2012-03-02 10:44:29 -060086}
87
88
Dean Troyer48352ee2012-12-12 12:50:38 -060089# HTTP and HTTPS proxy servers are supported via the usual environment variables [1]
90# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in
91# ``localrc`` or on the command line if necessary::
92#
93# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html
94#
95# http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh
96
97function export_proxy_variables() {
98 if [[ -n "$http_proxy" ]]; then
99 export http_proxy=$http_proxy
100 fi
101 if [[ -n "$https_proxy" ]]; then
102 export https_proxy=$https_proxy
103 fi
104 if [[ -n "$no_proxy" ]]; then
105 export no_proxy=$no_proxy
106 fi
107}
108
109
Dean Troyer489bd2a2012-03-02 10:44:29 -0600110# Grab a numbered field from python prettytable output
111# Fields are numbered starting with 1
112# Reverse syntax is supported: -1 is the last field, -2 is second to last, etc.
113# get_field field-number
114function get_field() {
115 while read data; do
116 if [ "$1" -lt 0 ]; then
117 field="(\$(NF$1))"
118 else
119 field="\$$(($1 + 1))"
120 fi
121 echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}"
122 done
123}
124
125
Dean Troyerc892bde2013-03-13 14:06:13 -0500126# Get the default value for HOST_IP
127# get_default_host_ip fixed_range floating_range host_ip_iface host_ip
128function get_default_host_ip() {
129 local fixed_range=$1
130 local floating_range=$2
131 local host_ip_iface=$3
132 local host_ip=$4
133
134 # Find the interface used for the default route
135 host_ip_iface=${host_ip_iface:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }' | head -1)}
136 # Search for an IP unless an explicit is set by ``HOST_IP`` environment variable
137 if [ -z "$host_ip" -o "$host_ip" == "dhcp" ]; then
138 host_ip=""
139 host_ips=`LC_ALL=C ip -f inet addr show ${host_ip_iface} | awk '/inet/ {split($2,parts,"/"); print parts[1]}'`
140 for IP in $host_ips; do
141 # Attempt to filter out IP addresses that are part of the fixed and
142 # floating range. Note that this method only works if the ``netaddr``
143 # python library is installed. If it is not installed, an error
144 # will be printed and the first IP from the interface will be used.
145 # If that is not correct set ``HOST_IP`` in ``localrc`` to the correct
146 # address.
147 if ! (address_in_net $IP $fixed_range || address_in_net $IP $floating_range); then
148 host_ip=$IP
149 break;
150 fi
151 done
152 fi
153 echo $host_ip
154}
155
156
Isaku Yamahata8c438092013-02-12 22:30:56 +0900157function _get_package_dir() {
158 local pkg_dir
159 if is_ubuntu; then
160 pkg_dir=$FILES/apts
161 elif is_fedora; then
162 pkg_dir=$FILES/rpms
163 elif is_suse; then
164 pkg_dir=$FILES/rpms-suse
165 else
166 exit_distro_not_supported "list of packages"
167 fi
168 echo "$pkg_dir"
169}
170
Dean Troyer7e270512012-06-14 15:23:24 -0500171# get_packages() collects a list of package names of any type from the
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500172# prerequisite files in ``files/{apts|rpms}``. The list is intended
173# to be passed to a package installer such as apt or yum.
Dean Troyer7e270512012-06-14 15:23:24 -0500174#
Isaku Yamahata8c438092013-02-12 22:30:56 +0900175# Only packages required for the services in 1st argument will be
Dean Troyer7e270512012-06-14 15:23:24 -0500176# included. Two bits of metadata are recognized in the prerequisite files:
177# - ``# NOPRIME`` defers installation to be performed later in stack.sh
178# - ``# dist:DISTRO`` or ``dist:DISTRO1,DISTRO2`` limits the selection
179# of the package to the distros listed. The distro names are case insensitive.
Dean Troyer7e270512012-06-14 15:23:24 -0500180function get_packages() {
Isaku Yamahata8c438092013-02-12 22:30:56 +0900181 local services=$1
182 local package_dir=$(_get_package_dir)
Dean Troyer7e270512012-06-14 15:23:24 -0500183 local file_to_parse
184 local service
185
186 if [[ -z "$package_dir" ]]; then
187 echo "No package directory supplied"
188 return 1
189 fi
190 if [[ -z "$DISTRO" ]]; then
Vincent Untz855c5872012-10-04 13:36:46 +0200191 GetDistro
Dean Troyer7e270512012-06-14 15:23:24 -0500192 fi
Isaku Yamahata8c438092013-02-12 22:30:56 +0900193 for service in general ${services//,/ }; do
Dean Troyer7e270512012-06-14 15:23:24 -0500194 # Allow individual services to specify dependencies
195 if [[ -e ${package_dir}/${service} ]]; then
196 file_to_parse="${file_to_parse} $service"
197 fi
198 # NOTE(sdague) n-api needs glance for now because that's where
199 # glance client is
200 if [[ $service == n-api ]]; then
201 if [[ ! $file_to_parse =~ nova ]]; then
202 file_to_parse="${file_to_parse} nova"
203 fi
204 if [[ ! $file_to_parse =~ glance ]]; then
205 file_to_parse="${file_to_parse} glance"
206 fi
207 elif [[ $service == c-* ]]; then
208 if [[ ! $file_to_parse =~ cinder ]]; then
209 file_to_parse="${file_to_parse} cinder"
210 fi
John H. Tran93361642012-07-26 11:22:05 -0700211 elif [[ $service == ceilometer-* ]]; then
212 if [[ ! $file_to_parse =~ ceilometer ]]; then
213 file_to_parse="${file_to_parse} ceilometer"
214 fi
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100215 elif [[ $service == s-* ]]; then
216 if [[ ! $file_to_parse =~ swift ]]; then
217 file_to_parse="${file_to_parse} swift"
218 fi
Dean Troyer7e270512012-06-14 15:23:24 -0500219 elif [[ $service == n-* ]]; then
220 if [[ ! $file_to_parse =~ nova ]]; then
221 file_to_parse="${file_to_parse} nova"
222 fi
223 elif [[ $service == g-* ]]; then
224 if [[ ! $file_to_parse =~ glance ]]; then
225 file_to_parse="${file_to_parse} glance"
226 fi
227 elif [[ $service == key* ]]; then
228 if [[ ! $file_to_parse =~ keystone ]]; then
229 file_to_parse="${file_to_parse} keystone"
230 fi
Robert Collins0a9954f2012-11-20 11:34:25 +1300231 elif [[ $service == q-* ]]; then
232 if [[ ! $file_to_parse =~ quantum ]]; then
233 file_to_parse="${file_to_parse} quantum"
234 fi
Dean Troyer7e270512012-06-14 15:23:24 -0500235 fi
236 done
237
238 for file in ${file_to_parse}; do
239 local fname=${package_dir}/${file}
240 local OIFS line package distros distro
241 [[ -e $fname ]] || continue
242
243 OIFS=$IFS
244 IFS=$'\n'
245 for line in $(<${fname}); do
246 if [[ $line =~ "NOPRIME" ]]; then
247 continue
248 fi
249
250 if [[ $line =~ (.*)#.*dist:([^ ]*) ]]; then
251 # We are using BASH regexp matching feature.
252 package=${BASH_REMATCH[1]}
253 distros=${BASH_REMATCH[2]}
254 # In bash ${VAR,,} will lowecase VAR
255 [[ ${distros,,} =~ ${DISTRO,,} ]] && echo $package
256 continue
257 fi
258
259 echo ${line%#*}
260 done
261 IFS=$OIFS
262 done
263}
264
265
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500266# Determine OS Vendor, Release and Update
267# Tested with OS/X, Ubuntu, RedHat, CentOS, Fedora
268# Returns results in global variables:
269# os_VENDOR - vendor name
270# os_RELEASE - release
271# os_UPDATE - update
272# os_PACKAGE - package type
273# os_CODENAME - vendor's codename for release
274# GetOSVersion
275GetOSVersion() {
276 # Figure out which vendor we are
277 if [[ -n "`which sw_vers 2>/dev/null`" ]]; then
278 # OS/X
279 os_VENDOR=`sw_vers -productName`
280 os_RELEASE=`sw_vers -productVersion`
281 os_UPDATE=${os_RELEASE##*.}
282 os_RELEASE=${os_RELEASE%.*}
283 os_PACKAGE=""
284 if [[ "$os_RELEASE" =~ "10.7" ]]; then
285 os_CODENAME="lion"
286 elif [[ "$os_RELEASE" =~ "10.6" ]]; then
287 os_CODENAME="snow leopard"
288 elif [[ "$os_RELEASE" =~ "10.5" ]]; then
289 os_CODENAME="leopard"
290 elif [[ "$os_RELEASE" =~ "10.4" ]]; then
291 os_CODENAME="tiger"
292 elif [[ "$os_RELEASE" =~ "10.3" ]]; then
293 os_CODENAME="panther"
294 else
295 os_CODENAME=""
296 fi
297 elif [[ -x $(which lsb_release 2>/dev/null) ]]; then
298 os_VENDOR=$(lsb_release -i -s)
299 os_RELEASE=$(lsb_release -r -s)
300 os_UPDATE=""
Attila Fazekasaf988fd2013-01-13 14:20:47 +0100301 os_PACKAGE="rpm"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500302 if [[ "Debian,Ubuntu" =~ $os_VENDOR ]]; then
303 os_PACKAGE="deb"
Vincent Untz856a11e2012-11-21 16:04:12 +0100304 elif [[ "SUSE LINUX" =~ $os_VENDOR ]]; then
305 lsb_release -d -s | grep -q openSUSE
306 if [[ $? -eq 0 ]]; then
307 os_VENDOR="openSUSE"
308 fi
Vincent Untzcd1fe982013-03-12 18:04:29 +0100309 elif [[ $os_VENDOR == "openSUSE project" ]]; then
310 os_VENDOR="openSUSE"
Attila Fazekasaf988fd2013-01-13 14:20:47 +0100311 elif [[ $os_VENDOR =~ Red.*Hat ]]; then
312 os_VENDOR="Red Hat"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500313 fi
314 os_CODENAME=$(lsb_release -c -s)
315 elif [[ -r /etc/redhat-release ]]; then
316 # Red Hat Enterprise Linux Server release 5.5 (Tikanga)
317 # CentOS release 5.5 (Final)
318 # CentOS Linux release 6.0 (Final)
319 # Fedora release 16 (Verne)
320 os_CODENAME=""
321 for r in "Red Hat" CentOS Fedora; do
322 os_VENDOR=$r
323 if [[ -n "`grep \"$r\" /etc/redhat-release`" ]]; then
324 ver=`sed -e 's/^.* \(.*\) (\(.*\)).*$/\1\|\2/' /etc/redhat-release`
325 os_CODENAME=${ver#*|}
326 os_RELEASE=${ver%|*}
327 os_UPDATE=${os_RELEASE##*.}
328 os_RELEASE=${os_RELEASE%.*}
329 break
330 fi
331 os_VENDOR=""
332 done
333 os_PACKAGE="rpm"
Vincent Untz856a11e2012-11-21 16:04:12 +0100334 elif [[ -r /etc/SuSE-release ]]; then
335 for r in openSUSE "SUSE Linux"; do
336 if [[ "$r" = "SUSE Linux" ]]; then
337 os_VENDOR="SUSE LINUX"
338 else
339 os_VENDOR=$r
340 fi
341
342 if [[ -n "`grep \"$r\" /etc/SuSE-release`" ]]; then
343 os_CODENAME=`grep "CODENAME = " /etc/SuSE-release | sed 's:.* = ::g'`
344 os_RELEASE=`grep "VERSION = " /etc/SuSE-release | sed 's:.* = ::g'`
345 os_UPDATE=`grep "PATCHLEVEL = " /etc/SuSE-release | sed 's:.* = ::g'`
346 break
347 fi
348 os_VENDOR=""
349 done
350 os_PACKAGE="rpm"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500351 fi
352 export os_VENDOR os_RELEASE os_UPDATE os_PACKAGE os_CODENAME
353}
354
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300355# git update using reference as a branch.
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500356# git_update_branch ref
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300357function git_update_branch() {
358
359 GIT_BRANCH=$1
360
361 git checkout -f origin/$GIT_BRANCH
362 # a local branch might not exist
363 git branch -D $GIT_BRANCH || true
364 git checkout -b $GIT_BRANCH
365}
366
367
368# git update using reference as a tag. Be careful editing source at that repo
369# as working copy will be in a detached mode
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500370# git_update_tag ref
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300371function git_update_tag() {
372
373 GIT_TAG=$1
374
375 git tag -d $GIT_TAG
376 # fetching given tag only
377 git fetch origin tag $GIT_TAG
378 git checkout -f $GIT_TAG
379}
380
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500381
Andrew Laskif900bd72012-09-05 17:23:14 -0400382# git update using reference as a branch.
383# git_update_remote_branch ref
384function git_update_remote_branch() {
385
386 GIT_BRANCH=$1
387
388 git checkout -b $GIT_BRANCH -t origin/$GIT_BRANCH
389}
390
391
Dean Troyera9e0a482012-07-09 14:07:23 -0500392# Translate the OS version values into common nomenclature
393# Sets ``DISTRO`` from the ``os_*`` values
394function GetDistro() {
395 GetOSVersion
396 if [[ "$os_VENDOR" =~ (Ubuntu) ]]; then
397 # 'Everyone' refers to Ubuntu releases by the code name adjective
398 DISTRO=$os_CODENAME
399 elif [[ "$os_VENDOR" =~ (Fedora) ]]; then
400 # For Fedora, just use 'f' and the release
401 DISTRO="f$os_RELEASE"
Vincent Untz856a11e2012-11-21 16:04:12 +0100402 elif [[ "$os_VENDOR" =~ (openSUSE) ]]; then
403 DISTRO="opensuse-$os_RELEASE"
404 elif [[ "$os_VENDOR" =~ (SUSE LINUX) ]]; then
405 # For SLE, also use the service pack
406 if [[ -z "$os_UPDATE" ]]; then
407 DISTRO="sle${os_RELEASE}"
408 else
409 DISTRO="sle${os_RELEASE}sp${os_UPDATE}"
410 fi
Dean Troyera9e0a482012-07-09 14:07:23 -0500411 else
412 # Catch-all for now is Vendor + Release + Update
413 DISTRO="$os_VENDOR-$os_RELEASE.$os_UPDATE"
414 fi
415 export DISTRO
416}
417
418
Vincent Untzc18b9652012-12-04 12:36:34 +0100419# Determine if current distribution is an Ubuntu-based distribution.
420# It will also detect non-Ubuntu but Debian-based distros; this is not an issue
421# since Debian and Ubuntu should be compatible.
422# is_ubuntu
423function is_ubuntu {
424 if [[ -z "$os_PACKAGE" ]]; then
425 GetOSVersion
426 fi
427
428 [ "$os_PACKAGE" = "deb" ]
429}
430
431
Vincent Untz00011c02012-12-06 09:56:32 +0100432# Determine if current distribution is a Fedora-based distribution
433# (Fedora, RHEL, CentOS).
434# is_fedora
435function is_fedora {
436 if [[ -z "$os_VENDOR" ]]; then
437 GetOSVersion
438 fi
439
440 [ "$os_VENDOR" = "Fedora" ] || [ "$os_VENDOR" = "Red Hat" ] || [ "$os_VENDOR" = "CentOS" ]
441}
442
443
Vincent Untz856a11e2012-11-21 16:04:12 +0100444# Determine if current distribution is a SUSE-based distribution
445# (openSUSE, SLE).
446# is_suse
447function is_suse {
448 if [[ -z "$os_VENDOR" ]]; then
449 GetOSVersion
450 fi
451
Steve Baker1a7bbd22012-12-03 17:04:02 +1300452 [ "$os_VENDOR" = "openSUSE" ] || [ "$os_VENDOR" = "SUSE LINUX" ]
Vincent Untz856a11e2012-11-21 16:04:12 +0100453}
454
455
Vincent Untz00011c02012-12-06 09:56:32 +0100456# Exit after outputting a message about the distribution not being supported.
457# exit_distro_not_supported [optional-string-telling-what-is-missing]
458function exit_distro_not_supported {
459 if [[ -z "$DISTRO" ]]; then
460 GetDistro
461 fi
462
463 if [ $# -gt 0 ]; then
Nachi Ueno07115eb2013-02-26 12:38:18 -0800464 die $LINENO "Support for $DISTRO is incomplete: no support for $@"
Vincent Untz00011c02012-12-06 09:56:32 +0100465 else
Nachi Ueno07115eb2013-02-26 12:38:18 -0800466 die $LINENO "Support for $DISTRO is incomplete."
Vincent Untz00011c02012-12-06 09:56:32 +0100467 fi
Vincent Untz00011c02012-12-06 09:56:32 +0100468}
469
470
Dean Troyer7f9aa712012-01-31 12:11:56 -0600471# git clone only if directory doesn't exist already. Since ``DEST`` might not
472# be owned by the installation user, we create the directory and change the
473# ownership to the proper user.
474# Set global RECLONE=yes to simulate a clone when dest-dir exists
James E. Blair94cb9602012-06-22 15:28:29 -0700475# Set global ERROR_ON_CLONE=True to abort execution with an error if the git repo
476# does not exist (default is False, meaning the repo will be cloned).
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500477# Uses global ``OFFLINE``
Dean Troyer7f9aa712012-01-31 12:11:56 -0600478# git_clone remote dest-dir branch
479function git_clone {
480 [[ "$OFFLINE" = "True" ]] && return
481
482 GIT_REMOTE=$1
483 GIT_DEST=$2
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300484 GIT_REF=$3
Dean Troyer7f9aa712012-01-31 12:11:56 -0600485
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300486 if echo $GIT_REF | egrep -q "^refs"; then
Dean Troyer7f9aa712012-01-31 12:11:56 -0600487 # If our branch name is a gerrit style refs/changes/...
488 if [[ ! -d $GIT_DEST ]]; then
James E. Blair94cb9602012-06-22 15:28:29 -0700489 [[ "$ERROR_ON_CLONE" = "True" ]] && exit 1
Dean Troyer7f9aa712012-01-31 12:11:56 -0600490 git clone $GIT_REMOTE $GIT_DEST
491 fi
492 cd $GIT_DEST
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300493 git fetch $GIT_REMOTE $GIT_REF && git checkout FETCH_HEAD
Dean Troyer7f9aa712012-01-31 12:11:56 -0600494 else
495 # do a full clone only if the directory doesn't exist
496 if [[ ! -d $GIT_DEST ]]; then
James E. Blair94cb9602012-06-22 15:28:29 -0700497 [[ "$ERROR_ON_CLONE" = "True" ]] && exit 1
Dean Troyer7f9aa712012-01-31 12:11:56 -0600498 git clone $GIT_REMOTE $GIT_DEST
499 cd $GIT_DEST
500 # This checkout syntax works for both branches and tags
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300501 git checkout $GIT_REF
Dean Troyer7f9aa712012-01-31 12:11:56 -0600502 elif [[ "$RECLONE" == "yes" ]]; then
503 # if it does exist then simulate what clone does if asked to RECLONE
504 cd $GIT_DEST
505 # set the url to pull from and fetch
506 git remote set-url origin $GIT_REMOTE
507 git fetch origin
508 # remove the existing ignored files (like pyc) as they cause breakage
509 # (due to the py files having older timestamps than our pyc, so python
510 # thinks the pyc files are correct using them)
511 find $GIT_DEST -name '*.pyc' -delete
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300512
513 # handle GIT_REF accordingly to type (tag, branch)
514 if [[ -n "`git show-ref refs/tags/$GIT_REF`" ]]; then
515 git_update_tag $GIT_REF
516 elif [[ -n "`git show-ref refs/heads/$GIT_REF`" ]]; then
517 git_update_branch $GIT_REF
Andrew Laskif900bd72012-09-05 17:23:14 -0400518 elif [[ -n "`git show-ref refs/remotes/origin/$GIT_REF`" ]]; then
519 git_update_remote_branch $GIT_REF
Evgeniy Afonichev6a3912d2012-07-10 14:02:43 +0300520 else
521 echo $GIT_REF is neither branch nor tag
522 exit 1
523 fi
524
Dean Troyer7f9aa712012-01-31 12:11:56 -0600525 fi
526 fi
527}
528
529
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500530# Comment an option in an INI file
Chmouel Boudjnahc7214e82012-06-06 13:56:39 +0200531# inicomment config-file section option
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500532function inicomment() {
533 local file=$1
534 local section=$2
535 local option=$3
Attila Fazekas588eb412012-12-20 10:57:16 +0100536 sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=.*$\)|#\1|" "$file"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500537}
538
Chmouel Boudjnahc7214e82012-06-06 13:56:39 +0200539# Uncomment an option in an INI file
540# iniuncomment config-file section option
541function iniuncomment() {
542 local file=$1
543 local section=$2
544 local option=$3
Attila Fazekas588eb412012-12-20 10:57:16 +0100545 sed -i -e "/^\[$section\]/,/^\[.*\]/ s|[^ \t]*#[ \t]*\($option[ \t]*=.*$\)|\1|" "$file"
Chmouel Boudjnahc7214e82012-06-06 13:56:39 +0200546}
547
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500548
549# Get an option from an INI file
Dean Troyer09e636e2012-03-19 16:31:12 -0500550# iniget config-file section option
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500551function iniget() {
552 local file=$1
553 local section=$2
554 local option=$3
555 local line
Attila Fazekas588eb412012-12-20 10:57:16 +0100556 line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500557 echo ${line#*=}
558}
559
Attila Fazekas588eb412012-12-20 10:57:16 +0100560# Determinate is the given option present in the INI file
561# ini_has_option config-file section option
562function ini_has_option() {
563 local file=$1
564 local section=$2
565 local option=$3
566 local line
567 line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
568 [ -n "$line" ]
569}
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500570
571# Set an option in an INI file
Dean Troyer09e636e2012-03-19 16:31:12 -0500572# iniset config-file section option value
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500573function iniset() {
574 local file=$1
575 local section=$2
576 local option=$3
577 local value=$4
Attila Fazekas588eb412012-12-20 10:57:16 +0100578 if ! grep -q "^\[$section\]" "$file"; then
Dean Troyer09e636e2012-03-19 16:31:12 -0500579 # Add section at the end
Attila Fazekas588eb412012-12-20 10:57:16 +0100580 echo -e "\n[$section]" >>"$file"
Dean Troyer09e636e2012-03-19 16:31:12 -0500581 fi
Attila Fazekas588eb412012-12-20 10:57:16 +0100582 if ! ini_has_option "$file" "$section" "$option"; then
Dean Troyer09e636e2012-03-19 16:31:12 -0500583 # Add it
Attila Fazekas588eb412012-12-20 10:57:16 +0100584 sed -i -e "/^\[$section\]/ a\\
Dean Troyer09e636e2012-03-19 16:31:12 -0500585$option = $value
Attila Fazekas588eb412012-12-20 10:57:16 +0100586" "$file"
Dean Troyer09e636e2012-03-19 16:31:12 -0500587 else
588 # Replace it
Attila Fazekas588eb412012-12-20 10:57:16 +0100589 sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" "$file"
Dean Troyer09e636e2012-03-19 16:31:12 -0500590 fi
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500591}
592
Lianhao Lu239f3242013-03-01 15:54:02 +0800593# Get a multiple line option from an INI file
594# iniget_multiline config-file section option
595function iniget_multiline() {
596 local file=$1
597 local section=$2
598 local option=$3
599 local values
600 values=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { s/^$option[ \t]*=[ \t]*//gp; }" "$file")
601 echo ${values}
602}
603
604# Set a multiple line option in an INI file
605# iniset_multiline config-file section option value1 value2 valu3 ...
606function iniset_multiline() {
607 local file=$1
608 local section=$2
609 local option=$3
610 shift 3
611 local values
612 for v in $@; do
613 # The later sed command inserts each new value in the line next to
614 # the section identifier, which causes the values to be inserted in
615 # the reverse order. Do a reverse here to keep the original order.
616 values="$v ${values}"
617 done
618 if ! grep -q "^\[$section\]" "$file"; then
619 # Add section at the end
620 echo -e "\n[$section]" >>"$file"
621 else
622 # Remove old values
623 sed -i -e "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ d; }" "$file"
624 fi
625 # Add new ones
626 for v in $values; do
627 sed -i -e "/^\[$section\]/ a\\
628$option = $v
629" "$file"
630 done
631}
632
633# Append a new option in an ini file without replacing the old value
634# iniadd config-file section option value1 value2 value3 ...
635function iniadd() {
636 local file=$1
637 local section=$2
638 local option=$3
639 shift 3
640 local values="$(iniget_multiline $file $section $option) $@"
641 iniset_multiline $file $section $option $values
642}
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500643
Chmouel Boudjnah408b0092012-03-15 23:21:55 +0000644# is_service_enabled() checks if the service(s) specified as arguments are
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500645# enabled by the user in ``ENABLED_SERVICES``.
Chmouel Boudjnah408b0092012-03-15 23:21:55 +0000646#
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500647# Multiple services specified as arguments are ``OR``'ed together; the test
648# is a short-circuit boolean, i.e it returns on the first match.
Chmouel Boudjnah408b0092012-03-15 23:21:55 +0000649#
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500650# There are special cases for some 'catch-all' services::
Chmouel Boudjnah408b0092012-03-15 23:21:55 +0000651# **nova** returns true if any service enabled start with **n-**
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500652# **cinder** returns true if any service enabled start with **c-**
653# **ceilometer** returns true if any service enabled start with **ceilometer**
Chmouel Boudjnah408b0092012-03-15 23:21:55 +0000654# **glance** returns true if any service enabled start with **g-**
655# **quantum** returns true if any service enabled start with **q-**
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100656# **swift** returns true if any service enabled start with **s-**
657# For backward compatibility if we have **swift** in ENABLED_SERVICES all the
658# **s-** services will be enabled. This will be deprecated in the future.
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500659#
660# Uses global ``ENABLED_SERVICES``
661# is_service_enabled service [service ...]
Chmouel Boudjnah408b0092012-03-15 23:21:55 +0000662function is_service_enabled() {
663 services=$@
664 for service in ${services}; do
665 [[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0
666 [[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
Dean Troyer67787e62012-05-02 11:48:15 -0500667 [[ ${service} == "cinder" && ${ENABLED_SERVICES} =~ "c-" ]] && return 0
John H. Tran93361642012-07-26 11:22:05 -0700668 [[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && return 0
Chmouel Boudjnah408b0092012-03-15 23:21:55 +0000669 [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
670 [[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100671 [[ ${service} == "swift" && ${ENABLED_SERVICES} =~ "s-" ]] && return 0
672 [[ ${service} == s-* && ${ENABLED_SERVICES} =~ "swift" ]] && return 0
Chmouel Boudjnah408b0092012-03-15 23:21:55 +0000673 done
674 return 1
675}
676
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500677
678# remove extra commas from the input string (i.e. ``ENABLED_SERVICES``)
679# _cleanup_service_list service-list
Doug Hellmannf04178f2012-07-05 17:10:03 -0400680function _cleanup_service_list () {
Dean Troyerca0e3d02012-04-13 15:58:37 -0500681 echo "$1" | sed -e '
Doug Hellmannf04178f2012-07-05 17:10:03 -0400682 s/,,/,/g;
683 s/^,//;
684 s/,$//
685 '
686}
687
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500688
Doug Hellmannf04178f2012-07-05 17:10:03 -0400689# enable_service() adds the services passed as argument to the
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500690# ``ENABLED_SERVICES`` list, if they are not already present.
Doug Hellmannf04178f2012-07-05 17:10:03 -0400691#
692# For example:
Joe Gordon6fd28112012-11-13 16:55:41 -0800693# enable_service qpid
Doug Hellmannf04178f2012-07-05 17:10:03 -0400694#
695# This function does not know about the special cases
696# for nova, glance, and quantum built into is_service_enabled().
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500697# Uses global ``ENABLED_SERVICES``
698# enable_service service [service ...]
Doug Hellmannf04178f2012-07-05 17:10:03 -0400699function enable_service() {
700 local tmpsvcs="${ENABLED_SERVICES}"
701 for service in $@; do
702 if ! is_service_enabled $service; then
703 tmpsvcs+=",$service"
704 fi
705 done
706 ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs")
707 disable_negated_services
708}
709
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500710
Doug Hellmannf04178f2012-07-05 17:10:03 -0400711# disable_service() removes the services passed as argument to the
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500712# ``ENABLED_SERVICES`` list, if they are present.
Doug Hellmannf04178f2012-07-05 17:10:03 -0400713#
714# For example:
Joe Gordon6fd28112012-11-13 16:55:41 -0800715# disable_service rabbit
Doug Hellmannf04178f2012-07-05 17:10:03 -0400716#
717# This function does not know about the special cases
718# for nova, glance, and quantum built into is_service_enabled().
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500719# Uses global ``ENABLED_SERVICES``
720# disable_service service [service ...]
Doug Hellmannf04178f2012-07-05 17:10:03 -0400721function disable_service() {
722 local tmpsvcs=",${ENABLED_SERVICES},"
723 local service
724 for service in $@; do
725 if is_service_enabled $service; then
726 tmpsvcs=${tmpsvcs//,$service,/,}
727 fi
728 done
729 ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs")
730}
731
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500732
Doug Hellmannf04178f2012-07-05 17:10:03 -0400733# disable_all_services() removes all current services
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500734# from ``ENABLED_SERVICES`` to reset the configuration
Doug Hellmannf04178f2012-07-05 17:10:03 -0400735# before a minimal installation
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500736# Uses global ``ENABLED_SERVICES``
737# disable_all_services
Doug Hellmannf04178f2012-07-05 17:10:03 -0400738function disable_all_services() {
739 ENABLED_SERVICES=""
740}
741
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500742
743# Remove all services starting with '-'. For example, to install all default
Joe Gordon6fd28112012-11-13 16:55:41 -0800744# services except rabbit (rabbit) set in ``localrc``:
745# ENABLED_SERVICES+=",-rabbit"
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500746# Uses global ``ENABLED_SERVICES``
747# disable_negated_services
Doug Hellmannf04178f2012-07-05 17:10:03 -0400748function disable_negated_services() {
749 local tmpsvcs="${ENABLED_SERVICES}"
750 local service
751 for service in ${tmpsvcs//,/ }; do
752 if [[ ${service} == -* ]]; then
753 tmpsvcs=$(echo ${tmpsvcs}|sed -r "s/(,)?(-)?${service#-}(,)?/,/g")
754 fi
755 done
756 ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs")
757}
Dean Troyer489bd2a2012-03-02 10:44:29 -0600758
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500759
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500760# Distro-agnostic package installer
761# install_package package [package ...]
762function install_package() {
Vincent Untzc18b9652012-12-04 12:36:34 +0100763 if is_ubuntu; then
Vincent Untzc0482e62012-06-12 11:30:43 +0200764 [[ "$NO_UPDATE_REPOS" = "True" ]] || apt_get update
765 NO_UPDATE_REPOS=True
766
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500767 apt_get install "$@"
Vincent Untz00011c02012-12-06 09:56:32 +0100768 elif is_fedora; then
769 yum_install "$@"
770 elif is_suse; then
771 zypper_install "$@"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500772 else
Vincent Untz00011c02012-12-06 09:56:32 +0100773 exit_distro_not_supported "installing packages"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500774 fi
775}
776
777
Dean Troyer995eb922013-03-07 16:11:40 -0600778# Distro-agnostic package uninstaller
779# uninstall_package package [package ...]
780function uninstall_package() {
781 if is_ubuntu; then
782 apt_get purge "$@"
783 elif is_fedora; then
Ian Wienand2c678cc2013-03-20 13:00:44 +1100784 sudo yum remove -y "$@"
Dean Troyer995eb922013-03-07 16:11:40 -0600785 elif is_suse; then
Ian Wienand2c678cc2013-03-20 13:00:44 +1100786 sudo rpm -e "$@"
Dean Troyer995eb922013-03-07 16:11:40 -0600787 else
788 exit_distro_not_supported "uninstalling packages"
789 fi
790}
791
792
Vincent Untz71ebc6f2012-06-12 13:45:15 +0200793# Distro-agnostic function to tell if a package is installed
794# is_package_installed package [package ...]
795function is_package_installed() {
796 if [[ -z "$@" ]]; then
797 return 1
798 fi
799
800 if [[ -z "$os_PACKAGE" ]]; then
801 GetOSVersion
802 fi
Vincent Untzc18b9652012-12-04 12:36:34 +0100803
Vincent Untz71ebc6f2012-06-12 13:45:15 +0200804 if [[ "$os_PACKAGE" = "deb" ]]; then
805 dpkg -l "$@" > /dev/null
Vincent Untz00011c02012-12-06 09:56:32 +0100806 elif [[ "$os_PACKAGE" = "rpm" ]]; then
Vincent Untz71ebc6f2012-06-12 13:45:15 +0200807 rpm --quiet -q "$@"
Vincent Untz00011c02012-12-06 09:56:32 +0100808 else
809 exit_distro_not_supported "finding if a package is installed"
Vincent Untz71ebc6f2012-06-12 13:45:15 +0200810 fi
811}
812
813
Dean Troyer489bd2a2012-03-02 10:44:29 -0600814# Test if the named environment variable is set and not zero length
815# is_set env-var
816function is_set() {
817 local var=\$"$1"
Attila Fazekas251d3b52012-12-16 15:05:44 +0100818 eval "[ -n \"$var\" ]" # For ex.: sh -c "[ -n \"$var\" ]" would be better, but several exercises depends on this
Dean Troyer489bd2a2012-03-02 10:44:29 -0600819}
820
821
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500822# Wrapper for ``pip install`` to set cache and proxy environment variables
Maru Newby3a87edd2012-10-25 23:01:06 +0000823# Uses globals ``OFFLINE``, ``PIP_DOWNLOAD_CACHE``, ``PIP_USE_MIRRORS``,
824# ``TRACK_DEPENDS``, ``*_proxy`
Dean Troyer7f9aa712012-01-31 12:11:56 -0600825# pip_install package [package ...]
826function pip_install {
Dean Troyerd0b21e22012-03-07 14:52:25 -0600827 [[ "$OFFLINE" = "True" || -z "$@" ]] && return
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500828 if [[ -z "$os_PACKAGE" ]]; then
829 GetOSVersion
830 fi
Monty Taylor47f02062012-07-26 11:09:24 -0500831 if [[ $TRACK_DEPENDS = True ]] ; then
832 source $DEST/.venv/bin/activate
833 CMD_PIP=$DEST/.venv/bin/pip
834 SUDO_PIP="env"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500835 else
Monty Taylor47f02062012-07-26 11:09:24 -0500836 SUDO_PIP="sudo"
Vincent Untz8ec27222012-11-29 09:25:31 +0100837 CMD_PIP=$(get_pip_command)
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500838 fi
Maru Newby3a87edd2012-10-25 23:01:06 +0000839 if [[ "$PIP_USE_MIRRORS" != "False" ]]; then
840 PIP_MIRROR_OPT="--use-mirrors"
841 fi
Monty Taylor47f02062012-07-26 11:09:24 -0500842 $SUDO_PIP PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE:-/var/cache/pip} \
Dean Troyer7f9aa712012-01-31 12:11:56 -0600843 HTTP_PROXY=$http_proxy \
844 HTTPS_PROXY=$https_proxy \
Osamu Habuka7abe4f22012-07-25 12:39:32 +0900845 NO_PROXY=$no_proxy \
Maru Newby3a87edd2012-10-25 23:01:06 +0000846 $CMD_PIP install $PIP_MIRROR_OPT $@
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500847}
848
849
850# Service wrapper to restart services
851# restart_service service-name
852function restart_service() {
Vincent Untzc18b9652012-12-04 12:36:34 +0100853 if is_ubuntu; then
Dean Troyer5218d452012-02-04 02:13:23 -0600854 sudo /usr/sbin/service $1 restart
855 else
856 sudo /sbin/service $1 restart
857 fi
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500858}
859
860
Dean Troyer681f3fd2013-02-27 19:00:39 -0600861# _run_process() is designed to be backgrounded by run_process() to simulate a
862# fork. It includes the dirty work of closing extra filehandles and preparing log
863# files to produce the same logs as screen_it(). The log filename is derived
864# from the service name and global-and-now-misnamed SCREEN_LOGDIR
865# _run_process service "command-line"
866function _run_process() {
867 local service=$1
868 local command="$2"
869
870 # Undo logging redirections and close the extra descriptors
871 exec 1>&3
872 exec 2>&3
873 exec 3>&-
874 exec 6>&-
875
876 if [[ -n ${SCREEN_LOGDIR} ]]; then
877 exec 1>&${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log 2>&1
878 ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
879
880 # TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
881 export PYTHONUNBUFFERED=1
882 fi
883
884 exec /bin/bash -c "$command"
885 die "$service exec failure: $command"
886}
887
888
889# run_process() launches a child process that closes all file descriptors and
890# then exec's the passed in command. This is meant to duplicate the semantics
891# of screen_it() without screen. PIDs are written to
892# $SERVICE_DIR/$SCREEN_NAME/$service.pid
893# run_process service "command-line"
894function run_process() {
895 local service=$1
896 local command="$2"
897
898 # Spawn the child process
899 _run_process "$service" "$command" &
900 echo $!
901}
902
903
Dean Troyer15733352012-09-06 11:51:30 -0500904# Helper to launch a service in a named screen
905# screen_it service "command-line"
906function screen_it {
Dean Troyer15733352012-09-06 11:51:30 -0500907 SCREEN_NAME=${SCREEN_NAME:-stack}
jiajun xua9414242012-12-06 16:30:57 +0800908 SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
Dean Troyer681f3fd2013-02-27 19:00:39 -0600909 USE_SCREEN=$(trueorfalse True $USE_SCREEN)
jiajun xua9414242012-12-06 16:30:57 +0800910
Dean Troyer15733352012-09-06 11:51:30 -0500911 if is_service_enabled $1; then
912 # Append the service to the screen rc file
913 screen_rc "$1" "$2"
914
Dean Troyer681f3fd2013-02-27 19:00:39 -0600915 if [[ "$USE_SCREEN" = "True" ]]; then
916 screen -S $SCREEN_NAME -X screen -t $1
Jeremy Stanley25ebbcd2013-02-17 15:45:55 +0000917
Dean Troyer681f3fd2013-02-27 19:00:39 -0600918 if [[ -n ${SCREEN_LOGDIR} ]]; then
919 screen -S $SCREEN_NAME -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log
920 screen -S $SCREEN_NAME -p $1 -X log on
921 ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
922 fi
Jeremy Stanley25ebbcd2013-02-17 15:45:55 +0000923
Vishvananda Ishaya58e21342013-02-11 16:48:12 -0800924 # sleep to allow bash to be ready to be send the command - we are
925 # creating a new window in screen and then sends characters, so if
926 # bash isn't running by the time we send the command, nothing happens
927 sleep 1.5
Dean Troyer15733352012-09-06 11:51:30 -0500928
Vishvananda Ishaya58e21342013-02-11 16:48:12 -0800929 NL=`echo -ne '\015'`
930 screen -S $SCREEN_NAME -p $1 -X stuff "$2 || touch \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL"
931 else
Dean Troyer681f3fd2013-02-27 19:00:39 -0600932 # Spawn directly without screen
933 run_process "$1" "$2" >$SERVICE_DIR/$SCREEN_NAME/$service.pid
Dean Troyer15733352012-09-06 11:51:30 -0500934 fi
Dean Troyer15733352012-09-06 11:51:30 -0500935 fi
936}
937
938
939# Screen rc file builder
940# screen_rc service "command-line"
941function screen_rc {
942 SCREEN_NAME=${SCREEN_NAME:-stack}
943 SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc
944 if [[ ! -e $SCREENRC ]]; then
945 # Name the screen session
946 echo "sessionname $SCREEN_NAME" > $SCREENRC
947 # Set a reasonable statusbar
948 echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC
949 echo "screen -t shell bash" >> $SCREENRC
950 fi
951 # If this service doesn't already exist in the screenrc file
952 if ! grep $1 $SCREENRC 2>&1 > /dev/null; then
953 NL=`echo -ne '\015'`
954 echo "screen -t $1 bash" >> $SCREENRC
955 echo "stuff \"$2$NL\"" >> $SCREENRC
956 fi
957}
958
jiajun xua9414242012-12-06 16:30:57 +0800959# Helper to remove the *.failure files under $SERVICE_DIR/$SCREEN_NAME
960# This is used for service_check when all the screen_it are called finished
961# init_service_check
962function init_service_check() {
963 SCREEN_NAME=${SCREEN_NAME:-stack}
964 SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
965
966 if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then
967 mkdir -p "$SERVICE_DIR/$SCREEN_NAME"
968 fi
969
970 rm -f "$SERVICE_DIR/$SCREEN_NAME"/*.failure
971}
972
973# Helper to get the status of each running service
974# service_check
975function service_check() {
976 local service
977 local failures
978 SCREEN_NAME=${SCREEN_NAME:-stack}
979 SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
980
981
982 if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then
983 echo "No service status directory found"
984 return
985 fi
986
987 # Check if there is any falure flag file under $SERVICE_DIR/$SCREEN_NAME
988 failures=`ls "$SERVICE_DIR/$SCREEN_NAME"/*.failure 2>/dev/null`
989
990 for service in $failures; do
991 service=`basename $service`
992 service=${service::-8}
993 echo "Error: Service $service is not running"
994 done
995
996 if [ -n "$failures" ]; then
997 echo "More details about the above errors can be found with screen, with ./rejoin-stack.sh"
998 fi
999}
Dean Troyer15733352012-09-06 11:51:30 -05001000
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001001# ``pip install`` the dependencies of the package before ``setup.py develop``
1002# so pip and not distutils processes the dependency chain
1003# Uses globals ``TRACK_DEPENDES``, ``*_proxy`
Dean Troyerbbafb1b2012-06-11 16:51:39 -05001004# setup_develop directory
1005function setup_develop() {
Monty Taylor47f02062012-07-26 11:09:24 -05001006 if [[ $TRACK_DEPENDS = True ]] ; then
1007 SUDO_CMD="env"
1008 else
1009 SUDO_CMD="sudo"
1010 fi
Dean Troyerbbafb1b2012-06-11 16:51:39 -05001011 (cd $1; \
1012 python setup.py egg_info; \
1013 raw_links=$(awk '/^.+/ {print "-f " $1}' *.egg-info/dependency_links.txt); \
1014 depend_links=$(echo $raw_links | xargs); \
Dean Troyer1a3c9fe2012-09-29 17:25:02 -05001015 require_file=$([ ! -r *-info/requires.txt ] || echo "-r *-info/requires.txt"); \
1016 pip_install $require_file $depend_links; \
Monty Taylor47f02062012-07-26 11:09:24 -05001017 $SUDO_CMD \
Dean Troyerbbafb1b2012-06-11 16:51:39 -05001018 HTTP_PROXY=$http_proxy \
1019 HTTPS_PROXY=$https_proxy \
Osamu Habuka7abe4f22012-07-25 12:39:32 +09001020 NO_PROXY=$no_proxy \
Dean Troyerbbafb1b2012-06-11 16:51:39 -05001021 python setup.py develop \
1022 )
1023}
1024
1025
Dean Troyer13dc5cc2012-03-27 14:50:45 -05001026# Service wrapper to start services
1027# start_service service-name
1028function start_service() {
Vincent Untzc18b9652012-12-04 12:36:34 +01001029 if is_ubuntu; then
Dean Troyer5218d452012-02-04 02:13:23 -06001030 sudo /usr/sbin/service $1 start
1031 else
1032 sudo /sbin/service $1 start
1033 fi
Dean Troyer13dc5cc2012-03-27 14:50:45 -05001034}
1035
1036
1037# Service wrapper to stop services
1038# stop_service service-name
1039function stop_service() {
Vincent Untzc18b9652012-12-04 12:36:34 +01001040 if is_ubuntu; then
Dean Troyer5218d452012-02-04 02:13:23 -06001041 sudo /usr/sbin/service $1 stop
1042 else
1043 sudo /sbin/service $1 stop
1044 fi
Dean Troyer7f9aa712012-01-31 12:11:56 -06001045}
1046
1047
1048# Normalize config values to True or False
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001049# Accepts as False: 0 no false False FALSE
1050# Accepts as True: 1 yes true True TRUE
1051# VAR=$(trueorfalse default-value test-value)
Dean Troyer7f9aa712012-01-31 12:11:56 -06001052function trueorfalse() {
1053 local default=$1
1054 local testval=$2
1055
1056 [[ -z "$testval" ]] && { echo "$default"; return; }
1057 [[ "0 no false False FALSE" =~ "$testval" ]] && { echo "False"; return; }
1058 [[ "1 yes true True TRUE" =~ "$testval" ]] && { echo "True"; return; }
1059 echo "$default"
1060}
Dean Troyer27e32692012-03-16 16:16:56 -05001061
Dean Troyer13dc5cc2012-03-27 14:50:45 -05001062
Dean Troyerca0e3d02012-04-13 15:58:37 -05001063# Retrieve an image from a URL and upload into Glance
1064# Uses the following variables:
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001065# ``FILES`` must be set to the cache dir
1066# ``GLANCE_HOSTPORT``
Dean Troyerca0e3d02012-04-13 15:58:37 -05001067# upload_image image-url glance-token
1068function upload_image() {
1069 local image_url=$1
1070 local token=$2
1071
1072 # Create a directory for the downloaded image tarballs.
1073 mkdir -p $FILES/images
1074
1075 # Downloads the image (uec ami+aki style), then extracts it.
1076 IMAGE_FNAME=`basename "$image_url"`
1077 if [[ ! -f $FILES/$IMAGE_FNAME || "$(stat -c "%s" $FILES/$IMAGE_FNAME)" = "0" ]]; then
1078 wget -c $image_url -O $FILES/$IMAGE_FNAME
1079 if [[ $? -ne 0 ]]; then
1080 echo "Not found: $image_url"
1081 return
1082 fi
1083 fi
1084
1085 # OpenVZ-format images are provided as .tar.gz, but not decompressed prior to loading
1086 if [[ "$image_url" =~ 'openvz' ]]; then
1087 IMAGE="$FILES/${IMAGE_FNAME}"
1088 IMAGE_NAME="${IMAGE_FNAME%.tar.gz}"
1089 glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format ami --disk-format ami < "${IMAGE}"
1090 return
1091 fi
1092
Davanum Srinivas316ed6c2013-02-06 15:29:49 -05001093 # XenServer-ovf-format images are provided as .vhd.tgz as well
1094 # and should not be decompressed prior to loading
1095 if [[ "$image_url" =~ '.vhd.tgz' ]]; then
1096 IMAGE="$FILES/${IMAGE_FNAME}"
1097 IMAGE_NAME="${IMAGE_FNAME%.vhd.tgz}"
1098 glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format=ovf --disk-format=vhd < "${IMAGE}"
1099 return
1100 fi
1101
Dean Troyerca0e3d02012-04-13 15:58:37 -05001102 KERNEL=""
1103 RAMDISK=""
1104 DISK_FORMAT=""
1105 CONTAINER_FORMAT=""
1106 UNPACK=""
1107 case "$IMAGE_FNAME" in
1108 *.tar.gz|*.tgz)
1109 # Extract ami and aki files
1110 [ "${IMAGE_FNAME%.tar.gz}" != "$IMAGE_FNAME" ] &&
1111 IMAGE_NAME="${IMAGE_FNAME%.tar.gz}" ||
1112 IMAGE_NAME="${IMAGE_FNAME%.tgz}"
1113 xdir="$FILES/images/$IMAGE_NAME"
1114 rm -Rf "$xdir";
1115 mkdir "$xdir"
1116 tar -zxf $FILES/$IMAGE_FNAME -C "$xdir"
1117 KERNEL=$(for f in "$xdir/"*-vmlinuz* "$xdir/"aki-*/image; do
1118 [ -f "$f" ] && echo "$f" && break; done; true)
1119 RAMDISK=$(for f in "$xdir/"*-initrd* "$xdir/"ari-*/image; do
1120 [ -f "$f" ] && echo "$f" && break; done; true)
1121 IMAGE=$(for f in "$xdir/"*.img "$xdir/"ami-*/image; do
1122 [ -f "$f" ] && echo "$f" && break; done; true)
1123 if [[ -z "$IMAGE_NAME" ]]; then
1124 IMAGE_NAME=$(basename "$IMAGE" ".img")
1125 fi
1126 ;;
1127 *.img)
1128 IMAGE="$FILES/$IMAGE_FNAME";
1129 IMAGE_NAME=$(basename "$IMAGE" ".img")
Dean Troyer636a3ff2012-09-14 11:36:07 -05001130 format=$(qemu-img info ${IMAGE} | awk '/^file format/ { print $3; exit }')
1131 if [[ ",qcow2,raw,vdi,vmdk,vpc," =~ ",$format," ]]; then
1132 DISK_FORMAT=$format
1133 else
1134 DISK_FORMAT=raw
1135 fi
Dean Troyerca0e3d02012-04-13 15:58:37 -05001136 CONTAINER_FORMAT=bare
1137 ;;
1138 *.img.gz)
1139 IMAGE="$FILES/${IMAGE_FNAME}"
1140 IMAGE_NAME=$(basename "$IMAGE" ".img.gz")
1141 DISK_FORMAT=raw
1142 CONTAINER_FORMAT=bare
1143 UNPACK=zcat
1144 ;;
1145 *.qcow2)
1146 IMAGE="$FILES/${IMAGE_FNAME}"
1147 IMAGE_NAME=$(basename "$IMAGE" ".qcow2")
1148 DISK_FORMAT=qcow2
1149 CONTAINER_FORMAT=bare
1150 ;;
Jonathan Michalon06802042013-03-21 14:29:58 +01001151 *.iso)
1152 IMAGE="$FILES/${IMAGE_FNAME}"
1153 IMAGE_NAME=$(basename "$IMAGE" ".iso")
1154 DISK_FORMAT=iso
1155 CONTAINER_FORMAT=bare
1156 ;;
Dean Troyerca0e3d02012-04-13 15:58:37 -05001157 *) echo "Do not know what to do with $IMAGE_FNAME"; false;;
1158 esac
1159
1160 if [ "$CONTAINER_FORMAT" = "bare" ]; then
1161 if [ "$UNPACK" = "zcat" ]; then
1162 glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --public --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < <(zcat --force "${IMAGE}")
1163 else
1164 glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --public --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < "${IMAGE}"
1165 fi
1166 else
1167 # Use glance client to add the kernel the root filesystem.
1168 # We parse the results of the first upload to get the glance ID of the
1169 # kernel for use when uploading the root filesystem.
1170 KERNEL_ID=""; RAMDISK_ID="";
1171 if [ -n "$KERNEL" ]; then
1172 KERNEL_ID=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-kernel" --public --container-format aki --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
1173 fi
1174 if [ -n "$RAMDISK" ]; then
1175 RAMDISK_ID=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-ramdisk" --public --container-format ari --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
1176 fi
1177 glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "${IMAGE_NAME%.img}" --public --container-format ami --disk-format ami ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} ${RAMDISK_ID:+--property ramdisk_id=$RAMDISK_ID} < "${IMAGE}"
1178 fi
1179}
1180
Dean Troyerc1b486a2012-11-05 14:26:09 -06001181# Set the database backend to use
1182# When called from stackrc/localrc DATABASE_BACKENDS has not been
1183# initialized yet, just save the configuration selection and call back later
1184# to validate it.
1185# $1 The name of the database backend to use (mysql, postgresql, ...)
1186function use_database {
1187 if [[ -z "$DATABASE_BACKENDS" ]]; then
Dean Troyerafc29fe2013-02-07 15:56:24 -06001188 # No backends registered means this is likely called from ``localrc``
1189 # This is now deprecated usage
Dean Troyerc1b486a2012-11-05 14:26:09 -06001190 DATABASE_TYPE=$1
Bob Ball3aa88872013-02-28 17:39:41 +00001191 DEPRECATED_TEXT="$DEPRECATED_TEXT\nThe database backend needs to be properly set in ENABLED_SERVICES; use_database is deprecated localrc\n"
Attila Fazekas251d3b52012-12-16 15:05:44 +01001192 else
Dean Troyerafc29fe2013-02-07 15:56:24 -06001193 # This should no longer get called...here for posterity
Attila Fazekas251d3b52012-12-16 15:05:44 +01001194 use_exclusive_service DATABASE_BACKENDS DATABASE_TYPE $1
Dean Troyerc1b486a2012-11-05 14:26:09 -06001195 fi
Dean Troyerc1b486a2012-11-05 14:26:09 -06001196}
1197
Terry Wilson428af5a2012-11-01 16:12:39 -04001198# Toggle enable/disable_service for services that must run exclusive of each other
1199# $1 The name of a variable containing a space-separated list of services
1200# $2 The name of a variable in which to store the enabled service's name
1201# $3 The name of the service to enable
1202function use_exclusive_service {
1203 local options=${!1}
1204 local selection=$3
1205 out=$2
1206 [ -z $selection ] || [[ ! "$options" =~ "$selection" ]] && return 1
1207 for opt in $options;do
1208 [[ "$opt" = "$selection" ]] && enable_service $opt || disable_service $opt
1209 done
1210 eval "$out=$selection"
1211 return 0
1212}
Dean Troyerca0e3d02012-04-13 15:58:37 -05001213
Dean Troyer3a3a2ba2012-12-11 15:26:24 -06001214# Wait for an HTTP server to start answering requests
1215# wait_for_service timeout url
1216function wait_for_service() {
1217 local timeout=$1
1218 local url=$2
1219 timeout $timeout sh -c "while ! http_proxy= https_proxy= curl -s $url >/dev/null; do sleep 1; done"
1220}
1221
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001222# Wrapper for ``yum`` to set proxy environment variables
1223# Uses globals ``OFFLINE``, ``*_proxy`
Dean Troyer13dc5cc2012-03-27 14:50:45 -05001224# yum_install package [package ...]
1225function yum_install() {
1226 [[ "$OFFLINE" = "True" ]] && return
1227 local sudo="sudo"
1228 [[ "$(id -u)" = "0" ]] && sudo="env"
1229 $sudo http_proxy=$http_proxy https_proxy=$https_proxy \
Osamu Habuka7abe4f22012-07-25 12:39:32 +09001230 no_proxy=$no_proxy \
Dean Troyer13dc5cc2012-03-27 14:50:45 -05001231 yum install -y "$@"
1232}
1233
Nachi Uenofda946e2012-10-24 17:26:02 -07001234# ping check
1235# Uses globals ``ENABLED_SERVICES``
1236function ping_check() {
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001237 if is_service_enabled quantum; then
1238 _ping_check_quantum "$1" $2 $3 $4
1239 return
1240 fi
1241 _ping_check_novanet "$1" $2 $3 $4
Nachi Uenofda946e2012-10-24 17:26:02 -07001242}
1243
1244# ping check for nova
1245# Uses globals ``MULTI_HOST``, ``PRIVATE_NETWORK``
1246function _ping_check_novanet() {
1247 local from_net=$1
1248 local ip=$2
1249 local boot_timeout=$3
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001250 local expected=${4:-"True"}
1251 local check_command=""
Nachi Uenofda946e2012-10-24 17:26:02 -07001252 MULTI_HOST=`trueorfalse False $MULTI_HOST`
1253 if [[ "$MULTI_HOST" = "True" && "$from_net" = "$PRIVATE_NETWORK_NAME" ]]; then
1254 sleep $boot_timeout
1255 return
1256 fi
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001257 if [[ "$expected" = "True" ]]; then
1258 check_command="while ! ping -c1 -w1 $ip; do sleep 1; done"
1259 else
1260 check_command="while ping -c1 -w1 $ip; do sleep 1; done"
1261 fi
1262 if ! timeout $boot_timeout sh -c "$check_command"; then
1263 if [[ "$expected" = "True" ]]; then
Nachi Ueno07115eb2013-02-26 12:38:18 -08001264 die $LINENO "[Fail] Couldn't ping server"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001265 else
Nachi Ueno07115eb2013-02-26 12:38:18 -08001266 die $LINENO "[Fail] Could ping server"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001267 fi
Nachi Uenofda946e2012-10-24 17:26:02 -07001268 exit 1
1269 fi
1270}
1271
1272# ssh check
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001273
Nachi Uenofda946e2012-10-24 17:26:02 -07001274function ssh_check() {
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001275 if is_service_enabled quantum; then
1276 _ssh_check_quantum "$1" $2 $3 $4 $5
1277 return
1278 fi
1279 _ssh_check_novanet "$1" $2 $3 $4 $5
1280}
1281
1282function _ssh_check_novanet() {
Nachi Uenofda946e2012-10-24 17:26:02 -07001283 local NET_NAME=$1
1284 local KEY_FILE=$2
1285 local FLOATING_IP=$3
1286 local DEFAULT_INSTANCE_USER=$4
1287 local ACTIVE_TIMEOUT=$5
Dean Troyer6931c132012-11-07 16:51:21 -06001288 local probe_cmd=""
Nachi Uenofda946e2012-10-24 17:26:02 -07001289 if ! timeout $ACTIVE_TIMEOUT sh -c "while ! ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP echo success ; do sleep 1; done"; then
Nachi Ueno07115eb2013-02-26 12:38:18 -08001290 die $LINENO "server didn't become ssh-able!"
Nachi Uenofda946e2012-10-24 17:26:02 -07001291 fi
1292}
Dean Troyer13dc5cc2012-03-27 14:50:45 -05001293
Vincent Untz856a11e2012-11-21 16:04:12 +01001294
1295# zypper wrapper to set arguments correctly
1296# zypper_install package [package ...]
1297function zypper_install() {
1298 [[ "$OFFLINE" = "True" ]] && return
1299 local sudo="sudo"
1300 [[ "$(id -u)" = "0" ]] && sudo="env"
1301 $sudo http_proxy=$http_proxy https_proxy=$https_proxy \
1302 zypper --non-interactive install --auto-agree-with-licenses "$@"
1303}
1304
1305
1306# Add a user to a group.
1307# add_user_to_group user group
1308function add_user_to_group() {
1309 local user=$1
1310 local group=$2
1311
1312 if [[ -z "$os_VENDOR" ]]; then
1313 GetOSVersion
1314 fi
1315
1316 # SLE11 and openSUSE 12.2 don't have the usual usermod
1317 if ! is_suse || [[ "$os_VENDOR" = "openSUSE" && "$os_RELEASE" != "12.2" ]]; then
1318 sudo usermod -a -G "$group" "$user"
1319 else
1320 sudo usermod -A "$group" "$user"
1321 fi
1322}
1323
1324
Jakub Ruzicka4196d552013-01-30 15:35:54 +01001325# Get the path to the direcotry where python executables are installed.
1326# get_python_exec_prefix
1327function get_python_exec_prefix() {
1328 if is_fedora; then
1329 echo "/usr/bin"
1330 else
1331 echo "/usr/local/bin"
1332 fi
1333}
1334
Vincent Untz856a11e2012-11-21 16:04:12 +01001335# Get the location of the $module-rootwrap executables, where module is cinder
1336# or nova.
1337# get_rootwrap_location module
1338function get_rootwrap_location() {
1339 local module=$1
1340
Jakub Ruzicka4196d552013-01-30 15:35:54 +01001341 echo "$(get_python_exec_prefix)/$module-rootwrap"
Vincent Untz856a11e2012-11-21 16:04:12 +01001342}
1343
Vincent Untz8ec27222012-11-29 09:25:31 +01001344# Get the path to the pip command.
1345# get_pip_command
1346function get_pip_command() {
Vincent Untz00011c02012-12-06 09:56:32 +01001347 if is_fedora; then
Nikhil Manchanda35138ed2013-01-03 17:49:58 -08001348 which pip-python
Vincent Untz00011c02012-12-06 09:56:32 +01001349 else
Nikhil Manchanda35138ed2013-01-03 17:49:58 -08001350 which pip
Vincent Untz8ec27222012-11-29 09:25:31 +01001351 fi
1352}
Vincent Untz856a11e2012-11-21 16:04:12 +01001353
Dean Troyer27e32692012-03-16 16:16:56 -05001354# Restore xtrace
Chmouel Boudjnah408b0092012-03-15 23:21:55 +00001355$XTRACE
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001356
1357
1358# Local variables:
Sean Dague584d90e2013-03-29 14:34:53 -04001359# mode: shell-script
Andrew Laskif900bd72012-09-05 17:23:14 -04001360# End: