From 2250afb3a4aaa7392822516f8d75c0c206a33eee Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Thu, 11 Mar 2010 17:16:28 +0100
Subject: [PATCH] daemon-util: Add function to start and stop all daemons
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is, to some degree, duplicated code from the init script. However,
the init script has to conform to standards of the underlying Linux
distributions, while these functions will be called by Ganeti itself. By
moving more code into daemon-util, the amount of duplication has been
reduced.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 daemons/daemon-util.in | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in
index ea2bd5f41..3cee400c9 100755
--- a/daemons/daemon-util.in
+++ b/daemons/daemon-util.in
@@ -185,6 +185,30 @@ stop_master() {
   stop ganeti-masterd
 }
 
+# Start all daemons
+start_all() {
+  for i in $(list_start_daemons); do
+    local rc=0
+
+    # Try to start daemon
+    start $i || rc=$?
+
+    if ! errmsg=$(check_exitcode $rc); then
+      echo "$errmsg" >&2
+      return 1
+    fi
+  done
+
+  return 0
+}
+
+# Stop all daemons
+stop_all() {
+  for i in $(list_stop_daemons); do
+    stop $i
+  done
+}
+
 # Reloads the SSH keys
 reload_ssh_keys() {
   @RPL_SSH_INITD_SCRIPT@ restart
-- 
GitLab