mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge pull request #1200 from koushik-das/CLOUDSTACK-9130
CLOUDSTACK-9130: Make RebootCommand similar to start/stop/migrate agent commands w.r.t. "execute in sequence" flag RebootCommand now behaves in the same way as start/stop/migrate agent commands w.r.t. to sequential/parallel execution. * pr/1200: CLOUDSTACK-9130: Make RebootCommand similar to start/stop/migrate agent commands w.r.t. "execute in sequence" flag RebootCommand now behaves in the same way as start/stop/migrate agent commands w.r.t. to sequential/parallel execution. Signed-off-by: Will Stevens <williamstevens@gmail.com>
This commit is contained in:
commit
f530a4c63a
@ -19,29 +19,25 @@
|
|||||||
|
|
||||||
package com.cloud.agent.api;
|
package com.cloud.agent.api;
|
||||||
|
|
||||||
import com.cloud.vm.VirtualMachine;
|
|
||||||
|
|
||||||
public class RebootCommand extends Command {
|
public class RebootCommand extends Command {
|
||||||
String vmName;
|
String vmName;
|
||||||
|
protected boolean executeInSequence = false;
|
||||||
|
|
||||||
protected RebootCommand() {
|
protected RebootCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RebootCommand(VirtualMachine vm) {
|
public RebootCommand(String vmName, boolean executeInSequence) {
|
||||||
vmName = vm.getInstanceName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public RebootCommand(String vmName) {
|
|
||||||
this.vmName = vmName;
|
this.vmName = vmName;
|
||||||
|
this.executeInSequence = executeInSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVmName() {
|
public String getVmName() {
|
||||||
return vmName;
|
return this.vmName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeInSequence() {
|
public boolean executeInSequence() {
|
||||||
return true;
|
return this.executeInSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public class RebootRouterCommand extends RebootCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RebootRouterCommand(String vmName, String privateIp) {
|
public RebootRouterCommand(String vmName, String privateIp) {
|
||||||
super(vmName);
|
super(vmName, true);
|
||||||
this.privateIp = privateIp;
|
this.privateIp = privateIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,6 @@ public class StopCommand extends RebootCommand {
|
|||||||
private boolean isProxy = false;
|
private boolean isProxy = false;
|
||||||
private String urlPort = null;
|
private String urlPort = null;
|
||||||
private String publicConsoleProxyIpAddress = null;
|
private String publicConsoleProxyIpAddress = null;
|
||||||
boolean executeInSequence = false;
|
|
||||||
private GPUDeviceTO gpuDevice;
|
private GPUDeviceTO gpuDevice;
|
||||||
boolean checkBeforeCleanup = false;
|
boolean checkBeforeCleanup = false;
|
||||||
|
|
||||||
@ -34,33 +33,30 @@ public class StopCommand extends RebootCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StopCommand(VirtualMachine vm, boolean isProxy, String urlPort, String publicConsoleProxyIpAddress, boolean executeInSequence, boolean checkBeforeCleanup) {
|
public StopCommand(VirtualMachine vm, boolean isProxy, String urlPort, String publicConsoleProxyIpAddress, boolean executeInSequence, boolean checkBeforeCleanup) {
|
||||||
super(vm);
|
super(vm.getInstanceName(), executeInSequence);
|
||||||
this.isProxy = isProxy;
|
this.isProxy = isProxy;
|
||||||
this.urlPort = urlPort;
|
this.urlPort = urlPort;
|
||||||
this.publicConsoleProxyIpAddress = publicConsoleProxyIpAddress;
|
this.publicConsoleProxyIpAddress = publicConsoleProxyIpAddress;
|
||||||
this.executeInSequence = executeInSequence;
|
|
||||||
this.checkBeforeCleanup = checkBeforeCleanup;
|
this.checkBeforeCleanup = checkBeforeCleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StopCommand(VirtualMachine vm, boolean executeInSequence, boolean checkBeforeCleanup) {
|
public StopCommand(VirtualMachine vm, boolean executeInSequence, boolean checkBeforeCleanup) {
|
||||||
super(vm);
|
super(vm.getInstanceName(), executeInSequence);
|
||||||
this.executeInSequence = executeInSequence;
|
|
||||||
this.checkBeforeCleanup = checkBeforeCleanup;
|
this.checkBeforeCleanup = checkBeforeCleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StopCommand(String vmName, boolean executeInSequence, boolean checkBeforeCleanup) {
|
public StopCommand(String vmName, boolean executeInSequence, boolean checkBeforeCleanup) {
|
||||||
super(vmName);
|
super(vmName, executeInSequence);
|
||||||
this.executeInSequence = executeInSequence;
|
|
||||||
this.checkBeforeCleanup = checkBeforeCleanup;
|
this.checkBeforeCleanup = checkBeforeCleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeInSequence() {
|
public boolean executeInSequence() {
|
||||||
//VR stop doesn't go through queue
|
// VR stop doesn't go through queue
|
||||||
if (vmName != null && vmName.startsWith("r-")) {
|
if (this.vmName != null && this.vmName.startsWith("r-")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return executeInSequence;
|
return this.executeInSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isProxy() {
|
public boolean isProxy() {
|
||||||
|
|||||||
@ -49,11 +49,10 @@ import com.cloud.utils.fsm.NoTransitionException;
|
|||||||
public interface VirtualMachineManager extends Manager {
|
public interface VirtualMachineManager extends Manager {
|
||||||
|
|
||||||
static final ConfigKey<Boolean> ExecuteInSequence = new ConfigKey<Boolean>("Advanced", Boolean.class, "execute.in.sequence.hypervisor.commands", "false",
|
static final ConfigKey<Boolean> ExecuteInSequence = new ConfigKey<Boolean>("Advanced", Boolean.class, "execute.in.sequence.hypervisor.commands", "false",
|
||||||
"If set to true, StartCommand, StopCommand, CopyCommand, MigrateCommand will be synchronized on the agent side."
|
"If set to true, start, stop, reboot, copy and migrate commands will be serialized on the agent side. If set to false the commands are executed in parallel. Default value is false.", false);
|
||||||
+ " If set to false, these commands become asynchronous. Default value is false.", false);
|
|
||||||
|
|
||||||
static final ConfigKey<String> VmConfigDriveLabel = new ConfigKey<String>("Hidden", String.class, "vm.configdrive.label", "config",
|
static final ConfigKey<String> VmConfigDriveLabel = new ConfigKey<String>("Hidden", String.class, "vm.configdrive.label", "config",
|
||||||
"The default lable name for the config drive", false);
|
"The default label name for the config drive", false);
|
||||||
|
|
||||||
public interface Topics {
|
public interface Topics {
|
||||||
public static final String VM_POWER_STATE = "vm.powerstate";
|
public static final String VM_POWER_STATE = "vm.powerstate";
|
||||||
@ -199,4 +198,6 @@ public interface VirtualMachineManager extends Manager {
|
|||||||
ConcurrentOperationException, ResourceUnavailableException;
|
ConcurrentOperationException, ResourceUnavailableException;
|
||||||
|
|
||||||
void migrateForScale(String vmUuid, long srcHostId, DeployDestination dest, Long newSvcOfferingId) throws ResourceUnavailableException, ConcurrentOperationException;
|
void migrateForScale(String vmUuid, long srcHostId, DeployDestination dest, Long newSvcOfferingId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||||
|
|
||||||
|
boolean getExecuteInSequence(HypervisorType hypervisorType);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1241,11 +1241,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected boolean getExecuteInSequence(final HypervisorType hypervisorType) {
|
public boolean getExecuteInSequence(final HypervisorType hypervisorType) {
|
||||||
if (HypervisorType.KVM == hypervisorType || HypervisorType.LXC == hypervisorType || HypervisorType.XenServer == hypervisorType) {
|
if (HypervisorType.KVM == hypervisorType || HypervisorType.XenServer == hypervisorType || HypervisorType.Hyperv == hypervisorType || HypervisorType.LXC == hypervisorType) {
|
||||||
return false;
|
return false;
|
||||||
} else if(HypervisorType.VMware == hypervisorType) {
|
} else if (HypervisorType.VMware == hypervisorType) {
|
||||||
final Boolean fullClone = HypervisorGuru.VmwareFullClone.value();
|
final Boolean fullClone = HypervisorGuru.VmwareFullClone.value();
|
||||||
return fullClone;
|
return fullClone;
|
||||||
} else {
|
} else {
|
||||||
@ -2585,7 +2585,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
final Commands cmds = new Commands(Command.OnError.Stop);
|
final Commands cmds = new Commands(Command.OnError.Stop);
|
||||||
cmds.addCommand(new RebootCommand(vm.getInstanceName()));
|
cmds.addCommand(new RebootCommand(vm.getInstanceName(), getExecuteInSequence(vm.getHypervisorType())));
|
||||||
_agentMgr.send(host.getId(), cmds);
|
_agentMgr.send(host.getId(), cmds);
|
||||||
|
|
||||||
final Answer rebootAnswer = cmds.getAnswer(RebootAnswer.class);
|
final Answer rebootAnswer = cmds.getAnswer(RebootAnswer.class);
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package com.cloud.vm;
|
package com.cloud.vm;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyLong;
|
import static org.mockito.Matchers.anyLong;
|
||||||
import static org.mockito.Matchers.isA;
|
import static org.mockito.Matchers.isA;
|
||||||
@ -505,4 +506,12 @@ public class VirtualMachineManagerImplTest {
|
|||||||
|
|
||||||
Assert.assertFalse(actual);
|
Assert.assertFalse(actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExeceuteInSequence() {
|
||||||
|
assertTrue(_vmMgr.getExecuteInSequence(HypervisorType.XenServer) == false);
|
||||||
|
assertTrue(_vmMgr.getExecuteInSequence(HypervisorType.KVM) == false);
|
||||||
|
assertTrue(_vmMgr.getExecuteInSequence(HypervisorType.VMware) == HypervisorGuru.VmwareFullClone.value());
|
||||||
|
assertTrue(_vmMgr.getExecuteInSequence(HypervisorType.Ovm3) == VirtualMachineManager.ExecuteInSequence.value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public final class LibvirtRebootRouterCommandWrapper extends CommandWrapper<Rebo
|
|||||||
public Answer execute(final RebootRouterCommand command, final LibvirtComputingResource libvirtComputingResource) {
|
public Answer execute(final RebootRouterCommand command, final LibvirtComputingResource libvirtComputingResource) {
|
||||||
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
|
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
|
||||||
|
|
||||||
final RebootCommand rebootCommand = new RebootCommand(command.getVmName());
|
final RebootCommand rebootCommand = new RebootCommand(command.getVmName(), true);
|
||||||
final Answer answer = wrapper.execute(rebootCommand, libvirtComputingResource);
|
final Answer answer = wrapper.execute(rebootCommand, libvirtComputingResource);
|
||||||
|
|
||||||
final VirtualRoutingResource virtualRouterResource = libvirtComputingResource.getVirtRouterResource();
|
final VirtualRoutingResource virtualRouterResource = libvirtComputingResource.getVirtRouterResource();
|
||||||
|
|||||||
@ -749,7 +749,7 @@ public class LibvirtComputingResourceTest {
|
|||||||
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
|
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
|
||||||
|
|
||||||
final String vmName = "Test";
|
final String vmName = "Test";
|
||||||
final RebootCommand command = new RebootCommand(vmName);
|
final RebootCommand command = new RebootCommand(vmName, true);
|
||||||
|
|
||||||
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
|
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
|
||||||
try {
|
try {
|
||||||
@ -778,7 +778,7 @@ public class LibvirtComputingResourceTest {
|
|||||||
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
|
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
|
||||||
|
|
||||||
final String vmName = "Test";
|
final String vmName = "Test";
|
||||||
final RebootCommand command = new RebootCommand(vmName);
|
final RebootCommand command = new RebootCommand(vmName, true);
|
||||||
|
|
||||||
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
|
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
|
||||||
try {
|
try {
|
||||||
@ -807,7 +807,7 @@ public class LibvirtComputingResourceTest {
|
|||||||
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
|
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
|
||||||
|
|
||||||
final String vmName = "Test";
|
final String vmName = "Test";
|
||||||
final RebootCommand command = new RebootCommand(vmName);
|
final RebootCommand command = new RebootCommand(vmName, true);
|
||||||
|
|
||||||
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
|
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
|
||||||
try {
|
try {
|
||||||
@ -838,7 +838,7 @@ public class LibvirtComputingResourceTest {
|
|||||||
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
|
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
|
||||||
|
|
||||||
final String vmName = "Test";
|
final String vmName = "Test";
|
||||||
final RebootCommand command = new RebootCommand(vmName);
|
final RebootCommand command = new RebootCommand(vmName, true);
|
||||||
|
|
||||||
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
|
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -172,7 +172,7 @@ public class Ovm3HypervisorResourceTest {
|
|||||||
con.removeMethodResponse("list_vms");
|
con.removeMethodResponse("list_vms");
|
||||||
con.addResult(xen.getMultipleVmsListXML());
|
con.addResult(xen.getMultipleVmsListXML());
|
||||||
con.addResult(xen.getMultipleVmsListXML());
|
con.addResult(xen.getMultipleVmsListXML());
|
||||||
RebootCommand cmd = new RebootCommand(name);
|
RebootCommand cmd = new RebootCommand(name, true);
|
||||||
Answer ra = hypervisor.executeRequest(cmd);
|
Answer ra = hypervisor.executeRequest(cmd);
|
||||||
return ra.getResult();
|
return ra.getResult();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public final class CitrixRebootRouterCommandWrapper extends CommandWrapper<Reboo
|
|||||||
|
|
||||||
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
|
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
|
||||||
|
|
||||||
final RebootCommand rebootCommand = new RebootCommand(command.getVmName());
|
final RebootCommand rebootCommand = new RebootCommand(command.getVmName(), true);
|
||||||
final Answer answer = wrapper.execute(rebootCommand, citrixResourceBase);
|
final Answer answer = wrapper.execute(rebootCommand, citrixResourceBase);
|
||||||
|
|
||||||
if (answer.getResult()) {
|
if (answer.getResult()) {
|
||||||
|
|||||||
@ -300,7 +300,7 @@ public class CitrixRequestWrapperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRebootCommand() {
|
public void testRebootCommand() {
|
||||||
final RebootCommand rebootCommand = new RebootCommand("Test");
|
final RebootCommand rebootCommand = new RebootCommand("Test", true);
|
||||||
|
|
||||||
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
|
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
|
||||||
assertNotNull(wrapper);
|
assertNotNull(wrapper);
|
||||||
|
|||||||
@ -1127,7 +1127,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (proxy.getState() == State.Running && proxy.getHostId() != null) {
|
if (proxy.getState() == State.Running && proxy.getHostId() != null) {
|
||||||
final RebootCommand cmd = new RebootCommand(proxy.getInstanceName());
|
final RebootCommand cmd = new RebootCommand(proxy.getInstanceName(), _itMgr.getExecuteInSequence(proxy.getHypervisorType()));
|
||||||
final Answer answer = _agentMgr.easySend(proxy.getHostId(), cmd);
|
final Answer answer = _agentMgr.easySend(proxy.getHostId(), cmd);
|
||||||
|
|
||||||
if (answer != null && answer.getResult()) {
|
if (answer != null && answer.getResult()) {
|
||||||
|
|||||||
@ -988,7 +988,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (secStorageVm.getState() == State.Running && secStorageVm.getHostId() != null) {
|
if (secStorageVm.getState() == State.Running && secStorageVm.getHostId() != null) {
|
||||||
final RebootCommand cmd = new RebootCommand(secStorageVm.getInstanceName());
|
final RebootCommand cmd = new RebootCommand(secStorageVm.getInstanceName(), _itMgr.getExecuteInSequence(secStorageVm.getHypervisorType()));
|
||||||
final Answer answer = _agentMgr.easySend(secStorageVm.getHostId(), cmd);
|
final Answer answer = _agentMgr.easySend(secStorageVm.getHostId(), cmd);
|
||||||
|
|
||||||
if (answer != null && answer.getResult()) {
|
if (answer != null && answer.getResult()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user