mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-5432:sync vm and storage commands on mgt server for kvm
Conflicts: engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java server/src/com/cloud/hypervisor/KVMGuru.java
This commit is contained in:
parent
bd752c2ec0
commit
504a6cdee2
|
|
@ -24,6 +24,7 @@ import com.cloud.agent.api.to.DiskTO;
|
|||
public final class AttachCommand extends Command implements StorageSubSystemCommand {
|
||||
private DiskTO disk;
|
||||
private String vmName;
|
||||
private boolean inSeq = false;
|
||||
|
||||
public AttachCommand(DiskTO disk, String vmName) {
|
||||
super();
|
||||
|
|
@ -51,4 +52,9 @@ public final class AttachCommand extends Command implements StorageSubSystemComm
|
|||
public void setVmName(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
this.inSeq = inSeq;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ package org.apache.cloudstack.storage.command;
|
|||
import com.cloud.agent.api.Command;
|
||||
|
||||
public final class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
|
||||
}
|
||||
|
||||
private final String dataStore;
|
||||
|
||||
public AttachPrimaryDataStoreCmd(String uri) {
|
||||
|
|
|
|||
|
|
@ -78,4 +78,8 @@ public final class CopyCommand extends Command implements StorageSubSystemComman
|
|||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
this.executeInSequence = inSeq;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,4 +42,8 @@ public final class CreateObjectCommand extends Command implements StorageSubSyst
|
|||
return this.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,8 @@ public final class CreatePrimaryDataStoreCmd extends Command implements StorageS
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,4 +42,8 @@ public final class DeleteCommand extends Command implements StorageSubSystemComm
|
|||
return this.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,4 +87,9 @@ public class DettachCommand extends Command implements StorageSubSystemCommand {
|
|||
public int getStoragePort() {
|
||||
return _storagePort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,9 @@ public class ForgetObjectCmd extends Command implements StorageSubSystemCommand
|
|||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,9 @@ public class IntroduceObjectCmd extends Command implements StorageSubSystemComma
|
|||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteInSequence(boolean inSeq) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,5 +19,5 @@
|
|||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
public interface StorageSubSystemCommand {
|
||||
|
||||
void setExecuteInSequence(boolean inSeq);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -996,7 +996,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
handlePath(vmTO.getDisks(), vm.getHypervisorType());
|
||||
|
||||
cmds = new Commands(Command.OnError.Stop);
|
||||
cmds.addCommand(new StartCommand(vmTO, dest.getHost(), ExecuteInSequence.value()));
|
||||
|
||||
cmds.addCommand(new StartCommand(vmTO, dest.getHost(), getExecuteInSequence(vm.getHypervisorType())));
|
||||
|
||||
|
||||
vmGuru.finalizeDeployment(cmds, vmProfile, dest, ctx);
|
||||
|
||||
|
|
@ -1045,9 +1047,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
s_logger.info("The guru did not like the answers so stopping " + vm);
|
||||
}
|
||||
|
||||
StopCommand cmd = new StopCommand(vm, ExecuteInSequence.value());
|
||||
StopAnswer answer = (StopAnswer)_agentMgr.easySend(destHostId, cmd);
|
||||
if (answer != null) {
|
||||
StopCommand cmd = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()));
|
||||
StopAnswer answer = (StopAnswer) _agentMgr.easySend(destHostId, cmd);
|
||||
if ( answer != null ) {
|
||||
|
||||
if (vm.getType() == VirtualMachine.Type.User) {
|
||||
String platform = answer.getPlatform();
|
||||
if (platform != null) {
|
||||
|
|
@ -1213,9 +1216,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean getExecuteInSequence(HypervisorType hypervisorType) {
|
||||
if (HypervisorType.KVM == hypervisorType) {
|
||||
return false;
|
||||
} else {
|
||||
return ExecuteInSequence.value();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean sendStop(VirtualMachineGuru guru, VirtualMachineProfile profile, boolean force) {
|
||||
VirtualMachine vm = profile.getVirtualMachine();
|
||||
StopCommand stop = new StopCommand(vm, ExecuteInSequence.value());
|
||||
StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()));
|
||||
try {
|
||||
StopAnswer answer = (StopAnswer)_agentMgr.send(vm.getHostId(), stop);
|
||||
if (answer != null) {
|
||||
|
|
@ -1475,7 +1487,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
|
||||
vmGuru.prepareStop(profile);
|
||||
StopCommand stop = new StopCommand(vm, ExecuteInSequence.value());
|
||||
|
||||
StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()));
|
||||
|
||||
boolean stopped = false;
|
||||
StopAnswer answer = null;
|
||||
try {
|
||||
|
|
@ -2450,11 +2464,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
|
||||
public Command cleanup(VirtualMachine vm) {
|
||||
return new StopCommand(vm, ExecuteInSequence.value());
|
||||
return new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()));
|
||||
}
|
||||
|
||||
public Command cleanup(String vmName) {
|
||||
return new StopCommand(vmName, ExecuteInSequence.value());
|
||||
return new StopCommand(vmName, getExecuteInSequence(null));
|
||||
|
||||
}
|
||||
|
||||
public Commands fullHostSync(final long hostId, StartupRoutingCommand startup) {
|
||||
|
|
|
|||
|
|
@ -19,11 +19,14 @@ package com.cloud.hypervisor;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||
|
||||
@Local(value = HypervisorGuru.class)
|
||||
public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
|
|
@ -40,6 +43,7 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
}
|
||||
|
||||
@Override
|
||||
|
||||
public VirtualMachineTO implement(VirtualMachineProfile vm) {
|
||||
VirtualMachineTO to = toVirtualMachineTO(vm);
|
||||
|
||||
|
|
@ -50,6 +54,15 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
return to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Boolean, Long> getCommandHostDelegation(long hostId, Command cmd) {
|
||||
if (cmd instanceof StorageSubSystemCommand) {
|
||||
StorageSubSystemCommand c = (StorageSubSystemCommand)cmd;
|
||||
c.setExecuteInSequence(false);
|
||||
}
|
||||
return new Pair<Boolean, Long>(false, new Long(hostId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trackVmHostChange() {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue