Skip to content

Commit cdf3d76

Browse files
author
Dean Troyer
committed
Add stack phases to extras.d handling
Add hooks to stack.sh, unstack.sh and clean.sh to call the extras.d scripts at multiple points in stack.sh. This allows these scripts to perform installation and startup tasks at similar times as they would if integrated into stack.sh. extras.d/70-tempest.sh is present as an example of the structure of these scripts. See extras.d/README.md for more information. Change-Id: Ic1fe522559b94d204d6c0319a2e3d23684c8d028
1 parent 13209d8 commit cdf3d76

7 files changed

Lines changed: 118 additions & 27 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ If tempest has been successfully configured, a basic set of smoke tests can be r
215215
$ cd /opt/stack/tempest
216216
$ nosetests tempest/scenario/test_network_basic_ops.py
217217

218+
# Additional Projects
219+
220+
DevStack has a hook mechanism to call out to a dispatch script at specific points in the execution if `stack.sh`, `unstack.sh` and `clean.sh`. This allows higher-level projects, especially those that the lower level projects have no dependency on, to be added to DevStack without modifying the scripts. Tempest is built this way as an example of how to structure the dispatch script, see `extras.d/80-tempest.sh`. See `extras.d/README.md` for more information.
221+
218222
# Multi-Node Setup
219223

220224
A more interesting setup involves running multiple compute nodes, with Neutron networks connecting VMs on different compute nodes.

clean.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ source $TOP_DIR/lib/neutron
4747
source $TOP_DIR/lib/baremetal
4848
source $TOP_DIR/lib/ldap
4949

50+
# Extras Source
51+
# --------------
52+
53+
# Phase: source
54+
if [[ -d $TOP_DIR/extras.d ]]; then
55+
for i in $TOP_DIR/extras.d/*.sh; do
56+
[[ -r $i ]] && source $i source
57+
done
58+
fi
5059

5160
# See if there is anything running...
5261
# need to adapt when run_service is merged
@@ -56,6 +65,16 @@ if [[ -n "$SESSION" ]]; then
5665
$TOP_DIR/unstack.sh --all
5766
fi
5867

68+
# Run extras
69+
# ==========
70+
71+
# Phase: clean
72+
if [[ -d $TOP_DIR/extras.d ]]; then
73+
for i in $TOP_DIR/extras.d/*.sh; do
74+
[[ -r $i ]] && source $i clean
75+
done
76+
fi
77+
5978
# Clean projects
6079
cleanup_oslo
6180
cleanup_cinder

extras.d/80-tempest.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
# tempest.sh - DevStack extras script
22

3-
source $TOP_DIR/lib/tempest
4-
5-
if [[ "$1" == "stack" ]]; then
6-
# Configure Tempest last to ensure that the runtime configuration of
7-
# the various OpenStack services can be queried.
8-
if is_service_enabled tempest; then
9-
echo_summary "Configuring Tempest"
3+
if is_service_enabled tempest; then
4+
if [[ "$1" == "source" ]]; then
5+
# Initial source
6+
source $TOP_DIR/lib/tempest
7+
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
8+
echo_summary "Installing Tempest"
109
install_tempest
10+
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
11+
# Tempest config must come after layer 2 services are running
12+
:
13+
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
14+
echo_summary "Initializing Tempest"
1115
configure_tempest
1216
init_tempest
1317
fi
14-
fi
1518

16-
if [[ "$1" == "unstack" ]]; then
17-
# no-op
18-
:
19-
fi
19+
if [[ "$1" == "unstack" ]]; then
20+
# no-op
21+
:
22+
fi
2023

24+
if [[ "$1" == "clean" ]]; then
25+
# no-op
26+
:
27+
fi
28+
fi
2129

extras.d/README

Lines changed: 0 additions & 14 deletions
This file was deleted.

extras.d/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Extras Hooks
2+
3+
The `extras.d` directory contains project dispatch scripts that are called
4+
at specific times by `stack.sh`, `unstack.sh` and `clean.sh`. These hooks are
5+
used to install, configure and start additional projects during a DevStack run
6+
without any modifications to the base DevStack scripts.
7+
8+
When `stack.sh` reaches one of the hook points it sources the scripts in `extras.d`
9+
that end with `.sh`. To control the order that the scripts are sourced their
10+
names start with a two digit sequence number. DevStack reserves the sequence
11+
numbers 00 through 09 and 90 through 99 for its own use.
12+
13+
The scripts are sourced at each hook point so they should not declare anything
14+
at the top level that would cause a problem, specifically, functions. This does
15+
allow the entire `stack.sh` variable space to be available. The scripts are
16+
sourced with one or more arguments, the first of which defines the hook phase:
17+
18+
arg 1: source | stack | unstack | clean
19+
20+
source: always called first in any of the scripts, used to set the
21+
initial defaults in a lib/* script or similar
22+
23+
stack: called by stack.sh. There are three possible values for
24+
the second arg to distinguish the phase stack.sh is in:
25+
26+
arg 2: install | post-config | extra
27+
28+
unstack: called by unstack.sh
29+
30+
clean: called by clean.sh. Remember, clean.sh also calls unstack.sh
31+
so that work need not be repeated.

stack.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ source $TOP_DIR/lib/ldap
313313
source $TOP_DIR/lib/ironic
314314
source $TOP_DIR/lib/trove
315315

316+
# Extras Source
317+
# --------------
318+
319+
# Phase: source
320+
if [[ -d $TOP_DIR/extras.d ]]; then
321+
for i in $TOP_DIR/extras.d/*.sh; do
322+
[[ -r $i ]] && source $i source
323+
done
324+
fi
325+
316326
# Set the destination directories for other OpenStack projects
317327
OPENSTACKCLIENT_DIR=$DEST/python-openstackclient
318328

@@ -725,6 +735,16 @@ if is_service_enabled ir-api ir-cond; then
725735
configure_ironic
726736
fi
727737

738+
# Extras Install
739+
# --------------
740+
741+
# Phase: install
742+
if [[ -d $TOP_DIR/extras.d ]]; then
743+
for i in $TOP_DIR/extras.d/*.sh; do
744+
[[ -r $i ]] && source $i stack install
745+
done
746+
fi
747+
728748
if [[ $TRACK_DEPENDS = True ]]; then
729749
$DEST/.venv/bin/pip freeze > $DEST/requires-post-pip
730750
if ! diff -Nru $DEST/requires-pre-pip $DEST/requires-post-pip > $DEST/requires.diff; then
@@ -1000,6 +1020,17 @@ if is_service_enabled nova && is_baremetal; then
10001020
fi
10011021

10021022

1023+
# Extras Configuration
1024+
# ====================
1025+
1026+
# Phase: post-config
1027+
if [[ -d $TOP_DIR/extras.d ]]; then
1028+
for i in $TOP_DIR/extras.d/*.sh; do
1029+
[[ -r $i ]] && source $i stack post-config
1030+
done
1031+
fi
1032+
1033+
10031034
# Local Configuration
10041035
# ===================
10051036

@@ -1214,9 +1245,10 @@ merge_config_group $TOP_DIR/local.conf extra
12141245
# Run extras
12151246
# ==========
12161247

1248+
# Phase: extra
12171249
if [[ -d $TOP_DIR/extras.d ]]; then
12181250
for i in $TOP_DIR/extras.d/*.sh; do
1219-
[[ -r $i ]] && source $i stack
1251+
[[ -r $i ]] && source $i stack extra
12201252
done
12211253
fi
12221254

unstack.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ source $TOP_DIR/lib/neutron
4242
source $TOP_DIR/lib/ironic
4343
source $TOP_DIR/lib/trove
4444

45+
# Extras Source
46+
# --------------
47+
48+
# Phase: source
49+
if [[ -d $TOP_DIR/extras.d ]]; then
50+
for i in $TOP_DIR/extras.d/*.sh; do
51+
[[ -r $i ]] && source $i source
52+
done
53+
fi
54+
4555
# Determine what system we are running on. This provides ``os_VENDOR``,
4656
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
4757
GetOSVersion
@@ -53,6 +63,7 @@ fi
5363
# Run extras
5464
# ==========
5565

66+
# Phase: unstack
5667
if [[ -d $TOP_DIR/extras.d ]]; then
5768
for i in $TOP_DIR/extras.d/*.sh; do
5869
[[ -r $i ]] && source $i unstack

0 commit comments

Comments
 (0)