We add a second category of daemons in daemon-util, those that are
started on demand and should not be started by the start_all action, but
should be stopped during service shutdown. This category currently
includes metad and kvmd.

To this end we introduce two more array variables:

 - ON_DEMAND_DAEMONS: currently holds kvmd and metad, which should only
   be stopped during stop-all.

 - ALL_DAEMONS: is the union of DAEMONS and ON_DEMAND_DAEMONS, i.e. the
   list of all known daemons.

We also change the daemon-util test to expect kvmd and metad in the stop
daemon list.

Signed-off-by: Apollon Oikonomopoulos <[email protected]>
---
 daemons/daemon-util.in            | 19 +++++++++++++------
 test/py/daemon-util_unittest.bash |  4 +++-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in
index 37ca0f1..df1510c 100644
--- a/daemons/daemon-util.in
+++ b/daemons/daemon-util.in
@@ -31,11 +31,17 @@ DAEMONS=(
   ganeti-wconfd
   ganeti-noded
   ganeti-masterd
-  ganeti-metad
   ganeti-rapi
   ganeti-luxid
   )
 
+# This is the list of daemons that are loaded on demand; they should only be
+# stopped, not started.
+ON_DEMAND_DAEMONS=(
+  ganeti-metad
+  ganeti-kvmd
+  )
+
 _confd_enabled() {
   [[ "@CUSTOM_ENABLE_CONFD@" == True ]]
 }
@@ -52,6 +58,9 @@ if _mond_enabled; then
   DAEMONS+=( ganeti-mond )
 fi
 
+# The full list of all daemons we know about
+ALL_DAEMONS=( ${DAEMONS[@]} ${ON_DEMAND_DAEMONS[@]} )
+
 NODED_ARGS=
 MASTERD_ARGS=
 CONFD_ARGS=
@@ -175,15 +184,13 @@ list_start_daemons() {
   local name
 
   for name in "${DAEMONS[@]}"; do
-    if [[ "$name" != ganeti-metad ]]; then
-      echo "$name"
-    fi
+    echo "$name"
   done
 }
 
 # Prints a list of all daemons in the order in which they should be stopped
 list_stop_daemons() {
-  for name in "${DAEMONS[@]}"; do
+  for name in "${ALL_DAEMONS[@]}"; do
     echo "$name"
   done | tac
 }
@@ -197,7 +204,7 @@ is_daemon_name() {
 
   local name="$1"; shift
 
-  for i in "${DAEMONS[@]}"; do
+  for i in "${ALL_DAEMONS[@]}"; do
     if [[ "$i" == "$name" ]]; then
       return 0
     fi
diff --git a/test/py/daemon-util_unittest.bash 
b/test/py/daemon-util_unittest.bash
index 2354a28..dd8600e 100755
--- a/test/py/daemon-util_unittest.bash
+++ b/test/py/daemon-util_unittest.bash
@@ -37,7 +37,7 @@ if ! grep -q '^ENABLE_MOND = ' lib/_constants.py; then
 fi
 
 DAEMONS_LIST="wconfd noded masterd rapi luxid"
-STOPDAEMONS_LIST="luxid rapi metad masterd noded wconfd"
+STOPDAEMONS_LIST="luxid rapi masterd noded wconfd"
 
 if grep -q '^ENABLE_CONFD = True' lib/_constants.py; then
   DAEMONS_LIST="$DAEMONS_LIST confd"
@@ -49,6 +49,8 @@ if grep -q '^ENABLE_MOND = True' lib/_constants.py; then
   STOPDAEMONS_LIST="mond $STOPDAEMONS_LIST"
 fi
 
+STOPDAEMONS_LIST="kvmd metad $STOPDAEMONS_LIST"
+
 DAEMONS=$(echo $(for d in $DAEMONS_LIST; do echo "ganeti-$d"; done))
 STOPDAEMONS=$(echo $(for d in $STOPDAEMONS_LIST; do echo "ganeti-$d"; done))
 
-- 
1.9.2

Reply via email to