Changed start to use uuid instead of generic vm start

This commit is contained in:
Alex Huang 2013-07-20 10:10:30 -07:00
parent 4aa9e0a696
commit 7928963d16
15 changed files with 218 additions and 267 deletions

View File

@ -22,6 +22,9 @@ import java.util.UUID;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
@ -29,16 +32,14 @@ import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDao;
import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.dc.DataCenter;
import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.deploy.DeploymentPlanningManager;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.deploy.DeploymentPlanningManager;
import com.cloud.exception.AffinityConflictException;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
@ -156,7 +157,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
if(!vols.isEmpty()){
VolumeVO vol = vols.get(0);
StoragePool pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
StoragePool pool = (StoragePool)dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
if (!pool.isInMaintenance()) {
long rootVolDcId = pool.getDataCenterId();
@ -224,8 +225,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
DataCenterDeployment reservedPlan = new DataCenterDeployment(vm.getDataCenterId(),
vmReservation.getPodId(), vmReservation.getClusterId(), vmReservation.getHostId(), null, null);
try {
VMInstanceVO vmDeployed = _itMgr.start(vm, params, _userDao.findById(new Long(caller)),
_accountDao.findById(vm.getAccountId()), reservedPlan);
_itMgr.start(vm.getUuid(), params, reservedPlan);
} catch (Exception ex) {
// Retry the deployment without using the reservation plan
DataCenterDeployment plan = new DataCenterDeployment(0, null, null, null, null, null);
@ -234,12 +234,11 @@ public class VMEntityManagerImpl implements VMEntityManager {
plan.setAvoids(reservedPlan.getAvoids());
}
_itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()),
plan);
_itMgr.start(vm.getUuid(), params, plan);
}
} else {
// no reservation found. Let VirtualMachineManager retry
_itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), null);
_itMgr.start(vm.getUuid(), params, null);
}
}

View File

@ -538,11 +538,8 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
private DomainRouterVO start(DomainRouterVO elbVm, User user, Account caller, Map<Param, Object> params) throws StorageUnavailableException, InsufficientCapacityException,
ConcurrentOperationException, ResourceUnavailableException {
s_logger.debug("Starting ELB VM " + elbVm);
if (_itMgr.start(elbVm, params, user, caller) != null) {
return _routerDao.findById(elbVm.getId());
} else {
return null;
}
_itMgr.start(elbVm.getUuid(), params);
return _routerDao.findById(elbVm.getId());
}
private DomainRouterVO stop(DomainRouterVO elbVm, boolean forced, User user, Account caller) throws ConcurrentOperationException, ResourceUnavailableException {

View File

@ -467,7 +467,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
maxconn = offering.getConcurrentConnections().toString();
}
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs, guestNic.getIp4Address(),
guestNic.getIp4Address(), internalLbVm.getPrivateIpAddress(),
guestNic.getIp4Address(), internalLbVm.getPrivateIpAddress(),
_itMgr.toNicTO(guestNicProfile, internalLbVm.getHypervisorType()), internalLbVm.getVpcId(), maxconn);
cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key());
@ -815,16 +815,13 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
throws StorageUnavailableException, InsufficientCapacityException,
ConcurrentOperationException, ResourceUnavailableException {
s_logger.debug("Starting Internal LB VM " + internalLbVm);
if (_itMgr.start(internalLbVm, params, _accountMgr.getUserIncludingRemoved(callerUserId), caller, null) != null) {
if (internalLbVm.isStopPending()) {
s_logger.info("Clear the stop pending flag of Internal LB VM " + internalLbVm.getHostName() + " after start router successfully!");
internalLbVm.setStopPending(false);
internalLbVm = _internalLbVmDao.persist(internalLbVm);
}
return _internalLbVmDao.findById(internalLbVm.getId());
} else {
return null;
_itMgr.start(internalLbVm.getUuid(), params, null);
if (internalLbVm.isStopPending()) {
s_logger.info("Clear the stop pending flag of Internal LB VM " + internalLbVm.getHostName() + " after start router successfully!");
internalLbVm.setStopPending(false);
internalLbVm = _internalLbVmDao.persist(internalLbVm);
}
return _internalLbVmDao.findById(internalLbVm.getId());
}

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.internallbvmmgr;
import java.lang.reflect.Field;
import java.util.Map;
import javax.inject.Inject;
@ -34,7 +33,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
@ -113,17 +111,6 @@ public class InternalLBVMServiceTest extends TestCase {
Mockito.when(_domainRouterDao.findById(nonExistingVmId)).thenReturn(null);
Mockito.when(_domainRouterDao.findById(nonInternalLbVmId)).thenReturn(nonInternalLbVm);
try {
Mockito.when(_itMgr.start(Mockito.any(DomainRouterVO.class),
Mockito.any(Map.class), Mockito.any(User.class), Mockito.any(Account.class), Mockito.any(DeploymentPlan.class))).thenReturn(validVm);
} catch (InsufficientCapacityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ResourceUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Mockito.when(_itMgr.advanceStop(Mockito.any(DomainRouterVO.class), Mockito.any(Boolean.class), Mockito.any(User.class), Mockito.any(Account.class))).thenReturn(true);
} catch (ResourceUnavailableException e) {

View File

@ -65,6 +65,7 @@ import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.Host;
@ -110,7 +111,6 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.User;
import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
@ -540,8 +540,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
public ConsoleProxyVO startProxy(long proxyVmId) {
try {
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
Account systemAcct = _accountMgr.getSystemAccount();
User systemUser = _accountMgr.getSystemUser();
if (proxy.getState() == VirtualMachine.State.Running) {
return proxy;
}
@ -552,7 +550,8 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
}
if (proxy.getState() == VirtualMachine.State.Stopped) {
return _itMgr.start(proxy, null, systemUser, systemAcct);
_itMgr.advanceStart(proxy.getUuid(), null);
proxy = _consoleProxyDao.findById(proxy.getId());
}
// For VMs that are in Stopping, Starting, Migrating state, let client to wait by returning null
@ -574,6 +573,12 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
} catch (CloudRuntimeException e) {
s_logger.warn("Runtime Exception while trying to start console proxy", e);
return null;
} catch (ConcurrentOperationException e) {
s_logger.warn("Runtime Exception while trying to start console proxy", e);
return null;
} catch (OperationTimedoutException e) {
s_logger.warn("Runtime Exception while trying to start console proxy", e);
return null;
}
}

View File

@ -32,6 +32,8 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
import org.apache.cloudstack.context.ServerContexts;
import com.cloud.agent.AgentManager;
import com.cloud.alert.AlertManager;
import com.cloud.cluster.ClusterManagerListener;
@ -294,7 +296,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} catch (ConcurrentOperationException e) {
assert false : "How do we hit this when force is true?";
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
}
}
return;
}
@ -338,7 +340,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} catch (ConcurrentOperationException e) {
assert false : "How do we hit this when force is true?";
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
}
}
}
List<HaWorkVO> items = _haDao.findPreviousHA(vm.getId());
@ -513,7 +515,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
return null; // VM doesn't require HA
}
if (!this.volumeMgr.canVmRestartOnAnotherServer(vm.getId())) {
if (!volumeMgr.canVmRestartOnAnotherServer(vm.getId())) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("VM can not restart on another server.");
}
@ -530,9 +532,10 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
if (_haTag != null) {
params.put(VirtualMachineProfile.Param.HaTag, _haTag);
}
VMInstanceVO started = _itMgr.advanceStart(vm, params, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
if (started != null) {
_itMgr.advanceStart(vm.getUuid(), params);
VMInstanceVO started = _instanceDao.findById(vm.getId());
if (started != null && started.getState() == VirtualMachine.State.Running) {
s_logger.info("VM is now restarted: " + vmId + " on " + started.getHostId());
return null;
}
@ -801,66 +804,71 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
@Override
public void run() {
s_logger.info("Starting work");
while (!_stopped) {
HaWorkVO work = null;
try {
s_logger.trace("Checking the database");
work = _haDao.take(_serverId);
if (work == null) {
ServerContexts.registerSystemContext();
try {
s_logger.info("Starting work");
while (!_stopped) {
HaWorkVO work = null;
try {
synchronized (this) {
wait(_timeToSleep);
s_logger.trace("Checking the database");
work = _haDao.take(_serverId);
if (work == null) {
try {
synchronized (this) {
wait(_timeToSleep);
}
continue;
} catch (final InterruptedException e) {
s_logger.info("Interrupted");
continue;
}
continue;
} catch (final InterruptedException e) {
s_logger.info("Interrupted");
continue;
}
}
NDC.push("work-" + work.getId());
s_logger.info("Processing " + work);
try {
final WorkType wt = work.getWorkType();
Long nextTime = null;
if (wt == WorkType.Migration) {
nextTime = migrate(work);
} else if (wt == WorkType.HA) {
nextTime = restart(work);
} else if (wt == WorkType.Stop || wt == WorkType.CheckStop || wt == WorkType.ForceStop) {
nextTime = stopVM(work);
} else if (wt == WorkType.Destroy) {
nextTime = destroyVM(work);
} else {
assert false : "How did we get here with " + wt.toString();
continue;
}
if (nextTime == null) {
s_logger.info("Completed " + work);
work.setStep(Step.Done);
} else {
s_logger.info("Rescheduling " + work + " to try again at " + new Date(nextTime << 10));
work.setTimeToTry(nextTime);
work.setServerId(null);
work.setDateTaken(null);
NDC.push("work-" + work.getId());
s_logger.info("Processing " + work);
try {
final WorkType wt = work.getWorkType();
Long nextTime = null;
if (wt == WorkType.Migration) {
nextTime = migrate(work);
} else if (wt == WorkType.HA) {
nextTime = restart(work);
} else if (wt == WorkType.Stop || wt == WorkType.CheckStop || wt == WorkType.ForceStop) {
nextTime = stopVM(work);
} else if (wt == WorkType.Destroy) {
nextTime = destroyVM(work);
} else {
assert false : "How did we get here with " + wt.toString();
continue;
}
if (nextTime == null) {
s_logger.info("Completed " + work);
work.setStep(Step.Done);
} else {
s_logger.info("Rescheduling " + work + " to try again at " + new Date(nextTime << 10));
work.setTimeToTry(nextTime);
work.setServerId(null);
work.setDateTaken(null);
}
} catch (Exception e) {
s_logger.error("Terminating " + work, e);
work.setStep(Step.Error);
}
_haDao.update(work.getId(), work);
} catch (final Throwable th) {
s_logger.error("Caught this throwable, ", th);
} finally {
if (work != null) {
NDC.pop();
}
}
} catch (Exception e) {
s_logger.error("Terminating " + work, e);
work.setStep(Step.Error);
}
_haDao.update(work.getId(), work);
} catch (final Throwable th) {
s_logger.error("Caught this throwable, ", th);
} finally {
if (work != null) {
NDC.pop();
}
}
s_logger.info("Time to go home!");
} finally {
ServerContexts.unregisterSystemContext();
}
s_logger.info("Time to go home!");
}
public synchronized void wakup() {

View File

@ -2735,22 +2735,19 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
throws StorageUnavailableException, InsufficientCapacityException,
ConcurrentOperationException, ResourceUnavailableException {
s_logger.debug("Starting router " + router);
if (_itMgr.start(router, params, user, caller, planToDeploy) != null) {
if (router.isStopPending()) {
s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after start router successfully!");
router.setStopPending(false);
router = _routerDao.persist(router);
}
// We don't want the failure of VPN Connection affect the status of router, so we try to make connection
// only after router start successfully
Long vpcId = router.getVpcId();
if (vpcId != null) {
_s2sVpnMgr.reconnectDisconnectedVpnByVpc(vpcId);
}
return _routerDao.findById(router.getId());
} else {
return null;
_itMgr.start(router.getUuid(), params, planToDeploy);
if (router.isStopPending()) {
s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after start router successfully!");
router.setStopPending(false);
router = _routerDao.persist(router);
}
// We don't want the failure of VPN Connection affect the status of router, so we try to make connection
// only after router start successfully
Long vpcId = router.getVpcId();
if (vpcId != null) {
_s2sVpnMgr.reconnectDisconnectedVpnByVpc(vpcId);
}
return _routerDao.findById(router.getId());
}
@Override

View File

@ -23,22 +23,22 @@ import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.*;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.ModifyStoragePoolCommand;
import com.cloud.alert.AlertManager;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.resource.ResourceManager;
import com.cloud.server.ManagementServer;
import com.cloud.storage.dao.StoragePoolHostDao;
@ -48,7 +48,6 @@ import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.exception.ExecutionException;
import com.cloud.vm.ConsoleProxyVO;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.SecondaryStorageVmVO;
@ -100,18 +99,19 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
VMInstanceDao vmDao;
@Inject
ManagementServer server;
@Inject DataStoreProviderManager providerMgr;
@Inject
DataStoreProviderManager providerMgr;
@Override
public boolean maintain(DataStore store) {
Long userId = CallContext.current().getCallingUserId();
User user = _userDao.findById(userId);
Account account = CallContext.current().getCallingAccount();
StoragePoolVO pool = this.primaryDataStoreDao.findById(store.getId());
StoragePoolVO pool = primaryDataStoreDao.findById(store.getId());
try {
List<StoragePoolVO> spes = null;
// Handling Zone and Cluster wide storage scopes.
// if the storage is ZONE wide then we pass podid and cluster id as null as they will be empty for ZWPS
// if the storage is ZONE wide then we pass podid and cluster id as null as they will be empty for ZWPS
if (pool.getScope() == ScopeType.ZONE) {
spes = primaryDataStoreDao.listBy(
pool.getDataCenterId(), null,
@ -128,14 +128,14 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
+ " is already in PrepareForMaintenance mode ");
}
}
StoragePool storagePool = (StoragePool) store;
StoragePool storagePool = (StoragePool)store;
//Handeling the Zone wide and cluster wide primay storage
List<HostVO> hosts = new ArrayList<HostVO>();
// if the storage scope is ZONE wide, then get all the hosts for which hypervisor ZWSP created to send Modifystoragepoolcommand
//TODO: if it's zone wide, this code will list a lot of hosts in the zone, which may cause performance/OOM issue.
if (pool.getScope().equals(ScopeType.ZONE)) {
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(pool.getHypervisor() , pool.getDataCenterId());
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(pool.getHypervisor(), pool.getDataCenterId());
} else {
hosts = _resourceMgr.listHostsInClusterByStatus(
pool.getClusterId(), Status.Up);
@ -159,7 +159,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
if (s_logger.isDebugEnabled()) {
s_logger.debug("ModifyStoragePool false failed due to "
+ ((answer == null) ? "answer null" : answer
.getDetails()));
.getDetails()));
}
} else {
if (s_logger.isDebugEnabled()) {
@ -179,7 +179,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
}
// 2. Get a list of all the ROOT volumes within this storage pool
List<VolumeVO> allVolumes = this.volumeDao.findByPoolId(pool
List<VolumeVO> allVolumes = volumeDao.findByPoolId(pool
.getId());
// 3. Enqueue to the work queue
@ -250,22 +250,15 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
if (restart) {
if (this.vmMgr.advanceStart(consoleProxy, null, user,
account) == null) {
String errorMsg = "There was an error starting the console proxy id: "
+ vmInstance.getId()
+ " on another storage pool, cannot enable primary storage maintenance";
s_logger.warn(errorMsg);
} else {
// update work status
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
vmMgr.advanceStart(consoleProxy.getUuid(), null);
// update work status
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
}
// if the instance is of type uservm, call the user vm manager
if (vmInstance.getType().equals(VirtualMachine.Type.User)) {
if (vmInstance.getType() == VirtualMachine.Type.User) {
UserVmVO userVm = userVmDao.findById(vmInstance.getId());
if (!vmMgr.advanceStop(userVm, true, user, account)) {
String errorMsg = "There was an error stopping the user vm id: "
@ -299,16 +292,10 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
}
if (restart) {
if (vmMgr.advanceStart(secStrgVm, null, user, account) == null) {
String errorMsg = "There was an error starting the ssvm id: "
+ vmInstance.getId()
+ " on another storage pool, cannot enable primary storage maintenance";
s_logger.warn(errorMsg);
} else {
// update work status
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
vmMgr.advanceStart(secStrgVm.getUuid(), null);
// update work status
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
}
@ -330,24 +317,18 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
}
if (restart) {
if (vmMgr.advanceStart(domR, null, user, account) == null) {
String errorMsg = "There was an error starting the domain router id: "
+ vmInstance.getId()
+ " on another storage pool, cannot enable primary storage maintenance";
s_logger.warn(errorMsg);
} else {
// update work status
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
vmMgr.advanceStart(domR.getUuid(), null);
// update work status
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
}
}
} catch(Exception e) {
} catch (Exception e) {
s_logger.error(
"Exception in enabling primary storage maintenance:", e);
pool.setStatus(StoragePoolStatus.ErrorInMaintenance);
this.primaryDataStoreDao.update(pool.getId(), pool);
primaryDataStoreDao.update(pool.getId(), pool);
throw new CloudRuntimeException(e.getMessage());
}
return true;
@ -359,7 +340,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
Long userId = CallContext.current().getCallingUserId();
User user = _userDao.findById(userId);
Account account = CallContext.current().getCallingAccount();
StoragePoolVO poolVO = this.primaryDataStoreDao
StoragePoolVO poolVO = primaryDataStoreDao
.findById(store.getId());
StoragePool pool = (StoragePool)store;
@ -370,7 +351,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(poolVO.getHypervisor(), pool.getDataCenterId());
} else {
hosts = _resourceMgr.listHostsInClusterByStatus(
pool.getClusterId(), Status.Up);
pool.getClusterId(), Status.Up);
}
if (hosts == null || hosts.size() == 0) {
@ -385,7 +366,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
if (s_logger.isDebugEnabled()) {
s_logger.debug("ModifyStoragePool add failed due to "
+ ((answer == null) ? "answer null" : answer
.getDetails()));
.getDetails()));
}
} else {
if (s_logger.isDebugEnabled()) {
@ -414,17 +395,10 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
ConsoleProxyVO consoleProxy = _consoleProxyDao
.findById(vmInstance.getId());
if (vmMgr.advanceStart(consoleProxy, null, user, account) == null) {
String msg = "There was an error starting the console proxy id: "
+ vmInstance.getId()
+ " on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg);
throw new ExecutionException(msg);
} else {
// update work queue
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
vmMgr.advanceStart(consoleProxy.getUuid(), null);
// update work queue
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
// if the instance is of type ssvm, call the ssvm manager
@ -432,52 +406,29 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
VirtualMachine.Type.SecondaryStorageVm)) {
SecondaryStorageVmVO ssVm = _secStrgDao.findById(vmInstance
.getId());
if (vmMgr.advanceStart(ssVm, null, user, account) == null) {
String msg = "There was an error starting the ssvm id: "
+ vmInstance.getId()
+ " on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg);
throw new ExecutionException(msg);
} else {
// update work queue
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
vmMgr.advanceStart(ssVm.getUuid(), null);
// update work queue
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
// if the instance is of type ssvm, call the ssvm manager
if (vmInstance.getType().equals(
VirtualMachine.Type.DomainRouter)) {
DomainRouterVO domR = _domrDao.findById(vmInstance.getId());
if (vmMgr.advanceStart(domR, null, user, account) == null) {
String msg = "There was an error starting the domR id: "
+ vmInstance.getId()
+ " on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg);
throw new ExecutionException(msg);
} else {
// update work queue
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
vmMgr.advanceStart(domR.getUuid(), null);
// update work queue
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
// if the instance is of type user vm, call the user vm manager
if (vmInstance.getType().equals(VirtualMachine.Type.User)) {
UserVmVO userVm = userVmDao.findById(vmInstance.getId());
if (vmMgr.advanceStart(userVm, null, user, account) == null) {
String msg = "There was an error starting the user vm id: "
+ vmInstance.getId()
+ " on storage pool, cannot complete primary storage maintenance";
s_logger.warn(msg);
throw new ExecutionException(msg);
} else {
// update work queue
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
vmMgr.advanceStart(userVm.getUuid(), null); // update work queue
work.setStartedAfterMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work);
}
return true;
} catch (Exception e) {

View File

@ -259,7 +259,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
Account systemAcct = _accountMgr.getSystemAccount();
User systemUser = _accountMgr.getSystemUser();
return _itMgr.start(secStorageVm, null, systemUser, systemAcct);
_itMgr.advanceStart(secStorageVm.getUuid(), null);
return _secStorageVmDao.findById(secStorageVm.getId());
} catch (StorageUnavailableException e) {
s_logger.warn("Exception while trying to start secondary storage vm", e);
return null;

View File

@ -22,10 +22,11 @@ import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import org.apache.cloudstack.context.ServerContexts;
import com.cloud.utils.Pair;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.db.Transaction;
//
// TODO: simple load scanner, to minimize code changes required in console proxy manager and SSVM, we still leave most of work at handler
@ -67,13 +68,13 @@ public class SystemVmLoadScanner<T> {
@Override
public void run() {
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
ServerContexts.registerSystemContext();
try {
reallyRun();
} catch (Throwable e) {
s_logger.warn("Unexpected exception " + e.getMessage(), e);
} finally {
txn.close();
ServerContexts.unregisterSystemContext();
}
}

View File

@ -4588,7 +4588,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
if (needRestart) {
try {
_itMgr.start(vm, null, user, caller);
_itMgr.start(vm.getUuid(), null);
} catch (Exception e) {
s_logger.debug("Unable to start VM " + vm.getUuid(), e);
CloudRuntimeException ex = new CloudRuntimeException(
@ -4598,8 +4598,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
}
}
s_logger.debug("Restore VM " + vmId + " with template "
+ template.getUuid() + " done successfully");
s_logger.debug("Restore VM " + vmId + " with template " + template.getUuid() + " done successfully");
return vm;
}

View File

@ -72,9 +72,9 @@ public interface VirtualMachineManager extends Manager {
DeploymentPlan plan,
HypervisorType hyperType) throws InsufficientCapacityException;
<T extends VMInstanceVO> T start(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException;
void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params);
<T extends VMInstanceVO> T start(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException, ResourceUnavailableException;
void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy);
<T extends VMInstanceVO> boolean stop(T vm, User caller, Account account) throws ResourceUnavailableException;
@ -84,9 +84,11 @@ public interface VirtualMachineManager extends Manager {
boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long hostId) throws NoTransitionException;
<T extends VMInstanceVO> T advanceStart(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException,
ConcurrentOperationException, OperationTimedoutException;
<T extends VMInstanceVO> T advanceStart(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
<T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;

View File

@ -39,6 +39,7 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
@ -603,17 +604,20 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
}
@Override
public <T extends VMInstanceVO> T start(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException {
return start(vm, params, caller, account, null);
public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) {
start(vmUuid, params, null);
}
@Override
public <T extends VMInstanceVO> T start(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
ResourceUnavailableException {
public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) {
try {
return advanceStart(vm, params, caller, account, planToDeploy);
advanceStart(vmUuid, params, planToDeploy);
} catch (ConcurrentOperationException e) {
throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e);
throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e).add(VirtualMachine.class, vmUuid);
} catch (InsufficientCapacityException e) {
throw new CloudRuntimeException("Unable to start a VM due to insufficient capacity", e).add(VirtualMachine.class, vmUuid);
} catch (ResourceUnavailableException e) {
throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e).add(VirtualMachine.class, vmUuid);
}
}
@ -651,7 +655,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
}
@DB
protected <T extends VMInstanceVO> Ternary<T, ReservationContext, ItWorkVO> changeToStartState(VirtualMachineGuru<T> vmGuru, T vm, User caller, Account account)
protected Ternary<VMInstanceVO, ReservationContext, ItWorkVO> changeToStartState(VirtualMachineGuru vmGuru, VMInstanceVO vm, User caller, Account account)
throws ConcurrentOperationException {
long vmId = vm.getId();
@ -659,7 +663,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
int retry = _lockStateRetry;
while (retry-- != 0) {
Transaction txn = Transaction.currentTxn();
Ternary<T, ReservationContext, ItWorkVO> result = null;
Ternary<VMInstanceVO, ReservationContext, ItWorkVO> result = null;
txn.start();
try {
Journal journal = new Journal.LogJournal("Creating " + vm, s_logger);
@ -670,7 +674,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (s_logger.isDebugEnabled()) {
s_logger.debug("Successfully transitioned to start state for " + vm + " reservation id = " + work.getId());
}
result = new Ternary<T, ReservationContext, ItWorkVO>(vmGuru.findById(vmId), context, work);
result = new Ternary<VMInstanceVO, ReservationContext, ItWorkVO>(vm, context, work);
txn.commit();
return result;
}
@ -744,28 +748,33 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
}
@Override
public <T extends VMInstanceVO> T advanceStart(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException,
ConcurrentOperationException, ResourceUnavailableException {
return advanceStart(vm, params, caller, account, null);
public void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
advanceStart(vmUuid, params, null);
}
@Override
public <T extends VMInstanceVO> T advanceStart(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy)
public void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
long vmId = vm.getId();
VirtualMachineGuru<T> vmGuru = getVmGuru(vm);
CallContext cctxt = CallContext.current();
Account account = cctxt.getCallingAccount();
User caller = cctxt.getCallingUser();
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
vm = vmGuru.findById(vm.getId());
Ternary<T, ReservationContext, ItWorkVO> start = changeToStartState(vmGuru, vm, caller, account);
long vmId = vm.getId();
VirtualMachineGuru<?> vmGuru = getVmGuru(vm);
Ternary<VMInstanceVO, ReservationContext, ItWorkVO> start = changeToStartState(vmGuru, vm, caller, account);
if (start == null) {
return vmGuru.findById(vmId);
return;
}
vm = start.first();
ReservationContext ctx = start.second();
ItWorkVO work = start.third();
T startedVm = null;
VMInstanceVO startedVm = null;
ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
@ -845,7 +854,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
}
}
plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), vol.getPoolId(), null, ctx);
}else{
} else {
plan = new DataCenterDeployment(rootVolDcId, rootVolPodId, rootVolClusterId, null, vol.getPoolId(), null, ctx);
if (s_logger.isDebugEnabled()) {
s_logger.debug(vol + " is READY, changing deployment plan to use this pool's dcId: " + rootVolDcId + " , podId: " + rootVolPodId + " , and clusterId: " + rootVolClusterId);
@ -856,7 +865,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
}
}
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, template, offering, account, params);
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, template, offering, account, params);
DeployDestination dest = null;
try {
dest = _dpMgr.planDeployment(vmProfile, plan, avoids);
@ -955,7 +964,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (s_logger.isDebugEnabled()) {
s_logger.debug("Start completed for VM " + vm);
}
return startedVm;
return;
} else {
if (s_logger.isDebugEnabled()) {
s_logger.info("The guru did not like the answers so stopping " + vm);
@ -1037,7 +1046,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
+ "' (" + vm.getUuid() + "), see management server log for details");
}
return startedVm;
return;
}
@Override
@ -1075,8 +1084,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
return true;
}
protected <T extends VMInstanceVO> boolean cleanup(VirtualMachineGuru<T> guru, VirtualMachineProfile<T> profile, ItWorkVO work, Event event, boolean force, User user, Account account) {
T vm = profile.getVirtualMachine();
protected boolean cleanup(VirtualMachineGuru guru, VirtualMachineProfile profile, ItWorkVO work, Event event, boolean force, User user, Account account) {
VirtualMachine vm = profile.getVirtualMachine();
State state = vm.getState();
s_logger.debug("Cleaning up resources for the vm " + vm + " in " + state + " state");
if (state == State.Starting) {

View File

@ -27,15 +27,15 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
@ -61,8 +61,8 @@ import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
import com.cloud.hypervisor.HypervisorGuruManager;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
import com.cloud.projects.Project.ListProjectResourcesCriteria;
import com.cloud.storage.GuestOSVO;
import com.cloud.storage.Snapshot;
@ -205,7 +205,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
}
if (state == null) {
VMSnapshot.State[] status = { VMSnapshot.State.Ready, VMSnapshot.State.Creating, VMSnapshot.State.Allocated,
VMSnapshot.State[] status = { VMSnapshot.State.Ready, VMSnapshot.State.Creating, VMSnapshot.State.Allocated,
VMSnapshot.State.Error, VMSnapshot.State.Expunging, VMSnapshot.State.Reverting };
sc.setParameters("status", (Object[]) status);
} else {
@ -237,7 +237,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
}
@Override
public VMSnapshot allocVMSnapshot(Long vmId, String vsDisplayName, String vsDescription, Boolean snapshotMemory)
public VMSnapshot allocVMSnapshot(Long vmId, String vsDisplayName, String vsDescription, Boolean snapshotMemory)
throws ResourceAllocationException {
Account caller = getCaller();
@ -265,7 +265,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
vsDisplayName = vmSnapshotName;
}
if(_vmSnapshotDao.findByName(vmId,vsDisplayName) != null){
throw new InvalidParameterValueException("Creating VM snapshot failed due to VM snapshot with name" + vsDisplayName + " already exists");
throw new InvalidParameterValueException("Creating VM snapshot failed due to VM snapshot with name" + vsDisplayName + " already exists");
}
// check VM state
@ -322,7 +322,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
} catch (Exception e) {
String msg = e.getMessage();
s_logger.error("Create vm snapshot record failed for vm: " + vmId + " due to: " + msg);
}
}
return null;
}
@ -352,7 +352,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
}
protected VMSnapshot createVmSnapshotInternal(UserVmVO userVm, VMSnapshotVO vmSnapshot, Long hostId) {
try {
try {
CreateVMSnapshotAnswer answer = null;
GuestOSVO guestOS = _guestOSDao.findById(userVm.getGuestOSId());
@ -412,7 +412,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
List<VolumeVO> volumeVos = _volumeDao.findByInstance(vmId);
for (VolumeVO volume : volumeVos) {
StoragePool pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
StoragePool pool = (StoragePool)dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
VolumeTO volumeTO = new VolumeTO(volume, pool);
volumeTOs.add(volumeTO);
}
@ -488,7 +488,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
_vmSnapshotDao.persist(child);
}
// update current snapshot
// update current snapshot
VMSnapshotVO current = _vmSnapshotDao.findCurrentSnapshotByVmId(vmSnapshot.getVmId());
if(current != null && current.getId() == vmSnapshot.getId() && vmSnapshot.getParent() != null){
VMSnapshotVO parent = _vmSnapshotDao.findById(vmSnapshot.getParent());
@ -550,7 +550,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
@Override
public boolean hasActiveVMSnapshotTasks(Long vmId){
List<VMSnapshotVO> activeVMSnapshots = _vmSnapshotDao.listByInstanceId(vmId,
List<VMSnapshotVO> activeVMSnapshots = _vmSnapshotDao.listByInstanceId(vmId,
VMSnapshot.State.Creating, VMSnapshot.State.Expunging,VMSnapshot.State.Reverting,VMSnapshot.State.Allocated);
return activeVMSnapshots.size() > 0;
}
@ -602,7 +602,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
// prepare DeleteVMSnapshotCommand
String vmInstanceName = userVm.getInstanceName();
VMSnapshotTO parent = getSnapshotWithParents(vmSnapshot).getParent();
VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(),
VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(),
vmSnapshot.getCreated().getTime(), vmSnapshot.getDescription(), vmSnapshot.getCurrent(), parent);
GuestOSVO guestOS = _guestOSDao.findById(userVm.getGuestOSId());
DeleteVMSnapshotCommand deleteSnapshotCommand = new DeleteVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs,guestOS.getDisplayName());
@ -673,7 +673,8 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
// start or stop VM first, if revert from stopped state to running state, or from running to stopped
if(userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory){
try {
vm = _itMgr.advanceStart(userVm, new HashMap<VirtualMachineProfile.Param, Object>(), callerUser, owner);
_itMgr.advanceStart(userVm.getUuid(), new HashMap<VirtualMachineProfile.Param, Object>());
vm = _userVMDao.findById(userVm.getId());
hostId = vm.getHostId();
} catch (Exception e) {
s_logger.error("Start VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage());
@ -715,7 +716,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
List<VolumeTO> volumeTOs = getVolumeTOList(userVm.getId());
String vmInstanceName = userVm.getInstanceName();
VMSnapshotTO parent = getSnapshotWithParents(snapshot).getParent();
VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(snapshot.getId(), snapshot.getName(), snapshot.getType(),
VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(snapshot.getId(), snapshot.getName(), snapshot.getType(),
snapshot.getCreated().getTime(), snapshot.getDescription(), snapshot.getCurrent(), parent);
GuestOSVO guestOS = _guestOSDao.findById(userVm.getGuestOSId());
@ -746,7 +747,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
String errMsg = "revert vm: " + userVm.getInstanceName() + " to snapshot " + vmSnapshotVo.getName() + " failed due to " + e.getMessage();
s_logger.error(errMsg);
throw new CloudRuntimeException(e.getMessage());
}
}
return userVm;
}

View File

@ -198,7 +198,6 @@ public class UserVmManagerTest {
doReturn(3L).when(_volumeMock).getTemplateId();
when(_templateDao.findById(anyLong())).thenReturn(_templateMock);
when(_itMgr.stop(_vmMock, _userMock, _account)).thenReturn(true);
when(_itMgr.start(_vmMock, null, _userMock, _account)).thenReturn(_vmMock);
when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock);
doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong());
when(_volumeMock.getId()).thenReturn(3L);
@ -237,7 +236,6 @@ public class UserVmManagerTest {
doNothing().when(_vmMock).setGuestOSId(anyLong());
doNothing().when(_vmMock).setTemplateId(3L);
when(_vmDao.update(314L, _vmMock)).thenReturn(true);
when(_itMgr.start(_vmMock, null, _userMock, _account)).thenReturn(_vmMock);
when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock);
doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong());
when(_volumeMock.getId()).thenReturn(3L);
@ -278,7 +276,6 @@ public class UserVmManagerTest {
doNothing().when(_vmMock).setGuestOSId(anyLong());
doNothing().when(_vmMock).setTemplateId(3L);
when(_vmDao.update(314L, _vmMock)).thenReturn(true);
when(_itMgr.start(_vmMock, null, _userMock, _account)).thenReturn(_vmMock);
when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock);
doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong());
when(_volumeMock.getId()).thenReturn(3L);