if storage network disconnected, reboot the host

This commit is contained in:
Edison Su 2011-04-13 21:51:16 -04:00
parent 24737154b7
commit d8ee7d9fc3
3 changed files with 20 additions and 4 deletions

View File

@ -75,7 +75,13 @@ public class KVMHAMonitor extends KVMHABase implements Runnable{
cmd.add("-h", _hostIP); cmd.add("-h", _hostIP);
String result = cmd.execute(); String result = cmd.execute();
if (result != null) { if (result != null) {
s_logger.debug("write heartbeat failed: " + result); s_logger.debug("write heartbeat failed: " + result + "; destroy all the vms on this host");
cmd = new Script(_heartBeatPath, _heartBeatUpdateTimeout, s_logger);
cmd.add("-i", primaryStoragePool._poolIp);
cmd.add("-p", primaryStoragePool._poolMountSourcePath);
cmd.add("-m", primaryStoragePool._mountDestPath);
cmd.add("-c");
result = cmd.execute();
} }
} }
} }

View File

@ -64,6 +64,7 @@
<adapters key="com.cloud.ha.Investigator"> <adapters key="com.cloud.ha.Investigator">
<adapter name="SimpleInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator"/> <adapter name="SimpleInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator"/>
<adapter name="PingInvestigator" class="com.cloud.ha.InvestigatorImpl"/> <adapter name="PingInvestigator" class="com.cloud.ha.InvestigatorImpl"/>
<adapter name="XenServerInvestigator" class="com.cloud.ha.XenServerInvestigator"/>
</adapters> </adapters>
<adapters key="com.cloud.ha.FenceBuilder"> <adapters key="com.cloud.ha.FenceBuilder">
<adapter name="XenServerFenceBuilder" class="com.cloud.ha.XenServerFencer"/> <adapter name="XenServerFenceBuilder" class="com.cloud.ha.XenServerFencer"/>

View File

@ -24,6 +24,7 @@ help() {
-m mount point -m mount point
-h host -h host
-r write/read hb log -r write/read hb log
-c cleanup
-t interval between read hb log\n" -t interval between read hb log\n"
exit 1 exit 1
} }
@ -34,8 +35,9 @@ MountPoint=
HostIP= HostIP=
interval= interval=
rflag=0 rflag=0
cflag=0
while getopts 'i:p:m:h:t:r' OPTION while getopts 'i:p:m:h:t:rc' OPTION
do do
case $OPTION in case $OPTION in
i) i)
@ -56,6 +58,9 @@ do
t) t)
interval="$OPTARG" interval="$OPTARG"
;; ;;
c)
cflag=1
;;
*) *)
help help
;; ;;
@ -71,7 +76,7 @@ fi
#delete VMs on this mountpoint #delete VMs on this mountpoint
deleteVMs() { deleteVMs() {
local mountPoint=$1 local mountPoint=$1
vmPids=$(ps aux| grep qemu | grep $mountPoint* | awk '{print $2}' &> /dev/null) vmPids=$(ps aux| grep qemu | grep "$mountPoint" | awk '{print $2}' 2> /dev/null)
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
return return
@ -82,7 +87,7 @@ deleteVMs() {
return return
fi fi
for pid in vmPids for pid in $vmPids
do do
kill -9 $pid &> /dev/null kill -9 $pid &> /dev/null
done done
@ -149,6 +154,10 @@ then
echo "=====> DEAD <======" echo "=====> DEAD <======"
fi fi
exit 0 exit 0
elif [ "$cflag" == "1" ]
then
reboot
exit $?
else else
write_hbLog write_hbLog
exit $? exit $?