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);
String result = cmd.execute();
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">
<adapter name="SimpleInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator"/>
<adapter name="PingInvestigator" class="com.cloud.ha.InvestigatorImpl"/>
<adapter name="XenServerInvestigator" class="com.cloud.ha.XenServerInvestigator"/>
</adapters>
<adapters key="com.cloud.ha.FenceBuilder">
<adapter name="XenServerFenceBuilder" class="com.cloud.ha.XenServerFencer"/>

View File

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