Browse code

Merge "Begin is_service_enabled() cleanup"

Jenkins authored on 2014/02/12 16:19:11
Showing 16 changed files
... ...
@@ -97,7 +97,7 @@ if is_service_enabled ldap; then
97 97
 fi
98 98
 
99 99
 # Do the hypervisor cleanup until this can be moved back into lib/nova
100
-if [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
100
+if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
101 101
     cleanup_nova_hypervisor
102 102
 fi
103 103
 
... ...
@@ -30,14 +30,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
30 30
 # Import common functions
31 31
 source $TOP_DIR/functions
32 32
 
33
+# Import project functions
34
+source $TOP_DIR/lib/cinder
35
+
33 36
 # Import configuration
34 37
 source $TOP_DIR/openrc
35 38
 
36
-# Import neutron functions if needed
37
-if is_service_enabled neutron; then
38
-    source $TOP_DIR/lib/neutron
39
-fi
40
-
41 39
 # Import exercise configuration
42 40
 source $TOP_DIR/exerciserc
43 41
 
... ...
@@ -33,11 +33,6 @@ source $TOP_DIR/functions
33 33
 # Import EC2 configuration
34 34
 source $TOP_DIR/eucarc
35 35
 
36
-# Import neutron functions if needed
37
-if is_service_enabled neutron; then
38
-    source $TOP_DIR/lib/neutron
39
-fi
40
-
41 36
 # Import exercise configuration
42 37
 source $TOP_DIR/exerciserc
43 38
 
... ...
@@ -27,14 +27,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
27 27
 # Import common functions
28 28
 source $TOP_DIR/functions
29 29
 
30
+# Import project functions
31
+source $TOP_DIR/lib/neutron
32
+
30 33
 # Import configuration
31 34
 source $TOP_DIR/openrc
32 35
 
33
-# Import neutron functions if needed
34
-if is_service_enabled neutron; then
35
-    source $TOP_DIR/lib/neutron
36
-fi
37
-
38 36
 # Import exercise configuration
39 37
 source $TOP_DIR/exerciserc
40 38
 
... ...
@@ -27,14 +27,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
27 27
 # Import common functions
28 28
 source $TOP_DIR/functions
29 29
 
30
+# Import project functions
31
+source $TOP_DIR/lib/cinder
32
+
30 33
 # Import configuration
31 34
 source $TOP_DIR/openrc
32 35
 
33
-# Import neutron functions if needed
34
-if is_service_enabled neutron; then
35
-    source $TOP_DIR/lib/neutron
36
-fi
37
-
38 36
 # Import exercise configuration
39 37
 source $TOP_DIR/exerciserc
40 38
 
... ...
@@ -840,6 +840,16 @@ function is_service_enabled() {
840 840
     services=$@
841 841
     for service in ${services}; do
842 842
         [[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0
843
+
844
+        # Look for top-level 'enabled' function for this service
845
+        if type is_${service}_enabled >/dev/null 2>&1; then
846
+            # A function exists for this service, use it
847
+            is_${service}_enabled
848
+            return $?
849
+        fi
850
+
851
+        # TODO(dtroyer): Remove these legacy special-cases after the is_XXX_enabled()
852
+        #                are implemented
843 853
         [[ ${service} == n-cell-* && ${ENABLED_SERVICES} =~ "n-cell" ]] && return 0
844 854
         [[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
845 855
         [[ ${service} == "cinder" && ${ENABLED_SERVICES} =~ "c-" ]] && return 0
... ...
@@ -59,7 +59,14 @@ TEMPEST_SERVICES+=,ceilometer
59 59
 
60 60
 # Functions
61 61
 # ---------
62
-#
62
+
63
+# Test if any Ceilometer services are enabled
64
+# is_ceilometer_enabled
65
+function is_ceilometer_enabled {
66
+    [[ ,${ENABLED_SERVICES} =~ ,"ceilometer-" ]] && return 0
67
+    return 1
68
+}
69
+
63 70
 # create_ceilometer_accounts() - Set up common required ceilometer accounts
64 71
 
65 72
 create_ceilometer_accounts() {
... ...
@@ -85,6 +85,14 @@ TEMPEST_SERVICES+=,cinder
85 85
 
86 86
 # Functions
87 87
 # ---------
88
+
89
+# Test if any Cinder services are enabled
90
+# is_cinder_enabled
91
+function is_cinder_enabled {
92
+    [[ ,${ENABLED_SERVICES} =~ ,"c-" ]] && return 0
93
+    return 1
94
+}
95
+
88 96
 # _clean_lvm_lv removes all cinder LVM volumes
89 97
 #
90 98
 # Usage: _clean_lvm_lv $VOLUME_GROUP $VOLUME_NAME_PREFIX
... ...
@@ -59,6 +59,13 @@ TEMPEST_SERVICES+=,glance
59 59
 # Functions
60 60
 # ---------
61 61
 
62
+# Test if any Glance services are enabled
63
+# is_glance_enabled
64
+function is_glance_enabled {
65
+    [[ ,${ENABLED_SERVICES} =~ ,"g-" ]] && return 0
66
+    return 1
67
+}
68
+
62 69
 # cleanup_glance() - Remove residual data files, anything left over from previous
63 70
 # runs that a clean run would need to clean up
64 71
 function cleanup_glance() {
... ...
@@ -244,6 +244,13 @@ TEMPEST_SERVICES+=,neutron
244 244
 # Functions
245 245
 # ---------
246 246
 
247
+# Test if any Neutron services are enabled
248
+# is_neutron_enabled
249
+function is_neutron_enabled {
250
+    [[ ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0
251
+    return 1
252
+}
253
+
247 254
 # configure_neutron()
248 255
 # Set common config for all neutron server and agents.
249 256
 function configure_neutron() {
... ...
@@ -129,6 +129,20 @@ TEMPEST_SERVICES+=,nova
129 129
 # Functions
130 130
 # ---------
131 131
 
132
+# Test if any Nova services are enabled
133
+# is_nova_enabled
134
+function is_nova_enabled {
135
+    [[ ,${ENABLED_SERVICES} =~ ,"n-" ]] && return 0
136
+    return 1
137
+}
138
+
139
+# Test if any Nova Cell services are enabled
140
+# is_nova_enabled
141
+function is_n-cell_enabled {
142
+    [[ ,${ENABLED_SERVICES} =~ ,"n-cell-" ]] && return 0
143
+    return 1
144
+}
145
+
132 146
 # Helper to clean iptables rules
133 147
 function clean_iptables() {
134 148
     # Delete rules
... ...
@@ -118,6 +118,13 @@ TEMPEST_SERVICES+=,swift
118 118
 # Functions
119 119
 # ---------
120 120
 
121
+# Test if any Swift services are enabled
122
+# is_swift_enabled
123
+function is_swift_enabled {
124
+    [[ ,${ENABLED_SERVICES} =~ ,"s-" ]] && return 0
125
+    return 1
126
+}
127
+
121 128
 # cleanup_swift() - Remove residual data files
122 129
 function cleanup_swift() {
123 130
     rm -f ${SWIFT_CONF_DIR}{*.builder,*.ring.gz,backups/*.builder,backups/*.ring.gz}
... ...
@@ -10,6 +10,7 @@
10 10
 
11 11
 # ``stack.sh`` calls the entry points in this order:
12 12
 #
13
+# - is_XXXX_enabled
13 14
 # - install_XXXX
14 15
 # - configure_XXXX
15 16
 # - init_XXXX
... ...
@@ -35,6 +36,13 @@ XXX_CONF_DIR=/etc/XXXX
35 35
 # Entry Points
36 36
 # ------------
37 37
 
38
+# Test if any XXXX services are enabled
39
+# is_XXXX_enabled
40
+function is_XXXX_enabled {
41
+    [[ ,${ENABLED_SERVICES} =~ ,"XX-" ]] && return 0
42
+    return 1
43
+}
44
+
38 45
 # cleanup_XXXX() - Remove residual data files, anything left over from previous
39 46
 # runs that a clean run would need to clean up
40 47
 function cleanup_XXXX() {
... ...
@@ -1085,7 +1085,7 @@ if is_service_enabled s-proxy; then
1085 1085
 fi
1086 1086
 
1087 1087
 # Launch the Glance services
1088
-if is_service_enabled g-api g-reg; then
1088
+if is_service_enabled glance; then
1089 1089
     echo_summary "Starting Glance"
1090 1090
     start_glance
1091 1091
 fi
... ...
@@ -35,7 +35,7 @@ fi
35 35
 #  enable_service neutron
36 36
 #  # Optional, to enable tempest configuration as part of devstack
37 37
 #  enable_service tempest
38
-ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,cinder,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,rabbit,tempest,mysql
38
+ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,rabbit,tempest,mysql
39 39
 
40 40
 # Tell Tempest which services are available.  The default is set here as
41 41
 # Tempest falls late in the configuration sequence.  This differs from
... ...
@@ -103,7 +103,7 @@ if is_service_enabled nova; then
103 103
     stop_nova
104 104
 fi
105 105
 
106
-if is_service_enabled g-api g-reg; then
106
+if is_service_enabled glance; then
107 107
     stop_glance
108 108
 fi
109 109