mirror of https://github.com/apache/cloudstack.git
Merge pull request #1635 from myENA/feature/honor_force_stop_vm
CLOUDSTACK-9451https://issues.apache.org/jira/browse/CLOUDSTACK-9451 Re-doing against 4.8 since this is a bug, not a feature. * pr/1635: CLOUDSTACK-9451 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
5811d33658
|
|
@ -90,6 +90,8 @@ public interface VirtualMachineManager extends Manager {
|
|||
|
||||
void stop(String vmUuid) throws ResourceUnavailableException;
|
||||
|
||||
void stopForced(String vmUuid) throws ResourceUnavailableException;
|
||||
|
||||
void expunge(String vmUuid) throws ResourceUnavailableException;
|
||||
|
||||
void registerGuru(VirtualMachine.Type type, VirtualMachineGuru guru);
|
||||
|
|
|
|||
|
|
@ -114,6 +114,12 @@ public interface VirtualMachineEntity extends CloudStackEntity {
|
|||
*/
|
||||
boolean stop(String caller) throws ResourceUnavailableException, CloudException;
|
||||
|
||||
/**
|
||||
* Stop the virtual machine, by force if necessary
|
||||
*
|
||||
*/
|
||||
boolean stopForced(String caller) throws ResourceUnavailableException, CloudException;
|
||||
|
||||
/**
|
||||
* Cleans up after any botched starts. CloudStack Orchestration Platform
|
||||
* will attempt a best effort to actually shutdown any resource but
|
||||
|
|
|
|||
|
|
@ -1239,6 +1239,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
} catch (final ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Unable to stop vm because of a concurrent operation", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopForced(String vmUuid) throws ResourceUnavailableException {
|
||||
try {
|
||||
advanceStop(vmUuid, true);
|
||||
} catch (final OperationTimedoutException e) {
|
||||
throw new AgentUnavailableException("Unable to stop vm because the operation to stop timed out", e.getAgentId(), e);
|
||||
} catch (final ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Unable to stop vm because of a concurrent operation", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -44,5 +44,7 @@ public interface VMEntityManager {
|
|||
|
||||
boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException;
|
||||
|
||||
boolean stopvirtualmachineforced(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException;
|
||||
|
||||
boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,6 +254,12 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopvirtualmachineforced(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException {
|
||||
_itMgr.stopForced(vmEntityVO.getUuid());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
|
||||
|
|
|
|||
|
|
@ -217,6 +217,11 @@ public class VirtualMachineEntityImpl implements VirtualMachineEntity {
|
|||
return manager.stopvirtualmachine(this.vmEntityVO, caller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopForced(String caller) throws ResourceUnavailableException {
|
||||
return manager.stopvirtualmachineforced(this.vmEntityVO, caller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
|||
|
|
@ -3866,7 +3866,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
boolean status = false;
|
||||
try {
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
|
||||
status = vmEntity.stop(Long.toString(userId));
|
||||
|
||||
if(forced) {
|
||||
status = vmEntity.stopForced(Long.toString(userId));
|
||||
} else {
|
||||
status = vmEntity.stop(Long.toString(userId));
|
||||
}
|
||||
if (status) {
|
||||
return _vmDao.findById(vmId);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue