mirror of https://github.com/apache/cloudstack.git
Fix CheckRouterAnswer's isMaster report
If we got invalid/unsuccessed answer from CheckRouterAnswer, set master to false. Also add missed scripts.
This commit is contained in:
parent
8542c9ca13
commit
5db86e6c20
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
tail -n 1 /root/keepalived.log | grep "Status"
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
printf "Usage:\n %s <domR eth1 ip> \n" $(basename $0) >&2
|
||||
printf " %s <domR eth1 ip> \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
cert="/root/.ssh/id_rsa.cloud"
|
||||
domRIp=$1
|
||||
shift
|
||||
|
||||
# check if gateway domain is up and running
|
||||
check_gw() {
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
sleep 1
|
||||
ping -c 1 -n -q $1 > /dev/null
|
||||
fi
|
||||
return $?;
|
||||
}
|
||||
|
||||
|
||||
# Check if DomR is up and running. If not, exit with error code 1.
|
||||
check_gw "$domRIp"
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmpfile=/tmp/$RANDOM.log
|
||||
|
||||
scp -P 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp:/root/keepalived.log $tmpfile
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
exit $?
|
||||
fi
|
||||
result=`tail $tmpfile -n 1`
|
||||
echo $result
|
||||
|
|
@ -725,18 +725,24 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
final CheckRouterAnswer answer = (CheckRouterAnswer) _agentMgr.easySend(router.getHostId(), command);
|
||||
if (answer != null) {
|
||||
router.setIsMaster(answer.getIsMaster());
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
try {
|
||||
txn.start();
|
||||
_routerDao.update(router.getId(), router);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
s_logger.warn("Unable to update router status for account: " + router.getAccountId());
|
||||
} finally {
|
||||
txn.close();
|
||||
if (answer.getResult()) {
|
||||
router.setIsMaster(answer.getIsMaster());
|
||||
} else {
|
||||
router.setIsMaster(false);
|
||||
}
|
||||
} else {
|
||||
router.setIsMaster(false);
|
||||
}
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
try {
|
||||
txn.start();
|
||||
_routerDao.update(router.getId(), router);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
s_logger.warn("Unable to update router status for account: " + router.getAccountId());
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue