tell agent to reconnect to mgt server, if cancelmaintainance cmd is called

This commit is contained in:
Edison Su 2012-01-19 17:14:00 -08:00
parent 86b51dedcf
commit d9287f0e43
3 changed files with 23 additions and 3 deletions

View File

@ -483,8 +483,13 @@ public class Agent implements HandlerFactory, IAgentControl {
answer = new Answer(cmd, true, null);
} else if (cmd instanceof MaintainCommand) {
s_logger.debug("Received maintainCommand" );
cancelTasks();
_reconnectAllowed = false;
MaintainCommand maintainCmd = (MaintainCommand)cmd;
if (maintainCmd.getMaintain()) {
cancelTasks();
_reconnectAllowed = false;
} else {
_reconnectAllowed = true;
}
answer = new MaintainAnswer((MaintainCommand)cmd);
} else if (cmd instanceof ReadyCommand) {
ReadyCommand ready = (ReadyCommand)cmd;

View File

@ -18,8 +18,17 @@
package com.cloud.agent.api;
public class MaintainCommand extends Command {
private boolean _maintain;
public MaintainCommand() {
_maintain = true;
}
public void setMaintain(boolean maintain) {
_maintain = maintain;
}
public boolean getMaintain() {
return _maintain;
}
@Override

View File

@ -1570,6 +1570,12 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
return false;
}
}
if (host.getHypervisorType() == HypervisorType.KVM) {
MaintainCommand cmd = new MaintainCommand();
cmd.setMaintain(false);
easySend(hostId, cmd);
}
disconnect(hostId, Event.ResetRequested, false);
return true;
}