From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4048 invoked by alias); 27 Mar 2009 19:07:04 -0000 Received: (qmail 4015 invoked by alias); 27 Mar 2009 19:07:04 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion.fedora.phx.redhat.com Subject: cluster: STABLE3 - cman init: introduce runwrap local function and use it To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: 4c237dd55d272ee11ba97ffd9a730a3d83ff6069 X-Git-Newrev: 388e3e47c36e49fc2a414d86b4de52b408955342 From: "Fabio M. Di Nitto" Message-Id: <20090327190635.88E0512020C@lists.fedorahosted.org> Date: Fri, 27 Mar 2009 19:07:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00947.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=388e3e47c36e49fc2a414d86b4de52b408955342 Commit: 388e3e47c36e49fc2a414d86b4de52b408955342 Parent: 4c237dd55d272ee11ba97ffd9a730a3d83ff6069 Author: Fabio M. Di Nitto AuthorDate: Wed Mar 25 15:42:50 2009 +0100 Committer: Fabio M. Di Nitto CommitterDate: Fri Mar 27 20:05:46 2009 +0100 cman init: introduce runwrap local function and use it runwrap takes in input the function to call and the message to print and does the right thing while checking return codes and inform the user. This collapse a lot of stuff within start/stop functions Signed-off-by: Fabio M. Di Nitto --- cman/init.d/cman.in | 159 ++++++++++++--------------------------------------- 1 files changed, 36 insertions(+), 123 deletions(-) diff --git a/cman/init.d/cman.in b/cman/init.d/cman.in index 801ed19..27429c7 100644 --- a/cman/init.d/cman.in +++ b/cman/init.d/cman.in @@ -268,6 +268,20 @@ cmannotifyd_enabled() esac } +runwrap() +{ + function=$1 + shift + message="$@" + + echo -n " $message... " + if $function; then + ok + else + nok + fi +} + ### the real stuff starts here load_modules() @@ -452,75 +466,16 @@ start() # required for distributions that use tmpfs for /var/run mkdir -p /var/run/cluster - echo -n " Enable Xend bridge net workaround... " - if xend_bridged_net_start; then - ok - else - nok - fi - - echo -n " Loading modules... " - if load_modules; then - ok - else - nok - fi - - echo -n " Mounting configfs... " - if start_configfs; then - ok - else - nok - fi - - echo -n " Setting network parameters... " - if set_networking_params; then - ok - else - nok - fi - - echo -n " Starting cman... " - if start_cman; then - ok - else - nok - fi - - echo -n " Unfencing self... " - if unfence_self; then - ok - else - nok - fi - - echo -n " Starting qdiskd... " - if start_qdiskd; then - ok - else - nok - fi - - echo -n " Starting daemons... " - if start_daemons; then - ok - else - nok - fi - - echo -n " Starting fencing... " - if start_fence; then - ok - else - nok - fi - - echo -n " Starting virtual machine fencing host... " - if start_fence_xvmd; then - ok - else - nok - fi + runwrap xend_bridged_net_start "Enable Xend bridge net workaround" + runwrap load_modules "Loading modules" + runwrap start_configfs "Mounting configfs" + runwrap set_networking_params "Setting network parameters" + runwrap start_cman "Starting cman" + runwrap unfence_self "Unfencing self" + runwrap start_qdiskd "Starting qdiskd" + runwrap start_daemons "Starting daemons" + runwrap start_fence "Starting fencing" + runwrap start_fence_xvmd "Starting virtual machine fencing host" return 0 } @@ -541,7 +496,7 @@ stop_cman() { if cman_running; then errmsg=$( @SBINDIR@/cman_tool -t $CMAN_SHUTDOWN_TIMEOUT \ - -w leave $1 2>&1 ) || return 1 + -w leave $cmanremove 2>&1 ) || return 1 fi return 0 # all ok } @@ -624,58 +579,14 @@ stop() { echo "Stopping cluster: " - echo -n " Stopping virtual machine fencing host... " - if stop_fence_xvmd; then - ok - else - nok - fi - - echo -n " Stopping fencing... " - if stop_fence; then - ok - else - nok - fi - - echo -n " Stopping daemons... " - if stop_daemons; then - ok - else - nok - fi - - echo -n " Stopping qdiskd... " - if stop_qdiskd; then - ok - else - nok - fi - - echo -n " Stopping cman... " - if stop_cman "$1"; then - ok - else - nok - fi - - echo -n " Stopping cmannotifyd... " - if stop_cmannotifyd; then - ok - else - nok - fi - - echo -n " Unloading modules..." - unload_modules - ok - - echo -n " Unmounting configfs... " - if stop_configfs; then - ok - else - nok - fi + runwrap stop_fence_xvmd "Stopping virtual machine fencing host" + runwrap stop_fence "Stopping fencing" + runwrap stop_daemons "Stopping daemons" + runwrap stop_qdiskd "Stopping qdiskd" + runwrap stop_cman "Stopping cman" + runwrap stop_cmannotifyd "Stopping cmannotifyd" + runwrap unload_modules "Unloading modules" + runwrap stop_configfs "Unmounting configfs" return 0 } @@ -720,6 +631,7 @@ start) fi ;; stop) + cmanremove="" if stop; then rm -f $LOCK_FILE else @@ -729,7 +641,8 @@ stop) ;; restart|reload) echo -n "Restarting cluster: " - if stop remove > /dev/null 2>&1 && \ + cmanremove=remove + if stop > /dev/null 2>&1 && \ start > /dev/null 2>&1; then ok else