mirror of https://github.com/apache/cloudstack.git
bug 11307: Let CheckRouterAnswer() parse the return result
This commit is contained in:
parent
4bbfa2513e
commit
b987123daa
|
|
@ -17,28 +17,44 @@
|
|||
*/
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.network.router.VirtualRouter.RedundantState;
|
||||
|
||||
public class CheckRouterAnswer extends Answer {
|
||||
public static final String ROUTER_NAME = "router.name";
|
||||
public static final String ROUTER_IP = "router.ip";
|
||||
boolean isMaster;
|
||||
RedundantState state;
|
||||
|
||||
protected CheckRouterAnswer() {
|
||||
}
|
||||
|
||||
public CheckRouterAnswer(CheckRouterCommand cmd, boolean isMaster, String details) {
|
||||
public CheckRouterAnswer(CheckRouterCommand cmd, String details, boolean parse) {
|
||||
super(cmd, true, details);
|
||||
this.isMaster = isMaster;
|
||||
}
|
||||
|
||||
public CheckRouterAnswer(CheckRouterCommand cmd, String details) {
|
||||
super(cmd, false, details);
|
||||
}
|
||||
|
||||
public boolean getIsMaster() {
|
||||
return isMaster;
|
||||
if (parse) {
|
||||
parseDetails(details);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsMaster(boolean isMaster) {
|
||||
this.isMaster = isMaster;
|
||||
public CheckRouterAnswer(CheckRouterCommand cmd, String details) {
|
||||
super(cmd, false, details);
|
||||
}
|
||||
|
||||
protected void parseDetails(String details) {
|
||||
if (details.startsWith("Status: MASTER")) {
|
||||
state = RedundantState.MASTER;
|
||||
} else if (details.startsWith("Status: BACKUP")) {
|
||||
state = RedundantState.BACKUP;
|
||||
} else if (details.startsWith("Status: FAULT")) {
|
||||
state = RedundantState.FAULT;
|
||||
} else {
|
||||
state = RedundantState.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(RedundantState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public RedundantState getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -423,16 +423,16 @@ public class VirtualRoutingResource implements Manager {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected Answer execute(CheckRouterCommand cmd) {
|
||||
final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
protected Answer execute(CheckRouterCommand cmd) {
|
||||
final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
|
||||
final String result = getRouterStatus(routerPrivateIPAddress);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new CheckRouterAnswer(cmd, "CheckRouterCommand failed");
|
||||
}
|
||||
return new CheckRouterAnswer(cmd, result, true);
|
||||
}
|
||||
|
||||
final String result = getRouterStatus(routerPrivateIPAddress);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new CheckRouterAnswer(cmd, "CheckRouterCommand failed");
|
||||
}
|
||||
return new CheckRouterAnswer(cmd, result.equals("Status: MASTER"), result);
|
||||
}
|
||||
|
||||
protected Answer execute(final CheckConsoleProxyLoadCommand cmd) {
|
||||
return executeProxyLoadScan(cmd, cmd.getProxyVmId(), cmd.getProxyVmName(), cmd.getProxyManagementIp(), cmd.getProxyCmdPort());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,7 +926,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
s_logger.error(msg);
|
||||
return new CheckRouterAnswer(cmd, msg);
|
||||
}
|
||||
return new CheckRouterAnswer(cmd, result.second().startsWith("Status: MASTER"), result.second());
|
||||
return new CheckRouterAnswer(cmd, result.second(), true);
|
||||
}
|
||||
|
||||
protected Answer execute(VmDataCommand cmd) {
|
||||
|
|
|
|||
|
|
@ -1219,7 +1219,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
if (result == null || result.isEmpty()) {
|
||||
return new CheckRouterAnswer(cmd, "CheckRouterCommand failed");
|
||||
}
|
||||
return new CheckRouterAnswer(cmd, result.equals("Status: MASTER"), result);
|
||||
return new CheckRouterAnswer(cmd, result, true);
|
||||
}
|
||||
|
||||
protected MaintainAnswer execute(MaintainCommand cmd) {
|
||||
|
|
|
|||
|
|
@ -28,12 +28,5 @@ 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
|
||||
ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$domRIp "/root/checkrouter.sh"
|
||||
exit $?
|
||||
|
|
|
|||
|
|
@ -799,17 +799,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
final CheckRouterAnswer answer = (CheckRouterAnswer) _agentMgr.easySend(router.getHostId(), command);
|
||||
RedundantState state = RedundantState.UNKNOWN;
|
||||
if (answer != null && answer.getResult()) {
|
||||
if (answer.getIsMaster()) {
|
||||
state = RedundantState.MASTER;
|
||||
} else {
|
||||
if (answer.getDetails() != null) {
|
||||
if (answer.getDetails().startsWith("Status: BACKUP")) {
|
||||
state = RedundantState.BACKUP;
|
||||
} else if (answer.getDetails().startsWith("Status: FAULT")) {
|
||||
state = RedundantState.FAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
state = answer.getState();
|
||||
}
|
||||
router.setRedundantState(state);
|
||||
updated = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue