Browse code

Add lib/template

Add a template for the lib/* sub-scripts and a description
to HACKING.

Change-Id: Ia490de8e565982c517525e09d8941a847ba530aa

Dean Troyer authored on 2012/08/30 05:20:21
Showing 2 changed files
... ...
@@ -53,9 +53,23 @@ configuration of the user environment::
53 53
     source $TOP_DIR/openrc
54 54
 
55 55
 ``stack.sh`` is a rather large monolithic script that flows through from beginning
56
-to end.  There is a proposal to segment it to put the OpenStack projects
57
-into their own sub-scripts to better document the projects as a unit rather than
58
-have it scattered throughout ``stack.sh``.  Someday.
56
+to end.  The process of breaking it down into project-level sub-scripts has begun
57
+with the introduction of ``lib/cinder`` and ``lib/ceilometer``.
58
+
59
+These library sub-scripts have a number of fixed entry points, some of which may
60
+just be stubs.  These entry points will be called by ``stack.sh`` in the
61
+following order::
62
+
63
+    install_XXXX
64
+    configure_XXXX
65
+    init_XXXX
66
+    start_XXXX
67
+    stop_XXXX
68
+    cleanup_XXXX
69
+
70
+There is a sub-script template in ``lib/templates`` to be used in creating new
71
+service sub-scripts.  The comments in ``<>`` are meta comments describing
72
+how to use the template and should be removed.
59 73
 
60 74
 
61 75
 Documentation
62 76
new file mode 100644
... ...
@@ -0,0 +1,77 @@
0
+# lib/template
1
+# Functions to control the configuration and operation of the XXXX service
2
+# <do not include this template file in ``stack.sh``!>
3
+
4
+# Dependencies:
5
+# ``functions`` file
6
+# ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined
7
+# <list other global vars that are assumed to be defined>
8
+
9
+# ``stack.sh`` calls the entry points in this order:
10
+#
11
+# install_XXXX
12
+# configure_XXXX
13
+# init_XXXX
14
+# start_XXXX
15
+# stop_XXXX
16
+# cleanup_XXXX
17
+
18
+# Print the commands being run so that we can see the command that triggers
19
+# an error.  It is also useful for following along as the install occurs.
20
+set -o xtrace
21
+
22
+
23
+# Defaults
24
+# --------
25
+
26
+# <define global variables here that belong to this project>
27
+
28
+# Set up default directories
29
+XXXX_DIR=$DEST/XXXX
30
+XXX_CONF_DIR=/etc/XXXX
31
+
32
+
33
+# Entry Points
34
+# ------------
35
+
36
+# cleanup_XXXX() - Remove residual data files, anything left over from previous
37
+# runs that a clean run would need to clean up
38
+function cleanup_XXXX() {
39
+    # kill instances (nova)
40
+    # delete image files (glance)
41
+    # This function intentionally left blank
42
+    :
43
+}
44
+
45
+# configure_XXXX() - Set config files, create data dirs, etc
46
+function configure_XXXX() {
47
+    # sudo python setup.py deploy
48
+    # iniset $XXXX_CONF ...
49
+    # This function intentionally left blank
50
+    :
51
+}
52
+
53
+# init_XXXX() - Initialize databases, etc.
54
+function init_XXXX() {
55
+    # clean up from previous (possibly aborted) runs
56
+    # create required data files
57
+    :
58
+}
59
+
60
+# install_XXXX() - Collect source and prepare
61
+function install_XXXX() {
62
+    # git clone xxx
63
+    :
64
+}
65
+
66
+# start_XXXX() - Start running processes, including screen
67
+function start_XXXX()
68
+    # screen_it XXXX "cd $XXXX_DIR && $XXXX_DIR/bin/XXXX-bin"
69
+    :
70
+}
71
+
72
+# stop_XXXX() - Stop running processes (non-screen)
73
+function stop_XXXX() {
74
+    # FIXME(dtroyer): stop only our screen screen window?
75
+    :
76
+}