From mboxrd@z Thu Jan 1 00:00:00 1970 From: lhh@sourceware.org Date: 19 Apr 2007 17:53:07 -0000 Subject: [Cluster-devel] cluster/rgmanager/src/resources fs.sh ip.sh nf ... Message-ID: <20070419175307.22597.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Changes by: lhh at sourceware.org 2007-04-19 18:53:05 Modified files: rgmanager/src/resources: fs.sh ip.sh nfsclient.sh vm.sh Log message: Cleanups to make the resource agents behave better (return OCF_NOT_RUNNING, for example) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/fs.sh.diff?cvsroot=cluster&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/ip.sh.diff?cvsroot=cluster&r1=1.23&r2=1.24 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/nfsclient.sh.diff?cvsroot=cluster&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/vm.sh.diff?cvsroot=cluster&r1=1.3&r2=1.4 --- cluster/rgmanager/src/resources/fs.sh 2007/04/05 15:08:20 1.21 +++ cluster/rgmanager/src/resources/fs.sh 2007/04/19 17:53:05 1.22 @@ -527,7 +527,7 @@ if [ -z "$dev" ]; then ocf_log err \ "fs (isMounted): Could not match $1 with a real device" - return $FAIL + return $OCF_ERR_ARGS fi mp=$2 @@ -939,7 +939,7 @@ ;; $NO) # not mounted, continue ;; - $FAIL) + *) return $FAIL ;; esac @@ -1149,9 +1149,6 @@ umount_failed= done=$YES ;; - $FAIL) - return $FAIL - ;; $YES) sync; sync; sync ocf_log info "unmounting $mp" @@ -1236,6 +1233,19 @@ ;; status|monitor) isMounted ${OCF_RESKEY_device} ${OCF_RESKEY_mountpoint} + case $? in + $NO) + ocf_log info "fs:${OCF_RESKEY_name}: ${OCF_RESKEY_device} is not mounted on ${OCF_RESKEY_mountpoint}" + exit $OCF_NOT_RUNNING + ;; + $YES) + ;; + *) + ocf_log err "fs:${OCF_RESKEY_name}: ${OCF_RESKEY_device} is not mounted on ${OCF_RESKEY_mountpoint}" + exit $OCF_ERR_GENERIC + ;; + esac + if [ $? -ne $YES ]; then ocf_log err "fs:${OCF_RESKEY_name}: ${OCF_RESKEY_device} is not mounted on ${OCF_RESKEY_mountpoint}" exit $OCF_ERR_GENERIC --- cluster/rgmanager/src/resources/ip.sh 2007/04/05 15:08:20 1.23 +++ cluster/rgmanager/src/resources/ip.sh 2007/04/19 17:53:05 1.24 @@ -915,7 +915,7 @@ ;; status|monitor) ip_op ${OCF_RESKEY_family} status ${OCF_RESKEY_address} - [ $? -ne 0 ] && exit $OCF_ERR_GENERIC + [ $? -ne 0 ] && exit $OCF_NOT_RUNNING check_interface_up ${OCF_RESKEY_family} ${OCF_RESKEY_address} exit $? --- cluster/rgmanager/src/resources/nfsclient.sh 2007/04/05 15:08:20 1.15 +++ cluster/rgmanager/src/resources/nfsclient.sh 2007/04/19 17:53:05 1.16 @@ -83,6 +83,15 @@ + + + + + + + + + File system ID inherited from the parent nfsexport/ @@ -323,7 +332,8 @@ rv=$? if [ $rv -ne 0 ]; then - ocf_log err "nfsclient:$OCF_RESKEY_name is missing!" + ocf_log info "nfsclient:$OCF_RESKEY_name is not running!" + exit $OCF_NOT_RUNNING fi ;; --- cluster/rgmanager/src/resources/vm.sh 2007/04/05 15:08:20 1.3 +++ cluster/rgmanager/src/resources/vm.sh 2007/04/19 17:53:05 1.4 @@ -22,6 +22,8 @@ export PATH +. $(dirname $0)/ocf-shellfuncs || exit 1 + # # Virtual Machine start/stop script (requires the xm command) # @@ -346,8 +348,28 @@ # status() { - xm list $OCF_RESKEY_name &> /dev/null - return $? + declare line + + line=$(virsh domstate $OCF_RESKEY_name) + if [ "$line" = "" ]; then + return $OCF_NOT_RUNNING + fi + + if [ "$line" = "blocked" ]; then + return $OCF_SUCCESS + elif [ "$line" = "running" ]; then + return $OCF_SUCCESS + elif [ "$line" = "in shutdown" ]; then + return $OCF_SUCCESS + elif [ "$line" = "shut off" ]; then + return $OCF_NOT_RUNNING + fi + + # + # Crashed or paused + # + + return $OCF_ERR_GENERIC }