mirror of https://github.com/apache/cloudstack.git
Implementing Migration and Maintenance mode for the simulator
This commit is contained in:
parent
befd6dd0c6
commit
87bcd8e116
|
|
@ -50,11 +50,11 @@ public interface MockAgentManager extends Manager {
|
|||
Answer checkHealth(CheckHealthCommand cmd);
|
||||
Answer pingTest(PingTestCommand cmd);
|
||||
|
||||
Answer PrepareForMigration(PrepareForMigrationCommand cmd);
|
||||
Answer prepareForMigrate(PrepareForMigrationCommand cmd);
|
||||
|
||||
MockHost getHost(String guid);
|
||||
|
||||
Answer MaintainCommand(MaintainCommand cmd);
|
||||
Answer maintain(MaintainCommand cmd);
|
||||
|
||||
Answer checkNetworkCommand(CheckNetworkCommand cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,10 +45,9 @@ import com.cloud.agent.api.MaintainAnswer;
|
|||
import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.resource.AgentResourceBase;
|
||||
import com.cloud.resource.AgentRoutingResource;
|
||||
import com.cloud.resource.AgentStorageResource;
|
||||
|
|
@ -340,7 +339,11 @@ public class MockAgentManagerImpl implements MockAgentManager {
|
|||
|
||||
|
||||
@Override
|
||||
public PrepareForMigrationAnswer PrepareForMigration(PrepareForMigrationCommand cmd) {
|
||||
public PrepareForMigrationAnswer prepareForMigrate(PrepareForMigrationCommand cmd) {
|
||||
VirtualMachineTO vm = cmd.getVirtualMachine();
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Preparing host for migrating " + vm);
|
||||
}
|
||||
return new PrepareForMigrationAnswer(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -364,7 +367,7 @@ public class MockAgentManagerImpl implements MockAgentManager {
|
|||
|
||||
|
||||
@Override
|
||||
public MaintainAnswer MaintainCommand(com.cloud.agent.api.MaintainCommand cmd) {
|
||||
public MaintainAnswer maintain(com.cloud.agent.api.MaintainCommand cmd) {
|
||||
return new MaintainAnswer(cmd);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public interface MockVmManager extends Manager {
|
|||
public Answer stopVM(StopCommand cmd);
|
||||
public Answer rebootVM(RebootCommand cmd);
|
||||
|
||||
public Answer checkVmState(CheckVirtualMachineCommand cmd, String hostGuid);
|
||||
public Answer checkVmState(CheckVirtualMachineCommand cmd);
|
||||
public Map<String, State> getVmStates(String hostGuid);
|
||||
public Answer getVncPort(GetVncPortCommand cmd);
|
||||
|
||||
|
|
|
|||
|
|
@ -243,8 +243,8 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CheckVirtualMachineAnswer checkVmState(CheckVirtualMachineCommand cmd, String hostGuid) {
|
||||
MockVMVO vm = _mockVmDao.findByVmNameAndHost(cmd.getVmName(), hostGuid);
|
||||
public CheckVirtualMachineAnswer checkVmState(CheckVirtualMachineCommand cmd) {
|
||||
MockVMVO vm = _mockVmDao.findByVmName(cmd.getVmName());
|
||||
if (vm == null) {
|
||||
return new CheckVirtualMachineAnswer(cmd, "can't find vm:" + cmd.getVmName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.cloud.agent.api.CheckVirtualMachineCommand;
|
|||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
|
||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
import com.cloud.agent.api.ReadyAnswer;
|
||||
import com.cloud.agent.api.ReadyCommand;
|
||||
|
|
@ -85,8 +86,6 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
return execute((StartCommand) cmd);
|
||||
} else if (cmd instanceof StopCommand) {
|
||||
return execute((StopCommand) cmd);
|
||||
} else if (cmd instanceof PrepareForMigrationCommand) {
|
||||
return execute((PrepareForMigrationCommand) cmd);
|
||||
} else if (cmd instanceof CheckVirtualMachineCommand) {
|
||||
return execute((CheckVirtualMachineCommand) cmd);
|
||||
} else if (cmd instanceof ReadyCommand) {
|
||||
|
|
@ -191,7 +190,7 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
String vmName = vmSpec.getName();
|
||||
if (this.totalCpu < (vmSpec.getCpus() * vmSpec.getSpeed() + this.usedCpu) ||
|
||||
this.totalMem < (vmSpec.getMaxRam() + this.usedMem)) {
|
||||
return new StartAnswer(cmd, "No enough resource to start the vm");
|
||||
return new StartAnswer(cmd, "Not enough resource to start the vm");
|
||||
}
|
||||
State state = State.Stopped;
|
||||
synchronized (_vms) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue