Skip to content

Commit cc6b443

Browse files
author
Dean Troyer
committed
Formatting cleanups, doc updates and whatnot
Change-Id: Ica8298353be22f947c8e8a03d8dc29ded9cb26dd
1 parent 2e75ff1 commit cc6b443

25 files changed

Lines changed: 145 additions & 75 deletions

HACKING.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ General
77

88
DevStack is written in POSIX shell script. This choice was made because
99
it best illustrates the configuration steps that this implementation takes
10-
on setting up and interacting with OpenStack components. DevStack specifies
11-
BASH and is compatible with Bash 3.
10+
on setting up and interacting with OpenStack components. DevStack specifically
11+
uses Bash and is compatible with Bash 3.
1212

1313
DevStack's official repository is located on GitHub at
1414
https://github.com/openstack-dev/devstack.git. Besides the master branch that
@@ -30,9 +30,17 @@ work for DevStack's use cases. There is a subscript ``functions`` that contains
3030
generally useful shell functions and is used by a number of the scripts in
3131
DevStack.
3232

33+
The ``lib`` directory contains sub-scripts for projects or packages that ``stack.sh``
34+
sources to perform much of the work related to those projects. These sub-scripts
35+
contain configuration defaults and functions to configure, start and stop the project
36+
or package. These variables and functions are also used by related projects,
37+
such as Grenade, to manage a DevStack installation.
38+
3339
A number of additional scripts can be found in the ``tools`` directory that may
34-
be useful in setting up special-case uses of DevStack. These include: bare metal
35-
deployment, ramdisk deployment and Jenkins integration.
40+
be useful in supporting DevStack installations. Of particular note are ``info.sh``
41+
to collect and report information about the installed system, and ``instal_prereqs.sh``
42+
that handles installation of the prerequisite packages for DevStack. It is
43+
suitable, for example, to pre-load a system for making a snapshot.
3644

3745

3846
Scripts
@@ -63,8 +71,8 @@ configuration of the user environment::
6371
source $TOP_DIR/openrc
6472

6573
``stack.sh`` is a rather large monolithic script that flows through from beginning
66-
to end. The process of breaking it down into project-level sub-scripts is nearly
67-
complete and should make ``stack.sh`` easier to read and manage.
74+
to end. It has been broken down into project-specific subscripts (as noted above)
75+
located in ``lib`` to make ``stack.sh`` more manageable and to promote code reuse.
6876

6977
These library sub-scripts have a number of fixed entry points, some of which may
7078
just be stubs. These entry points will be called by ``stack.sh`` in the
@@ -112,6 +120,7 @@ Also, variable declarations in ``stackrc`` do NOT allow overriding (the form
112120
``FOO=${FOO:-baz}``); if they did then they can already be changed in ``localrc``
113121
and can stay in the project file.
114122

123+
115124
Documentation
116125
-------------
117126

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,16 @@ In order to enable Quantum a single node setup, you'll need the following settin
120120
# Optional, to enable tempest configuration as part of devstack
121121
enable_service tempest
122122

123-
Then run stack.sh as normal.
123+
Then run `stack.sh` as normal.
124+
125+
# Tempest
124126

125127
If tempest has been successfully configured, a basic set of smoke tests can be run as follows:
126128

127129
$ cd /opt/stack/tempest
128130
$ nosetests tempest/tests/network/test_network_basic_ops.py
129131

130-
Multi-Node Setup
132+
# Multi-Node Setup
131133

132134
A more interesting setup involves running multiple compute nodes, with Quantum networks connecting VMs on different compute nodes.
133135
You should run at least one "controller node", which should have a `stackrc` that includes at least:

exercise.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ basenames=${RUN_EXERCISES:-""}
2323

2424
EXERCISE_DIR=$TOP_DIR/exercises
2525

26-
if [ -z "${basenames}" ] ; then
26+
if [[ -z "${basenames}" ]]; then
2727
# Locate the scripts we should run
2828
basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done)
2929
else
@@ -38,7 +38,7 @@ skips=""
3838

3939
# Loop over each possible script (by basename)
4040
for script in $basenames; do
41-
if [[ ,$SKIP_EXERCISES, =~ ,$script, ]] ; then
41+
if [[ ,$SKIP_EXERCISES, =~ ,$script, ]]; then
4242
skips="$skips $script"
4343
else
4444
echo "====================================================================="
@@ -48,7 +48,7 @@ for script in $basenames; do
4848
exitcode=$?
4949
if [[ $exitcode == 55 ]]; then
5050
skips="$skips $script"
51-
elif [[ $exitcode -ne 0 ]] ; then
51+
elif [[ $exitcode -ne 0 ]]; then
5252
failures="$failures $script"
5353
else
5454
passes="$passes $script"
@@ -69,6 +69,6 @@ for script in $failures; do
6969
done
7070
echo "====================================================================="
7171

72-
if [ -n "$failures" ] ; then
72+
if [[ -n "$failures" ]]; then
7373
exit 1
7474
fi

exercises/client-args.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ RETURN=0
6767
# Keystone client
6868
# ---------------
6969
if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
70-
if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
70+
if [[ "$SKIP_EXERCISES" =~ "key" ]]; then
7171
STATUS_KEYSTONE="Skipped"
7272
else
7373
echo -e "\nTest Keystone"
@@ -84,7 +84,7 @@ fi
8484
# -----------
8585

8686
if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
87-
if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
87+
if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then
8888
STATUS_NOVA="Skipped"
8989
STATUS_EC2="Skipped"
9090
else
@@ -103,7 +103,7 @@ fi
103103
# -------------
104104

105105
if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
106-
if [[ "$SKIP_EXERCISES" =~ "c-api" ]] ; then
106+
if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then
107107
STATUS_CINDER="Skipped"
108108
else
109109
echo -e "\nTest Cinder"
@@ -120,7 +120,7 @@ fi
120120
# -------------
121121

122122
if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
123-
if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
123+
if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then
124124
STATUS_GLANCE="Skipped"
125125
else
126126
echo -e "\nTest Glance"
@@ -137,7 +137,7 @@ fi
137137
# ------------
138138

139139
if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
140-
if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
140+
if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then
141141
STATUS_SWIFT="Skipped"
142142
else
143143
echo -e "\nTest Swift"
@@ -152,8 +152,9 @@ fi
152152

153153
set +o xtrace
154154

155+
155156
# Results
156-
# -------
157+
# =======
157158

158159
function report() {
159160
if [[ -n "$2" ]]; then

exercises/client-env.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ RETURN=0
6060
# Keystone client
6161
# ---------------
6262
if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
63-
if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
63+
if [[ "$SKIP_EXERCISES" =~ "key" ]]; then
6464
STATUS_KEYSTONE="Skipped"
6565
else
6666
echo -e "\nTest Keystone"
@@ -77,7 +77,7 @@ fi
7777
# -----------
7878

7979
if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
80-
if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
80+
if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then
8181
STATUS_NOVA="Skipped"
8282
STATUS_EC2="Skipped"
8383
else
@@ -111,7 +111,7 @@ fi
111111
# -------------
112112

113113
if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
114-
if [[ "$SKIP_EXERCISES" =~ "c-api" ]] ; then
114+
if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then
115115
STATUS_CINDER="Skipped"
116116
else
117117
echo -e "\nTest Cinder"
@@ -128,7 +128,7 @@ fi
128128
# -------------
129129

130130
if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
131-
if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
131+
if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then
132132
STATUS_GLANCE="Skipped"
133133
else
134134
echo -e "\nTest Glance"
@@ -146,7 +146,7 @@ fi
146146

147147

148148
if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
149-
if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
149+
if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then
150150
STATUS_SWIFT="Skipped"
151151
else
152152
echo -e "\nTest Swift"
@@ -161,8 +161,9 @@ fi
161161

162162
set +o xtrace
163163

164+
164165
# Results
165-
# -------
166+
# =======
166167

167168
function report() {
168169
if [[ -n "$2" ]]; then

functions

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ function pip_install {
830830
if [[ -z "$os_PACKAGE" ]]; then
831831
GetOSVersion
832832
fi
833-
if [[ $TRACK_DEPENDS = True ]] ; then
833+
if [[ $TRACK_DEPENDS = True ]]; then
834834
source $DEST/.venv/bin/activate
835835
CMD_PIP=$DEST/.venv/bin/pip
836836
SUDO_PIP="env"
@@ -1005,7 +1005,7 @@ function service_check() {
10051005
# Uses globals ``TRACK_DEPENDES``, ``*_proxy`
10061006
# setup_develop directory
10071007
function setup_develop() {
1008-
if [[ $TRACK_DEPENDS = True ]] ; then
1008+
if [[ $TRACK_DEPENDS = True ]]; then
10091009
SUDO_CMD="env"
10101010
else
10111011
SUDO_CMD="sudo"
@@ -1288,7 +1288,7 @@ function _ssh_check_novanet() {
12881288
local DEFAULT_INSTANCE_USER=$4
12891289
local ACTIVE_TIMEOUT=$5
12901290
local probe_cmd=""
1291-
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
1291+
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
12921292
die $LINENO "server didn't become ssh-able!"
12931293
fi
12941294
}

lib/baremetal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
XTRACE=$(set +o | grep xtrace)
5454
set +o xtrace
5555

56+
5657
# Sub-driver settings
5758
# -------------------
5859

lib/ceilometer

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ CEILOMETER_API_LOG_DIR=/var/log/ceilometer-api
3737
CEILOMETER_AUTH_CACHE_DIR=${CEILOMETER_AUTH_CACHE_DIR:-/var/cache/ceilometer}
3838

3939
# Support potential entry-points console scripts
40-
if [ -d $CEILOMETER_DIR/bin ] ; then
40+
if [[ -d $CEILOMETER_DIR/bin ]]; then
4141
CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
4242
else
4343
CEILOMETER_BIN_DIR=$(get_python_exec_prefix)
4444
fi
4545

46+
47+
# Functions
48+
# ---------
49+
4650
# cleanup_ceilometer() - Remove residual data files, anything left over from previous
4751
# runs that a clean run would need to clean up
4852
function cleanup_ceilometer() {
@@ -93,7 +97,7 @@ function configure_ceilometer() {
9397
}
9498

9599
function configure_mongodb() {
96-
if is_fedora ; then
100+
if is_fedora; then
97101
# ensure smallfiles selected to minimize freespace requirements
98102
sudo sed -i '/--smallfiles/!s/OPTIONS=\"/OPTIONS=\"--smallfiles /' /etc/sysconfig/mongod
99103

@@ -135,6 +139,7 @@ function stop_ceilometer() {
135139
done
136140
}
137141

142+
138143
# Restore xtrace
139144
$XTRACE
140145

lib/cinder

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
6464
VOLUME_GROUP2=${VOLUME_GROUP2:-stack-volumes2}
6565
VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
6666

67+
68+
# Functions
69+
# ---------
70+
6771
# _clean_volume_group removes all cinder volumes from the specified volume group
6872
# _clean_volume_group $VOLUME_GROUP $VOLUME_NAME_PREFIX
6973
function _clean_volume_group() {
@@ -432,6 +436,7 @@ function stop_cinder() {
432436
fi
433437
}
434438

439+
435440
# Restore xtrace
436441
$XTRACE
437442

lib/database

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
XTRACE=$(set +o | grep xtrace)
2121
set +o xtrace
2222

23+
2324
# Register a database backend
2425
# $1 The name of the database backend
26+
# This is required to be defined before the specific database scripts are sourced
2527
function register_database {
2628
[ -z "$DATABASE_BACKENDS" ] && DATABASE_BACKENDS=$1 || DATABASE_BACKENDS+=" $1"
2729
}
2830

2931
# Sourcing the database libs sets DATABASE_BACKENDS with the available list
30-
for f in $TOP_DIR/lib/databases/*; do source $f; done
32+
for f in $TOP_DIR/lib/databases/*; do
33+
source $f;
34+
done
3135

3236
# ``DATABASE_BACKENDS`` now contains a list of the supported databases
3337
# Look in ``ENABLED_SERVICES`` to see if one has been selected
@@ -42,6 +46,9 @@ done
4246
# This is not an error as multi-node installs will do this on the compute nodes
4347

4448

49+
# Functions
50+
# ---------
51+
4552
# Get rid of everything enough to cleanly change database backends
4653
function cleanup_database {
4754
cleanup_database_$DATABASE_TYPE
@@ -112,6 +119,7 @@ function database_connection_url {
112119
database_connection_url_$DATABASE_TYPE $var $db
113120
}
114121

122+
115123
# Restore xtrace
116124
$XTRACE
117125

0 commit comments

Comments
 (0)