Allow skipping exercises.
- Catch a special exit signal 55 to notify that we want to skip an
excercise.
- Move is_enabled_service to functions.
- Fix bug 928390.
Change-Id: Iebf7a6f30a0f305a2a70173fb6b988bc07e34292
diff --git a/functions b/functions
index 7fd37c0..75c20d7 100644
--- a/functions
+++ b/functions
@@ -115,6 +115,28 @@
}
+# is_service_enabled() checks if the service(s) specified as arguments are
+# enabled by the user in **ENABLED_SERVICES**.
+#
+# If there are multiple services specified as arguments the test performs a
+# boolean OR or if any of the services specified on the command line
+# return true.
+#
+# There is a special cases for some 'catch-all' services::
+# **nova** returns true if any service enabled start with **n-**
+# **glance** returns true if any service enabled start with **g-**
+# **quantum** returns true if any service enabled start with **q-**
+function is_service_enabled() {
+ services=$@
+ for service in ${services}; do
+ [[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0
+ [[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
+ [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
+ [[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
+ done
+ return 1
+}
+
# Test if the named environment variable is set and not zero length
# is_set env-var
@@ -151,4 +173,4 @@
}
# Restore xtrace
-$XTRACE
\ No newline at end of file
+$XTRACE