mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Finished all merges and unit testing
This commit is contained in:
parent
6e6e8ff876
commit
6d9442be54
@ -739,7 +739,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
volResponse.setDeviceId(volume.getDeviceId());
|
||||
|
||||
Long instanceId = volume.getInstanceId();
|
||||
if (instanceId != null) {
|
||||
if (instanceId != null && volume.getState() != Volume.State.Destroy) {
|
||||
VMInstanceVO vm = ApiDBUtils.findVMInstanceById(instanceId);
|
||||
volResponse.setVirtualMachineId(vm.getId());
|
||||
volResponse.setVirtualMachineName(vm.getName());
|
||||
|
||||
@ -562,6 +562,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
Account systemAcct = _accountMgr.getSystemAccount();
|
||||
User systemUser = _accountMgr.getSystemUser();
|
||||
if (proxy.getState() == VirtualMachine.State.Running) {
|
||||
return proxy;
|
||||
}
|
||||
return _itMgr.start(proxy, null, systemUser, systemAcct);
|
||||
}
|
||||
|
||||
|
||||
@ -2723,8 +2723,10 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
String vmName = null;
|
||||
if (vol.getVolumeType() == VolumeType.ROOT && vol.getInstanceId() != null) {
|
||||
VirtualMachine vm = _vmInstanceDao.findById(vol.getInstanceId());
|
||||
vmName = vm.getInstanceName();
|
||||
VirtualMachine vm = _vmInstanceDao.findByIdIncludingRemoved(vol.getInstanceId());
|
||||
if (vm != null) {
|
||||
vmName = vm.getInstanceName();
|
||||
}
|
||||
}
|
||||
|
||||
String volumePath = vol.getPath();
|
||||
|
||||
@ -461,7 +461,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager {
|
||||
while (retry-- != 0) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
if (_vmDao.updateIf(vm, Event.StartRequested, null, work.getId())) {
|
||||
if (stateTransitTo(vm, Event.StartRequested, null, work.getId())) {
|
||||
|
||||
Journal journal = new Journal.LogJournal("Creating " + vm, s_logger);
|
||||
work = _workDao.persist(work);
|
||||
@ -470,6 +470,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully transitioned to start state for " + vm + " reservation id = " + work.getId());
|
||||
}
|
||||
txn.commit();
|
||||
return new Ternary<T, ReservationContext, ItWorkVO>(vmGuru.findById(vmId), context, work);
|
||||
}
|
||||
|
||||
@ -477,35 +478,32 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager {
|
||||
s_logger.debug("Determining why we're unable to update the state to Starting for " + vm);
|
||||
}
|
||||
|
||||
try {
|
||||
VMInstanceVO instance = _vmDao.lockRow(vmId, true);
|
||||
if (instance == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on " + vm);
|
||||
VMInstanceVO instance = _vmDao.lockRow(vmId, true);
|
||||
if (instance == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on " + vm);
|
||||
}
|
||||
|
||||
State state = instance.getState();
|
||||
if (state == State.Running) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
}
|
||||
|
||||
State state = instance.getState();
|
||||
if (state == State.Running) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state.isTransitional()) {
|
||||
if (!checkWorkItems(vm, state)) {
|
||||
throw new ConcurrentOperationException("There are concurrent operations on the VM " + vm);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (state != State.Stopped) {
|
||||
s_logger.debug("VM " + vm + " is not in a state to be started: " + state);
|
||||
return null;
|
||||
}
|
||||
|
||||
} finally {
|
||||
txn.commit();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state.isTransitional()) {
|
||||
if (!checkWorkItems(vm, state)) {
|
||||
throw new ConcurrentOperationException("There are concurrent operations on the VM " + vm);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (state != State.Stopped) {
|
||||
s_logger.debug("VM " + vm + " is not in a state to be started: " + state);
|
||||
txn.commit();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user