Browse code

Merge "refactor zookeeper into a slightly more generic dlm module"

Jenkins authored on 2015/11/14 00:41:24
Showing 5 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,108 @@
0
+#!/bin/bash
1
+#
2
+# lib/dlm
3
+#
4
+# Functions to control the installation and configuration of software
5
+# that provides a dlm (and possibly other functions). The default is
6
+# **zookeeper**, and is going to be the only backend supported in the
7
+# devstack tree.
8
+
9
+# Dependencies:
10
+#
11
+# - ``functions`` file
12
+
13
+# ``stack.sh`` calls the entry points in this order:
14
+#
15
+# - is_dlm_enabled
16
+# - install_dlm
17
+# - configure_dlm
18
+# - cleanup_dlm
19
+
20
+# Save trace setting
21
+XTRACE=$(set +o | grep xtrace)
22
+set +o xtrace
23
+
24
+
25
+# Defaults
26
+# --------
27
+
28
+# <define global variables here that belong to this project>
29
+
30
+# Set up default directories
31
+ZOOKEEPER_DATA_DIR=$DEST/data/zookeeper
32
+ZOOKEEPER_CONF_DIR=/etc/zookeeper
33
+
34
+
35
+# Entry Points
36
+# ------------
37
+#
38
+# NOTE(sdague): it is expected that when someone wants to implement
39
+# another one of these out of tree, they'll implement the following
40
+# functions:
41
+#
42
+# - dlm_backend
43
+# - install_dlm
44
+# - configure_dlm
45
+# - cleanup_dlm
46
+
47
+# This should be declared in the settings file of any plugin or
48
+# service that needs to have a dlm in their enviroment.
49
+function use_dlm {
50
+    enable_service $(dlm_backend)
51
+}
52
+
53
+# A function to return the name of the backend in question, some users
54
+# are going to need to know this.
55
+function dlm_backend {
56
+    echo "zookeeper"
57
+}
58
+
59
+# Test if a dlm is enabled (defaults to a zookeeper specific check)
60
+function is_dlm_enabled {
61
+    [[ ,${ENABLED_SERVICES}, =~ ,"$(dlm_backend)", ]] && return 0
62
+    return 1
63
+}
64
+
65
+# cleanup_dlm() - Remove residual data files, anything left over from previous
66
+# runs that a clean run would need to clean up
67
+function cleanup_dlm {
68
+    # NOTE(sdague): we don't check for is_enabled here because we
69
+    # should just delete this regardless. Some times users updated
70
+    # their service list before they run cleanup.
71
+    sudo rm -rf $ZOOKEEPER_DATA_DIR
72
+}
73
+
74
+# configure_dlm() - Set config files, create data dirs, etc
75
+function configure_dlm {
76
+    if is_dlm_enabled; then
77
+        sudo cp $FILES/zookeeper/* $ZOOKEEPER_CONF_DIR
78
+        sudo sed -i -e 's|.*dataDir.*|dataDir='$ZOOKEEPER_DATA_DIR'|' $ZOOKEEPER_CONF_DIR/zoo.cfg
79
+        # clean up from previous (possibly aborted) runs
80
+        # create required data files
81
+        sudo rm -rf $ZOOKEEPER_DATA_DIR
82
+        sudo mkdir -p $ZOOKEEPER_DATA_DIR
83
+        # restart after configuration, there is no reason to make this
84
+        # another step, because having data files that don't match the
85
+        # zookeeper running is just going to cause tears.
86
+        restart_service zookeeper
87
+    fi
88
+}
89
+
90
+# install_dlm() - Collect source and prepare
91
+function install_dlm {
92
+    if is_dlm_enabled; then
93
+        if is_ubuntu; then
94
+            install_package zookeeperd
95
+        else
96
+            die $LINENO "Don't know how to install zookeeper on this platform"
97
+        fi
98
+    fi
99
+}
100
+
101
+# Restore xtrace
102
+$XTRACE
103
+
104
+# Tell emacs to use shell-script-mode
105
+## Local variables:
106
+## mode: shell-script
107
+## End:
0 108
deleted file mode 100644
... ...
@@ -1,91 +0,0 @@
1
-#!/bin/bash
2
-#
3
-# lib/zookeeper
4
-# Functions to control the installation and configuration of **zookeeper**
5
-
6
-# Dependencies:
7
-#
8
-# - ``functions`` file
9
-
10
-# ``stack.sh`` calls the entry points in this order:
11
-#
12
-# - is_zookeeper_enabled
13
-# - install_zookeeper
14
-# - configure_zookeeper
15
-# - init_zookeeper
16
-# - start_zookeeper
17
-# - stop_zookeeper
18
-# - cleanup_zookeeper
19
-
20
-# Save trace setting
21
-XTRACE=$(set +o | grep xtrace)
22
-set +o xtrace
23
-
24
-
25
-# Defaults
26
-# --------
27
-
28
-# <define global variables here that belong to this project>
29
-
30
-# Set up default directories
31
-ZOOKEEPER_DATA_DIR=$DEST/data/zookeeper
32
-ZOOKEEPER_CONF_DIR=/etc/zookeeper
33
-
34
-
35
-# Entry Points
36
-# ------------
37
-
38
-# Test if any zookeeper service us enabled
39
-# is_zookeeper_enabled
40
-function is_zookeeper_enabled {
41
-    [[ ,${ENABLED_SERVICES}, =~ ,"zookeeper", ]] && return 0
42
-    return 1
43
-}
44
-
45
-# cleanup_zookeeper() - Remove residual data files, anything left over from previous
46
-# runs that a clean run would need to clean up
47
-function cleanup_zookeeper {
48
-    sudo rm -rf $ZOOKEEPER_DATA_DIR
49
-}
50
-
51
-# configure_zookeeper() - Set config files, create data dirs, etc
52
-function configure_zookeeper {
53
-    sudo cp $FILES/zookeeper/* $ZOOKEEPER_CONF_DIR
54
-    sudo sed -i -e 's|.*dataDir.*|dataDir='$ZOOKEEPER_DATA_DIR'|' $ZOOKEEPER_CONF_DIR/zoo.cfg
55
-}
56
-
57
-# init_zookeeper() - Initialize databases, etc.
58
-function init_zookeeper {
59
-    # clean up from previous (possibly aborted) runs
60
-    # create required data files
61
-    sudo rm -rf $ZOOKEEPER_DATA_DIR
62
-    sudo mkdir -p $ZOOKEEPER_DATA_DIR
63
-}
64
-
65
-# install_zookeeper() - Collect source and prepare
66
-function install_zookeeper {
67
-    install_package zookeeperd
68
-}
69
-
70
-# start_zookeeper() - Start running processes, including screen
71
-function start_zookeeper {
72
-    # Starting twice Zookeeper on Ubuntu exits with error code 1. See LP#1513741
73
-    # Match both systemd and sysvinit output
74
-    local running="(active \(running\)|start/running)"
75
-    if ! is_ubuntu || ! sudo /usr/sbin/service zookeeper status | egrep -q "$running"; then
76
-        start_service zookeeper
77
-    fi
78
-}
79
-
80
-# stop_zookeeper() - Stop running processes (non-screen)
81
-function stop_zookeeper {
82
-    stop_service zookeeper
83
-}
84
-
85
-# Restore xtrace
86
-$XTRACE
87
-
88
-# Tell emacs to use shell-script-mode
89
-## Local variables:
90
-## mode: shell-script
91
-## End:
... ...
@@ -557,7 +557,7 @@ source $TOP_DIR/lib/heat
557 557
 source $TOP_DIR/lib/neutron-legacy
558 558
 source $TOP_DIR/lib/ldap
559 559
 source $TOP_DIR/lib/dstat
560
-source $TOP_DIR/lib/zookeeper
560
+source $TOP_DIR/lib/dlm
561 561
 
562 562
 # Extras Source
563 563
 # --------------
... ...
@@ -742,11 +742,10 @@ run_phase stack pre-install
742 742
 
743 743
 install_rpc_backend
744 744
 
745
-if is_service_enabled zookeeper; then
746
-    cleanup_zookeeper
747
-    configure_zookeeper
748
-    init_zookeeper
749
-fi
745
+# NOTE(sdague): dlm install is conditional on one being enabled by configuration
746
+install_dlm
747
+configure_dlm
748
+
750 749
 if is_service_enabled $DATABASE_BACKENDS; then
751 750
     install_database
752 751
 fi
... ...
@@ -986,15 +985,6 @@ save_stackenv $LINENO
986 986
 start_dstat
987 987
 
988 988
 
989
-# Zookeeper
990
-# -----
991
-
992
-# zookeeper for use with tooz for Distributed Lock Management capabilities etc.,
993
-if is_service_enabled zookeeper; then
994
-    start_zookeeper
995
-fi
996
-
997
-
998 989
 # Keystone
999 990
 # --------
1000 991
 
... ...
@@ -69,7 +69,7 @@ if ! isset ENABLED_SERVICES ; then
69 69
     # Dashboard
70 70
     ENABLED_SERVICES+=,horizon
71 71
     # Additional services
72
-    ENABLED_SERVICES+=,rabbit,tempest,mysql,dstat,zookeeper
72
+    ENABLED_SERVICES+=,rabbit,tempest,mysql,dstat
73 73
 fi
74 74
 
75 75
 # SQLAlchemy supports multiple database drivers for each database server
... ...
@@ -69,7 +69,7 @@ source $TOP_DIR/lib/heat
69 69
 source $TOP_DIR/lib/neutron-legacy
70 70
 source $TOP_DIR/lib/ldap
71 71
 source $TOP_DIR/lib/dstat
72
-source $TOP_DIR/lib/zookeeper
72
+source $TOP_DIR/lib/dlm
73 73
 
74 74
 # Extras Source
75 75
 # --------------