# HG changeset patch
# User Florian Haas <[email protected]>
# Date 1287508227 -7200
# Node ID 3f4c98a0c37915877baee2d970b8051f0a4cef7b
# Parent  8c88afdf27b0de507ce409af74312f5cd92eed66
Low: ManageVE: clean up start action

Invoke status before start, this removes the need for checking
for the 32 exit code (VE already running) on start.
Use ocf_run.

diff -r 8c88afdf27b0 -r 3f4c98a0c379 heartbeat/ManageVE
--- a/heartbeat/ManageVE        Mon Oct 18 07:47:56 2010 +0200
+++ b/heartbeat/ManageVE        Tue Oct 19 19:10:27 2010 +0200
@@ -103,39 +103,16 @@
 #
 # start_ve()
 #
-# ATTENTION: The following code relies on vzctl's exit codes, especially:
-#
-#   0 : success
-#  32 : VE already running
-#
-# In case any of those exit codes change, this function will need fixing.
+# Starts a VE, or simply logs a message if the VE is already running.
 #
 start_ve()
 {
-  declare -i retcode
-
-  veexists=`$VZCTL status $VEID 2>/dev/null | $AWK '{print $3}'`
-  if [[ $veexists != "exist" ]]; then
-    ocf_log err "vzctl status $VEID returned: $VEID does not exist."
-    exit $OCF_ERR_INSTALLED
+  if status_ve; then
+       ocf_log info "VE $VEID already running."
+       return $OCF_SUCCESS
   fi
 
-  status_ve
-  retcode=$?
-
-  if [[ $retcode == $OCF_SUCCESS ]]; then
-    return $OCF_SUCCESS
-  elif [[ $retcode != $OCF_NOT_RUNNING ]]; then
-    return $retcode
-  fi
-
-  $VZCTL start $VEID >& /dev/null
-  retcode=$?
-
-  if [[ $retcode != 0 && $retcode != 32 ]]; then
-    ocf_log err "vzctl start $VEID returned: $retcode"
-    exit $OCF_ERR_GENERIC
-  fi
+  ocf_run $VZCTL start $VEID || exit $OCF_ERR_GENERIC
 
   return $OCF_SUCCESS
 }


_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to