mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
move all the vm's state machine to itmgr->statetransitTO
This commit is contained in:
parent
2e3ef1408c
commit
d17beeb348
@ -31,6 +31,7 @@ import com.cloud.exception.DiscoveryException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
@ -155,7 +156,7 @@ public interface AgentManager extends Manager {
|
||||
* to deploy in, service offering, template, and list of host to avoid.
|
||||
*/
|
||||
|
||||
Host findHost(Host.Type type, DataCenterVO dc, HostPodVO pod, StoragePoolVO sp, ServiceOffering offering, VMTemplateVO template, VMInstanceVO vm, Host currentHost, Set<Host> avoid);
|
||||
Host findHost(Host.Type type, DataCenterVO dc, HostPodVO pod, StoragePoolVO sp, ServiceOfferingVO offering, VMTemplateVO template, VMInstanceVO vm, Host currentHost, Set<Host> avoid);
|
||||
List<PodCluster> listByDataCenter(long dcId);
|
||||
List<PodCluster> listByPod(long podId);
|
||||
|
||||
@ -212,4 +213,5 @@ public interface AgentManager extends Manager {
|
||||
public List<HostVO> discoverHosts(Long dcId, Long podId, Long clusterId, String clusterName, String url, String username, String password) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
|
||||
|
||||
Answer easySend(Long hostId, Command cmd, int timeout);
|
||||
|
||||
}
|
||||
|
||||
@ -95,10 +95,15 @@ import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlanner;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConnectionException;
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.UnsupportedVersionException;
|
||||
@ -218,6 +223,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
||||
@Inject protected DetailsDao _hostDetailsDao = null;
|
||||
@Inject protected ClusterDao _clusterDao;
|
||||
|
||||
@Inject(adapter=DeploymentPlanner.class)
|
||||
private Adapters<DeploymentPlanner> _planners;
|
||||
|
||||
protected Adapters<Discoverer> _discoverers = null;
|
||||
protected int _port;
|
||||
|
||||
@ -434,24 +442,33 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
||||
|
||||
@Override
|
||||
public Host findHost(final Host.Type type, final DataCenterVO dc, final HostPodVO pod, final StoragePoolVO sp,
|
||||
final ServiceOffering offering, final VMTemplateVO template, VMInstanceVO vm,
|
||||
final ServiceOfferingVO offering, final VMTemplateVO template, VMInstanceVO vm,
|
||||
Host currentHost, final Set<Host> avoid) {
|
||||
VirtualMachineProfile<VMInstanceVO> vmc = new VirtualMachineProfileImpl<VMInstanceVO>(vm.getType());
|
||||
Enumeration<HostAllocator> en = _hostAllocators.enumeration();
|
||||
while (en.hasMoreElements()) {
|
||||
final HostAllocator allocator = en.nextElement();
|
||||
final Host host = allocator.allocateTo(vmc, offering, type, dc, pod, sp.getClusterId(), template, avoid);
|
||||
if (host == null) {
|
||||
continue;
|
||||
} else {
|
||||
return host;
|
||||
}
|
||||
VirtualMachineProfileImpl<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(vm, template, offering, null, null);
|
||||
DeployDestination dest = null;
|
||||
DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), pod.getId(), sp.getClusterId(), null);
|
||||
ExcludeList avoids = new ExcludeList();
|
||||
for (Host h : avoid) {
|
||||
avoids.addHost(h.getId());
|
||||
}
|
||||
|
||||
for (DeploymentPlanner planner : _planners) {
|
||||
try {
|
||||
dest = planner.plan(vmProfile, plan, avoids);
|
||||
if (dest != null) {
|
||||
return dest.getHost();
|
||||
}
|
||||
} catch (InsufficientServerCapacityException e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
s_logger.warn("findHost() could not find a non-null host.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<PodCluster> listByDataCenter(long dcId) {
|
||||
List<HostPodVO> pods = _podDao.listByDataCenterId(dcId);
|
||||
|
||||
@ -32,6 +32,7 @@ import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.VmManager;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
@ -51,4 +52,5 @@ public interface AsyncJobExecutorContext extends Manager {
|
||||
public IPAddressDao getIpAddressDao();
|
||||
public AsyncJobDao getJobDao();
|
||||
public UserDao getUserDao();
|
||||
public VmManager getItMgr();
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.VmManager;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
@ -58,6 +59,7 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
||||
private IPAddressDao _ipAddressDao;
|
||||
private AsyncJobDao _jobDao;
|
||||
private UserDao _userDao;
|
||||
private VmManager _itMgr;
|
||||
|
||||
private ManagementServer _managementServer;
|
||||
|
||||
@ -139,6 +141,11 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
||||
return _userDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VmManager getItMgr() {
|
||||
return _itMgr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
@ -219,6 +226,10 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
||||
throw new ConfigurationException("unable to get " + UserDao.class.getName());
|
||||
}
|
||||
|
||||
_itMgr = locator.getManager(VmManager.class);
|
||||
if (_itMgr == null) {
|
||||
throw new ConfigurationException("unable to get " + VmManager.class.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ public class DestroyVMExecutor extends VMOperationExecutor {
|
||||
txn.start();
|
||||
|
||||
asyncMgr.getExecutorContext().getAccountMgr().decrementResourceCount(vm.getAccountId(), ResourceType.user_vm);
|
||||
if (!asyncMgr.getExecutorContext().getVmDao().updateIf(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) {
|
||||
if (!asyncMgr.getExecutorContext().getItMgr().stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) {
|
||||
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm.toString());
|
||||
|
||||
txn.rollback();
|
||||
@ -130,7 +130,7 @@ public class DestroyVMExecutor extends VMOperationExecutor {
|
||||
|
||||
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0, "success");
|
||||
} else {
|
||||
asyncMgr.getExecutorContext().getVmDao().updateIf(vm, Event.OperationFailed, vm.getHostId());
|
||||
asyncMgr.getExecutorContext().getItMgr().stateTransitTo(vm, Event.OperationFailed, vm.getHostId());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "Agent failed to stop VM: " + vm.getHostName());
|
||||
// managementServer.saveEvent(param.getUserId(), vm.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_STOP,
|
||||
|
||||
@ -92,7 +92,7 @@ public class StopVMExecutor extends VMOperationExecutor {
|
||||
AsyncJobResult.STATUS_SUCCEEDED, 0, VMExecutorHelper.composeResultObject(asyncMgr.getExecutorContext().getManagementServer(), vm, null));
|
||||
jobStatusUpdated = true;
|
||||
} else {
|
||||
asyncMgr.getExecutorContext().getVmDao().updateIf(vm, Event.OperationFailed, vm.getHostId());
|
||||
asyncMgr.getExecutorContext().getItMgr().stateTransitTo(vm, Event.OperationFailed, vm.getHostId());
|
||||
asyncMgr.completeAsyncJob(getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR, "Agent failed to stop VM");
|
||||
jobStatusUpdated = true;
|
||||
|
||||
@ -632,7 +632,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
}
|
||||
}
|
||||
// to ensure atomic state transition to Starting state
|
||||
if (!_consoleProxyDao.updateIf(proxy, com.cloud.vm.VirtualMachine.Event.StartRequested, routingHost.getId())) {
|
||||
if (!_itMgr.stateTransitTo(proxy, com.cloud.vm.VirtualMachine.Event.StartRequested, routingHost.getId())) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
ConsoleProxyVO temp = _consoleProxyDao.findById(proxyId);
|
||||
s_logger.debug("Unable to start console proxy " + proxy.getHostName() + " because it is not in a startable state : "
|
||||
@ -664,7 +664,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
String guestIpAddress = _dcDao.allocateLinkLocalIpAddress(proxy.getDataCenterId(), routingHost.getPodId(), proxy.getId(), null);
|
||||
proxy.setGuestIpAddress(guestIpAddress);
|
||||
|
||||
_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.OperationRetry, routingHost.getId());
|
||||
_itMgr.stateTransitTo(proxy, VirtualMachine.Event.OperationRetry, routingHost.getId());
|
||||
proxy = _consoleProxyDao.findById(proxy.getId());
|
||||
|
||||
List<VolumeVO> vols = _storageMgr.prepare(proxy, routingHost);
|
||||
@ -768,7 +768,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
throw new ExecutionException("Couldn't find a routingHost to run console proxy");
|
||||
}
|
||||
|
||||
_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.OperationSucceeded, routingHost.getId());
|
||||
_itMgr.stateTransitTo(proxy, VirtualMachine.Event.OperationSucceeded, routingHost.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Console proxy is now started, vm id : " + proxy.getId());
|
||||
}
|
||||
@ -817,7 +817,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
freePrivateIpAddress(privateIpAddress, proxy.getDataCenterId(), proxy.getId());
|
||||
}
|
||||
|
||||
_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.OperationFailed, null);
|
||||
_itMgr.stateTransitTo(proxy, VirtualMachine.Event.OperationFailed, null);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Caught exception during error recovery");
|
||||
@ -1120,7 +1120,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
_consoleProxyDao.update(proxy.getId(), vo);
|
||||
|
||||
// kick the state machine
|
||||
_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.OperationSucceeded, null);
|
||||
_itMgr.stateTransitTo(proxy, VirtualMachine.Event.OperationSucceeded, null);
|
||||
|
||||
txn.commit();
|
||||
return proxy;
|
||||
@ -1788,7 +1788,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
|
||||
@Override
|
||||
public void completeStartCommand(ConsoleProxyVO vm) {
|
||||
_consoleProxyDao.updateIf(vm, VirtualMachine.Event.AgentReportRunning, vm.getHostId());
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.AgentReportRunning, vm.getHostId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1812,7 +1812,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
_dcDao.releaseLinkLocalIpAddress(guestIpAddress, proxy.getDataCenterId(), proxy.getId());
|
||||
}
|
||||
|
||||
if (!_consoleProxyDao.updateIf(proxy, ev, null)) {
|
||||
if (!_itMgr.stateTransitTo(proxy, ev, null)) {
|
||||
s_logger.debug("Unable to update the console proxy");
|
||||
return;
|
||||
}
|
||||
@ -1969,7 +1969,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
s_logger.debug("Destroying console proxy vm " + vmId);
|
||||
}
|
||||
|
||||
if (!_consoleProxyDao.updateIf(vm, VirtualMachine.Event.DestroyRequested, null)) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, null)) {
|
||||
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vmId);
|
||||
return false;
|
||||
}
|
||||
@ -2050,7 +2050,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
|
||||
@Override
|
||||
public boolean stop(ConsoleProxyVO proxy, long startEventId) throws AgentUnavailableException {
|
||||
if (!_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.StopRequested, proxy.getHostId())) {
|
||||
if (!_itMgr.stateTransitTo(proxy, VirtualMachine.Event.StopRequested, proxy.getHostId())) {
|
||||
s_logger.debug("Unable to stop console proxy: " + proxy.toString());
|
||||
return false;
|
||||
}
|
||||
@ -2129,7 +2129,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
public boolean migrate(ConsoleProxyVO proxy, HostVO host) {
|
||||
HostVO fromHost = _hostDao.findById(proxy.getId());
|
||||
|
||||
if (!_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.MigrationRequested, proxy.getHostId())) {
|
||||
if (! _itMgr.stateTransitTo(proxy, VirtualMachine.Event.MigrationRequested, proxy.getHostId())) {
|
||||
s_logger.debug("State for " + proxy.toString() + " has changed so migration can not take place.");
|
||||
return false;
|
||||
}
|
||||
@ -2152,18 +2152,18 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer) _agentMgr.send(host.getId(), cvm);
|
||||
if (!answer.getResult()) {
|
||||
s_logger.debug("Unable to complete migration for " + proxy.getId());
|
||||
_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.AgentReportStopped, null);
|
||||
_itMgr.stateTransitTo(proxy, VirtualMachine.Event.AgentReportStopped, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
State state = answer.getState();
|
||||
if (state == State.Stopped) {
|
||||
s_logger.warn("Unable to complete migration as we can not detect it on " + host.getId());
|
||||
_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.AgentReportStopped, null);
|
||||
_itMgr.stateTransitTo(proxy, VirtualMachine.Event.AgentReportStopped, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
_consoleProxyDao.updateIf(proxy, VirtualMachine.Event.OperationSucceeded, host.getId());
|
||||
_itMgr.stateTransitTo(proxy, VirtualMachine.Event.OperationSucceeded, host.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cloud.deploy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -15,12 +16,20 @@ import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.host.DetailVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.DetailsDao;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.storage.GuestOSCategoryVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
@ -33,6 +42,9 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
@Inject private DataCenterDao _dcDao;
|
||||
@Inject private HostPodDao _podDao;
|
||||
@Inject private ClusterDao _clusterDao;
|
||||
@Inject DetailsDao _hostDetailsDao = null;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject GuestOSCategoryDao _guestOSCategoryDao = null;
|
||||
|
||||
@Override
|
||||
public DeployDestination plan(VirtualMachineProfile vmProfile,
|
||||
@ -42,13 +54,13 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
ServiceOffering offering = vmProfile.getServiceOffering();
|
||||
DataCenter dc = _dcDao.findById(vm.getDataCenterId());
|
||||
int cpu_requested = offering.getCpu() * offering.getSpeed();
|
||||
int ram_requested = offering.getRamSize();
|
||||
long ram_requested = offering.getRamSize() * 1024L * 1024L;
|
||||
|
||||
if (vm.getLastHostId() != null) {
|
||||
HostVO host = _hostDao.findById(vm.getLastHostId());
|
||||
|
||||
if (host.getStatus() == Status.Up) {
|
||||
boolean canDepployToLastHost = deployToHost(vm.getLastHostId(), cpu_requested, ram_requested, true);
|
||||
boolean canDepployToLastHost = deployToHost(host, cpu_requested, ram_requested, true, avoid);
|
||||
if (canDepployToLastHost) {
|
||||
Pod pod = _podDao.findById(vm.getPodId());
|
||||
Cluster cluster = _clusterDao.findById(host.getClusterId());
|
||||
@ -58,12 +70,25 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
}
|
||||
|
||||
/*Go through all the pods/clusters under zone*/
|
||||
List<HostPodVO> pods = _podDao.listByDataCenterId(plan.getDataCenterId());
|
||||
List<HostPodVO> pods;
|
||||
if (plan.getPodId() != null) {
|
||||
pods = new ArrayList<HostPodVO>(1);
|
||||
pods.add(_podDao.findById(plan.getPodId()));
|
||||
} else {
|
||||
pods = _podDao.listByDataCenterId(plan.getDataCenterId());
|
||||
}
|
||||
//Collections.shuffle(pods);
|
||||
|
||||
for (HostPodVO hostPod : pods) {
|
||||
List<ClusterVO> clusters = _clusterDao.listByPodId(hostPod.getId());
|
||||
|
||||
//Collections.shuffle(clusters);
|
||||
List<ClusterVO> clusters;
|
||||
if (plan.getClusterId() != null) {
|
||||
clusters = new ArrayList<ClusterVO>(1);
|
||||
clusters.add(_clusterDao.findById(plan.getClusterId()));
|
||||
} else {
|
||||
clusters = _clusterDao.listByPodId(hostPod.getId());
|
||||
}
|
||||
|
||||
for (ClusterVO clusterVO : clusters) {
|
||||
|
||||
@ -71,20 +96,15 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listByCluster(clusterVO.getId());
|
||||
List<HostVO> hosts = _hostDao.listBy(Host.Type.Routing, clusterVO.getId(), hostPod.getId(), dc.getId());
|
||||
//Collections.shuffle(hosts);
|
||||
|
||||
// We will try to reorder the host lists such that we give priority to hosts that have
|
||||
// the minimums to support a VM's requirements
|
||||
hosts = prioritizeHosts(vmProfile.getTemplate(), hosts);
|
||||
|
||||
for (HostVO hostVO : hosts) {
|
||||
if (hostVO.getStatus() != Status.Up) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (avoid.shouldAvoid(hostVO)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean canDeployToHost = deployToHost(hostVO.getId(), cpu_requested, ram_requested, false);
|
||||
boolean canDeployToHost = deployToHost(hostVO, cpu_requested, ram_requested, false, avoid);
|
||||
if (canDeployToHost) {
|
||||
Pod pod = _podDao.findById(hostPod.getId());
|
||||
Cluster cluster = _clusterDao.findById(clusterVO.getId());
|
||||
@ -107,10 +127,13 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
}
|
||||
|
||||
@DB
|
||||
protected boolean deployToHost(Long hostId, Integer cpu, long ram, boolean fromLastHost) {
|
||||
protected boolean deployToHost(HostVO host, Integer cpu, long ram, boolean fromLastHost, ExcludeList avoid) {
|
||||
if (avoid.shouldAvoid(host)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CapacityVO capacityCpu = _capacityDao.findByHostIdType(hostId, CapacityVO.CAPACITY_TYPE_CPU);
|
||||
CapacityVO capacityMem = _capacityDao.findByHostIdType(hostId, CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
CapacityVO capacityCpu = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_CPU);
|
||||
CapacityVO capacityMem = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
@ -158,4 +181,109 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
}
|
||||
}
|
||||
|
||||
protected List<HostVO> prioritizeHosts(VirtualMachineTemplate template, List<HostVO> hosts) {
|
||||
if (template == null) {
|
||||
return hosts;
|
||||
}
|
||||
|
||||
// Determine the guest OS category of the template
|
||||
String templateGuestOSCategory = getTemplateGuestOSCategory(template);
|
||||
|
||||
List<HostVO> prioritizedHosts = new ArrayList<HostVO>();
|
||||
|
||||
// If a template requires HVM and a host doesn't support HVM, remove it from consideration
|
||||
List<HostVO> hostsToCheck = new ArrayList<HostVO>();
|
||||
if (template.isRequiresHvm()) {
|
||||
for (HostVO host : hosts) {
|
||||
if (hostSupportsHVM(host)) {
|
||||
hostsToCheck.add(host);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hostsToCheck.addAll(hosts);
|
||||
}
|
||||
|
||||
// If a host is tagged with the same guest OS category as the template, move it to a high priority list
|
||||
// If a host is tagged with a different guest OS category than the template, move it to a low priority list
|
||||
List<HostVO> highPriorityHosts = new ArrayList<HostVO>();
|
||||
List<HostVO> lowPriorityHosts = new ArrayList<HostVO>();
|
||||
for (HostVO host : hostsToCheck) {
|
||||
String hostGuestOSCategory = getHostGuestOSCategory(host);
|
||||
if (hostGuestOSCategory == null) {
|
||||
continue;
|
||||
} else if (templateGuestOSCategory.equals(hostGuestOSCategory)) {
|
||||
highPriorityHosts.add(host);
|
||||
} else {
|
||||
lowPriorityHosts.add(host);
|
||||
}
|
||||
}
|
||||
|
||||
hostsToCheck.removeAll(highPriorityHosts);
|
||||
hostsToCheck.removeAll(lowPriorityHosts);
|
||||
|
||||
// Prioritize the remaining hosts by HVM capability
|
||||
for (HostVO host : hostsToCheck) {
|
||||
if (!template.isRequiresHvm() && !hostSupportsHVM(host)) {
|
||||
// Host and template both do not support hvm, put it as first consideration
|
||||
prioritizedHosts.add(0, host);
|
||||
} else {
|
||||
// Template doesn't require hvm, but the machine supports it, make it last for consideration
|
||||
prioritizedHosts.add(host);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge the lists
|
||||
prioritizedHosts.addAll(0, highPriorityHosts);
|
||||
prioritizedHosts.addAll(lowPriorityHosts);
|
||||
|
||||
return prioritizedHosts;
|
||||
}
|
||||
|
||||
protected boolean hostSupportsHVM(HostVO host) {
|
||||
// Determine host capabilities
|
||||
String caps = host.getCapabilities();
|
||||
|
||||
if (caps != null) {
|
||||
String[] tokens = caps.split(",");
|
||||
for (String token : tokens) {
|
||||
if (token.contains("hvm")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String getHostGuestOSCategory(HostVO host) {
|
||||
DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), "guest.os.category.id");
|
||||
if (hostDetail != null) {
|
||||
String guestOSCategoryIdString = hostDetail.getValue();
|
||||
long guestOSCategoryId;
|
||||
|
||||
try {
|
||||
guestOSCategoryId = Long.parseLong(guestOSCategoryIdString);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
|
||||
|
||||
if (guestOSCategory != null) {
|
||||
return guestOSCategory.getName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getTemplateGuestOSCategory(VirtualMachineTemplate template) {
|
||||
long guestOSId = template.getGuestOSId();
|
||||
GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
|
||||
long guestOSCategoryId = guestOS.getCategoryId();
|
||||
GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
|
||||
return guestOSCategory.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
_eventDao.persist(event);
|
||||
throw new ExecutionException("Unable to create DHCP Server");
|
||||
}
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.OperationSucceeded, null);
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.OperationSucceeded, null);
|
||||
|
||||
s_logger.info("DHCP server created: id=" + router.getId() + "; name=" + router.getHostName() + "; vlan=" + guestVlan.getVlanId() + "; pod=" + pod.getName());
|
||||
|
||||
@ -551,7 +551,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
_eventDao.persist(event);
|
||||
throw new ExecutionException("Unable to create DomainRouter");
|
||||
}
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.OperationSucceeded, null);
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.OperationSucceeded, null);
|
||||
|
||||
s_logger.debug("Router created: id=" + router.getId() + "; name=" + router.getHostName());
|
||||
|
||||
@ -632,7 +632,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
return false;
|
||||
}
|
||||
router = _routerDao.findById(routerId);
|
||||
if (!_routerDao.updateIf(router, VirtualMachine.Event.DestroyRequested, router.getHostId())) {
|
||||
if (! _itMgr.stateTransitTo(router, VirtualMachine.Event.DestroyRequested, router.getHostId())) {
|
||||
s_logger.debug("VM " + router.toString() + " is not in a state to be destroyed.");
|
||||
return false;
|
||||
}
|
||||
@ -855,7 +855,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!_routerDao.updateIf(router, VirtualMachine.Event.StartRequested, routingHost.getId())) {
|
||||
if (! _itMgr.stateTransitTo(router, VirtualMachine.Event.StartRequested, routingHost.getId())) {
|
||||
s_logger.debug("Unable to start router " + router.toString() + " because it is not in a startable state");
|
||||
throw new ConcurrentOperationException("Someone else is starting the router: " + router.toString());
|
||||
}
|
||||
@ -964,7 +964,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
|
||||
}
|
||||
router.setDomain(networkDomain);
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.OperationRetry, routingHost.getId());
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.OperationRetry, routingHost.getId());
|
||||
|
||||
List<VolumeVO> vols = _storageMgr.prepare(router, routingHost);
|
||||
if (vols == null) {
|
||||
@ -1047,7 +1047,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
throw new ExecutionException("Couldn't find a routingHost");
|
||||
}
|
||||
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.OperationSucceeded, routingHost.getId());
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.OperationSucceeded, routingHost.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Router " + router.toString() + " is now started on " + routingHost.toString());
|
||||
}
|
||||
@ -1088,7 +1088,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
}
|
||||
|
||||
|
||||
if (_routerDao.updateIf(router, VirtualMachine.Event.OperationFailed, null)) {
|
||||
if ( _itMgr.stateTransitTo(router, VirtualMachine.Event.OperationFailed, null)) {
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@ -1570,7 +1570,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
|
||||
@Override
|
||||
public void completeStartCommand(final DomainRouterVO router) {
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.AgentReportRunning, router.getHostId());
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.AgentReportRunning, router.getHostId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1602,7 +1602,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
}
|
||||
router.setPrivateIpAddress(null);
|
||||
|
||||
if (!_routerDao.updateIf(router, ev, null)) {
|
||||
if (! _itMgr.stateTransitTo(router, ev, null)) {
|
||||
s_logger.debug("Router is not updated");
|
||||
return;
|
||||
}
|
||||
@ -1699,7 +1699,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
event.setType(EventTypes.EVENT_ROUTER_STOP);
|
||||
event.setStartId(eventId);
|
||||
|
||||
if (!_routerDao.updateIf(router, VirtualMachine.Event.StopRequested, hostId)) {
|
||||
if (! _itMgr.stateTransitTo(router, VirtualMachine.Event.StopRequested, hostId)) {
|
||||
s_logger.debug("VM " + router.toString() + " is not in a state to be stopped.");
|
||||
return false;
|
||||
}
|
||||
@ -1734,7 +1734,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
event.setDescription("failed to stop Domain Router : " + router.getHostName());
|
||||
event.setLevel(EventVO.LEVEL_ERROR);
|
||||
_eventDao.persist(event);
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.OperationFailed, router.getHostId());
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.OperationFailed, router.getHostId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1811,7 +1811,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
public boolean migrate(final DomainRouterVO router, final HostVO host) {
|
||||
final HostVO fromHost = _hostDao.findById(router.getHostId());
|
||||
|
||||
if (!_routerDao.updateIf(router, VirtualMachine.Event.MigrationRequested, router.getHostId())) {
|
||||
if (! _itMgr.stateTransitTo(router, VirtualMachine.Event.MigrationRequested, router.getHostId())) {
|
||||
s_logger.debug("State for " + router.toString() + " has changed so migration can not take place.");
|
||||
return false;
|
||||
}
|
||||
@ -1838,18 +1838,18 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
final CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer)_agentMgr.send(host.getId(), cvm);
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.debug("Unable to complete migration for " + router.getId());
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.AgentReportStopped, null);
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.AgentReportStopped, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
final State state = answer.getState();
|
||||
if (state == State.Stopped) {
|
||||
s_logger.warn("Unable to complete migration as we can not detect it on " + host.getId());
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.AgentReportStopped, null);
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.AgentReportStopped, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
_routerDao.updateIf(router, VirtualMachine.Event.OperationSucceeded, host.getId());
|
||||
_itMgr.stateTransitTo(router, VirtualMachine.Event.OperationSucceeded, host.getId());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
}
|
||||
}
|
||||
// to ensure atomic state transition to Starting state
|
||||
if (!_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.StartRequested, routingHost.getId())) {
|
||||
if (! _itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.StartRequested, routingHost.getId())) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
SecondaryStorageVmVO temp = _secStorageVmDao.findById(secStorageVmId);
|
||||
s_logger.debug("Unable to start secondary storage vm "
|
||||
@ -391,7 +391,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
secStorageVm.setPrivateIpAddress(privateIpAddress);
|
||||
String guestIpAddress = _dcDao.allocateLinkLocalIpAddress(secStorageVm.getDataCenterId(), routingHost.getPodId(), secStorageVm.getId(), null);
|
||||
secStorageVm.setGuestIpAddress(guestIpAddress);
|
||||
_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.OperationRetry, routingHost.getId());
|
||||
_itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.OperationRetry, routingHost.getId());
|
||||
secStorageVm = _secStorageVmDao.findById(secStorageVm.getId());
|
||||
|
||||
List<VolumeVO> vols = _storageMgr.prepare(secStorageVm, routingHost);
|
||||
@ -504,7 +504,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
"Couldn't find a routingHost to run secondary storage vm");
|
||||
}
|
||||
|
||||
_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.OperationSucceeded, routingHost.getId());
|
||||
_itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.OperationSucceeded, routingHost.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Secondary storage vm is now started, vm id : " + secStorageVm.getId());
|
||||
}
|
||||
@ -544,7 +544,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
secStorageVm.setPrivateIpAddress(null);
|
||||
freePrivateIpAddress(privateIpAddress, secStorageVm.getDataCenterId(), secStorageVm.getId());
|
||||
}
|
||||
_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.OperationFailed, null);
|
||||
_itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.OperationFailed, null);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Caught exception during error recovery");
|
||||
@ -885,7 +885,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
}
|
||||
|
||||
// kick the state machine
|
||||
_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
_itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
return secStorageVm;
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.error("Unable to alloc storage for secondary storage vm: ", e);
|
||||
@ -1502,7 +1502,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
|
||||
@Override
|
||||
public void completeStartCommand(SecondaryStorageVmVO vm) {
|
||||
_secStorageVmDao.updateIf(vm, VirtualMachine.Event.AgentReportRunning, vm.getHostId());
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.AgentReportRunning, vm.getHostId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1525,7 +1525,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
secStorageVm.setGuestIpAddress(null);
|
||||
_dcDao.releaseLinkLocalIpAddress(guestIpAddress, secStorageVm.getDataCenterId(), secStorageVm.getId());
|
||||
}
|
||||
if (!_secStorageVmDao.updateIf(secStorageVm, ev, null)) {
|
||||
if (! _itMgr.stateTransitTo(secStorageVm, ev, null)) {
|
||||
s_logger.debug("Unable to update the secondary storage vm");
|
||||
return;
|
||||
}
|
||||
@ -1681,7 +1681,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
s_logger.debug("Destroying secondary storage vm vm " + vmId);
|
||||
}
|
||||
|
||||
if (!_secStorageVmDao.updateIf(vm, VirtualMachine.Event.DestroyRequested, null)) {
|
||||
if (! _itMgr.stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, null)) {
|
||||
String msg = "Unable to destroy the vm because it is not in the correct state: " + vmId;
|
||||
s_logger.debug(msg);
|
||||
saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_DESTROY, msg, startEventId);
|
||||
@ -1762,7 +1762,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
|
||||
@Override
|
||||
public boolean stop(SecondaryStorageVmVO secStorageVm, long startEventId) throws AgentUnavailableException {
|
||||
if (!_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.StopRequested, secStorageVm.getHostId())) {
|
||||
if (! _itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.StopRequested, secStorageVm.getHostId())) {
|
||||
String msg = "Unable to stop secondary storage vm: " + secStorageVm.toString();
|
||||
s_logger.debug(msg);
|
||||
saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_STOP, msg, startEventId);
|
||||
@ -1834,7 +1834,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
public boolean migrate(SecondaryStorageVmVO secStorageVm, HostVO host) {
|
||||
HostVO fromHost = _hostDao.findById(secStorageVm.getId());
|
||||
|
||||
if (!_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.MigrationRequested, secStorageVm.getHostId())) {
|
||||
if (! _itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.MigrationRequested, secStorageVm.getHostId())) {
|
||||
s_logger.debug("State for " + secStorageVm.toString() + " has changed so migration can not take place.");
|
||||
return false;
|
||||
}
|
||||
@ -1857,18 +1857,18 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer) _agentMgr.send(host.getId(), cvm);
|
||||
if (!answer.getResult()) {
|
||||
s_logger.debug("Unable to complete migration for " + secStorageVm.getId());
|
||||
_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.AgentReportStopped, null);
|
||||
_itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.AgentReportStopped, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
State state = answer.getState();
|
||||
if (state == State.Stopped) {
|
||||
s_logger.warn("Unable to complete migration as we can not detect it on " + host.getId());
|
||||
_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.AgentReportStopped, null);
|
||||
_itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.AgentReportStopped, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
_secStorageVmDao.updateIf(secStorageVm, VirtualMachine.Event.OperationSucceeded, host.getId());
|
||||
_itMgr.stateTransitTo(secStorageVm, VirtualMachine.Event.OperationSucceeded, host.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.vm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.AgentManager.OnError;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
import com.cloud.agent.api.Start2Command;
|
||||
import com.cloud.agent.api.StopAnswer;
|
||||
import com.cloud.agent.api.StopCommand;
|
||||
@ -43,6 +45,8 @@ import com.cloud.cluster.ManagementServerHostVO;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
@ -58,6 +62,8 @@ import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.network.NetworkVO;
|
||||
@ -67,7 +73,9 @@ import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@ -896,7 +896,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
StoragePoolVO sp = _storageMgr.getStoragePoolForVm(vm.getId());
|
||||
|
||||
VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
|
||||
ServiceOffering offering = _offeringDao.findById(vm.getServiceOfferingId());
|
||||
ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
|
||||
|
||||
// If an ISO path is passed in, boot from that ISO
|
||||
// Else, check if the VM already has an ISO attached to it. If so, start the VM with that ISO inserted, but don't boot from it.
|
||||
@ -945,7 +945,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.StartRequested, host.getId())) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.StartRequested, host.getId())) {
|
||||
String description = "Unable to start VM " + vm.toString() + " because the state is not correct.";
|
||||
s_logger.error(description);
|
||||
event.setDescription(description);
|
||||
@ -965,7 +965,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
router = _networkMgr.addVirtualMachineToGuestNetwork(vm, password, startEventId);
|
||||
if (router == null) {
|
||||
s_logger.error("Unable to add vm " + vm.getId() + " - " + vm.getHostName());
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.OperationFailed, null);
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, null);
|
||||
if(!vm.getHostName().equals(vm.getDisplayName())) {
|
||||
event.setDescription("Unable to start VM: " + vm.getHostName()+"("+vm.getDisplayName()+")" + "; Unable to add VM to guest network");
|
||||
} else {
|
||||
@ -1033,7 +1033,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
|
||||
|
||||
if( retry < _retry ) {
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.OperationRetry, host.getId())) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationRetry, host.getId())) {
|
||||
String description = "Unable to start VM " + vm.toString() + " because the state is not correct.";
|
||||
s_logger.debug(description);
|
||||
event.setDescription(description);
|
||||
@ -1125,7 +1125,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
throw new ExecutionException("Unable to start VM: " + vm.getHostName()+ " Reason: "+answer.getDetails());
|
||||
}
|
||||
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.OperationSucceeded, host.getId())) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationSucceeded, host.getId())) {
|
||||
if(!vm.getHostName().equals(vm.getDisplayName())) {
|
||||
event.setDescription("unable to start VM: " + vm.getHostName()+"("+vm.getDisplayName()+")");
|
||||
} else {
|
||||
@ -1158,7 +1158,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
vm.setVnet(null);
|
||||
|
||||
txn.start();
|
||||
if (_vmDao.updateIf(vm, VirtualMachine.Event.OperationFailed, null)) {
|
||||
if (_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, null)) {
|
||||
txn.commit();
|
||||
}
|
||||
}
|
||||
@ -1273,7 +1273,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.StopRequested, vm.getHostId())) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.StopRequested, vm.getHostId())) {
|
||||
resultDescription = "VM is not in a state to stop";
|
||||
executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
@ -1316,7 +1316,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
resultDescription = "Agent is not available";
|
||||
executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.OperationFailed, vm.getHostId());
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, vm.getHostId());
|
||||
response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
|
||||
return response;
|
||||
@ -1663,7 +1663,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
vm = _vmDao.persist(vm);
|
||||
} else {
|
||||
vm.setPodId(pod.first().getId());
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.OperationRetry, null);
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationRetry, null);
|
||||
}
|
||||
|
||||
String ipAddressStr = acquireGuestIpAddress(dataCenterId, accountId, vm);
|
||||
@ -1715,7 +1715,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
|
||||
_eventDao.persist(event);
|
||||
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("vm created " + vmId);
|
||||
}
|
||||
@ -1876,7 +1876,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
|
||||
_accountMgr.incrementResourceCount(account.getId(), ResourceType.user_vm);
|
||||
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.RecoveryRequested, null)) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.RecoveryRequested, null)) {
|
||||
s_logger.debug("Unable to recover the vm because it is not in the correct state: " + vmId);
|
||||
throw new InvalidParameterValueException("Unable to recover the vm because it is not in the correct state: " + vmId);
|
||||
}
|
||||
@ -2010,7 +2010,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
|
||||
@Override
|
||||
public void completeStartCommand(UserVmVO vm) {
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.AgentReportRunning, vm.getHostId());
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.AgentReportRunning, vm.getHostId());
|
||||
_networkGroupMgr.handleVmStateTransition(vm, State.Running);
|
||||
|
||||
}
|
||||
@ -2032,7 +2032,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
|
||||
txn.start();
|
||||
|
||||
if (!_vmDao.updateIf(vm, e, null)) {
|
||||
if (!_itMgr.stateTransitTo(vm, e, null)) {
|
||||
s_logger.debug("Unable to update ");
|
||||
return;
|
||||
}
|
||||
@ -2111,7 +2111,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.StopRequested, vm.getHostId())) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.StopRequested, vm.getHostId())) {
|
||||
s_logger.debug("VM is not in a state to stop: " + vm.getState().toString());
|
||||
return false;
|
||||
}
|
||||
@ -2155,7 +2155,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
}
|
||||
event.setLevel(EventVO.LEVEL_ERROR);
|
||||
_eventDao.persist(event);
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.OperationFailed, vm.getHostId());
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, vm.getHostId());
|
||||
s_logger.error("Unable to stop vm " + vm.getHostName());
|
||||
}
|
||||
|
||||
@ -2167,7 +2167,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Destroying vm " + vm.toString());
|
||||
}
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) {
|
||||
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm.toString());
|
||||
return false;
|
||||
}
|
||||
@ -2234,7 +2234,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
public boolean migrate(UserVmVO vm, HostVO host) throws AgentUnavailableException, OperationTimedoutException {
|
||||
HostVO fromHost = _hostDao.findById(vm.getHostId());
|
||||
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.MigrationRequested, vm.getHostId())) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.MigrationRequested, vm.getHostId())) {
|
||||
s_logger.debug("State for " + vm.toString() + " has changed so migration can not take place.");
|
||||
return false;
|
||||
}
|
||||
@ -2266,7 +2266,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
releaseGuestIpAddress(vm);
|
||||
vm.setGuestNetmask(null);
|
||||
vm.setGuestMacAddress(null);
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.ExpungeOperation, null)) {
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.ExpungeOperation, null)) {
|
||||
s_logger.info("vm " + vmId + " is skipped because it is no longer in Destroyed state");
|
||||
continue;
|
||||
}
|
||||
@ -2335,14 +2335,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer)_agentMgr.send(host.getId(), cvm);
|
||||
if (!answer.getResult()) {
|
||||
s_logger.debug("Unable to complete migration for " + vm.toString());
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.AgentReportStopped, null);
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
State state = answer.getState();
|
||||
if (state == State.Stopped) {
|
||||
s_logger.warn("Unable to complete migration as we can not detect it on " + host.toString());
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.AgentReportStopped, null);
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2353,7 +2353,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.OperationSucceeded, host.getId());
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationSucceeded, host.getId());
|
||||
txn.commit();
|
||||
_networkGroupMgr.handleVmStateTransition(vm, State.Running);
|
||||
return true;
|
||||
@ -2936,7 +2936,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
}
|
||||
_eventDao.persist(event);
|
||||
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("vm created " + vmId);
|
||||
}
|
||||
@ -3093,7 +3093,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
}
|
||||
_eventDao.persist(event);
|
||||
|
||||
_vmDao.updateIf(vm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("vm created " + vmId);
|
||||
}
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
package com.cloud.vm;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.fsm.StateListener;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class VMStateListener implements StateListener<State, VirtualMachine.Event, VMInstanceVO>{
|
||||
private static final Logger s_logger = Logger.getLogger(VMStateListener.class);
|
||||
CapacityDao _capacityDao;
|
||||
ServiceOfferingDao _offeringDao;
|
||||
VMInstanceDao _vmDao;
|
||||
@ -49,7 +51,23 @@ public class VMStateListener implements StateListener<State, VirtualMachine.Even
|
||||
}
|
||||
} else if (oldState == State.Migrating) {
|
||||
if (event == Event.AgentReportStopped) {
|
||||
/*Release capacity from original host*/
|
||||
releaseResource(vm, false, true);
|
||||
} else if (event == Event.OperationFailed) {
|
||||
if (vm.getHostId() == id) {
|
||||
/*Migrate command failed, vm still on the orginal host*/
|
||||
/*no change for the capacity*/
|
||||
} else {
|
||||
/*CheckVirtualMachineCommand cmd got exception, assume vm is running on dest host*/
|
||||
/*Need to clean up capacity*/
|
||||
releaseResource(vm, false, false);
|
||||
if (id != null) {
|
||||
addResource(vm, id);
|
||||
}
|
||||
}
|
||||
} else if (event == Event.OperationSucceeded) {
|
||||
releaseResource(vm, false, false);
|
||||
addResource(vm, id);
|
||||
}
|
||||
} else if (oldState == State.Stopping) {
|
||||
if (event == Event.AgentReportStopped || event == Event.OperationSucceeded) {
|
||||
@ -84,7 +102,7 @@ public class VMStateListener implements StateListener<State, VirtualMachine.Even
|
||||
CapacityVO capacityCpu = _capacityDao.findByHostIdType(vm.getHostId(), CapacityVO.CAPACITY_TYPE_CPU);
|
||||
CapacityVO capacityMemory = _capacityDao.findByHostIdType(vm.getHostId(), CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
int vmCPU = svo.getCpu() * svo.getSpeed();
|
||||
int vmMem = svo.getRamSize();
|
||||
long vmMem = svo.getRamSize() * 1024L * 1024L;
|
||||
|
||||
capacityCpu = _capacityDao.lockRow(capacityCpu.getId(), true);
|
||||
capacityMemory = _capacityDao.lockRow(capacityMemory.getId(), true);
|
||||
@ -124,4 +142,39 @@ public class VMStateListener implements StateListener<State, VirtualMachine.Even
|
||||
_capacityDao.update(capacityMemory.getId(), capacityMemory);
|
||||
|
||||
}
|
||||
|
||||
/*Add capacity to destination host, for migration*/
|
||||
private void addResource(VMInstanceVO vm, Long destHostId) {
|
||||
ServiceOfferingVO svo = _offeringDao.findById(vm.getServiceOfferingId());
|
||||
CapacityVO capacityCpu = _capacityDao.findByHostIdType(destHostId, CapacityVO.CAPACITY_TYPE_CPU);
|
||||
CapacityVO capacityMemory = _capacityDao.findByHostIdType(destHostId, CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
int vmCPU = svo.getCpu() * svo.getSpeed();
|
||||
long vmMem = svo.getRamSize() * 1024L * 1024L;
|
||||
|
||||
capacityCpu = _capacityDao.lockRow(capacityCpu.getId(), true);
|
||||
capacityMemory = _capacityDao.lockRow(capacityMemory.getId(), true);
|
||||
|
||||
long usedCpu = capacityCpu.getUsedCapacity();
|
||||
long usedMem = capacityMemory.getUsedCapacity();
|
||||
long reservedCpu = capacityCpu.getReservedCapacity();
|
||||
long reservedMem = capacityMemory.getReservedCapacity();
|
||||
long totalCpu = capacityCpu.getTotalCapacity();
|
||||
long totalMem = capacityMemory.getTotalCapacity();
|
||||
|
||||
if (usedCpu + reservedCpu + vmCPU <= totalCpu) {
|
||||
capacityCpu.setUsedCapacity(usedCpu + vmCPU);
|
||||
} else {
|
||||
s_logger.debug("What's the heck? :u:" + usedCpu + ",r:" + reservedCpu + ",vm:" + vmCPU + " > " + totalCpu);
|
||||
}
|
||||
|
||||
if (usedMem + reservedMem + vmMem <= totalMem) {
|
||||
capacityMemory.setUsedCapacity(usedMem + vmMem);
|
||||
} else {
|
||||
s_logger.debug("What's the heck? :u:" + usedMem + ",r:" + reservedMem + ",vm:" + vmMem + " > " + totalMem);
|
||||
}
|
||||
|
||||
_capacityDao.update(capacityCpu.getId(), capacityCpu);
|
||||
_capacityDao.update(capacityMemory.getId(), capacityMemory);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
@ -79,4 +80,5 @@ public interface VmManager extends Manager {
|
||||
|
||||
boolean stateTransitTo(VMInstanceVO vm, Event e, Long id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -47,5 +47,5 @@ public interface ConsoleProxyDao extends GenericDao<ConsoleProxyVO, Long> {
|
||||
public int getProxyActiveLoad(long proxyVmId);
|
||||
public List<Long> getRunningProxyListByMsid(long msid);
|
||||
|
||||
public boolean updateIf(ConsoleProxyVO vm, VirtualMachine.Event event, Long hostId);
|
||||
//public boolean updateIf(ConsoleProxyVO vm, VirtualMachine.Event event, Long hostId);
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean updateIf(ConsoleProxyVO vm, VirtualMachine.Event event, Long hostId) {
|
||||
State oldState = vm.getState();
|
||||
State newState = oldState.getNextState(event);
|
||||
@ -195,7 +195,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -63,7 +63,7 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long> {
|
||||
* @param hostId host id to set to.
|
||||
* @return true if update worked; false if not.
|
||||
*/
|
||||
public boolean updateIf(DomainRouterVO router, VirtualMachine.Event event, Long hostId);
|
||||
// public boolean updateIf(DomainRouterVO router, VirtualMachine.Event event, Long hostId);
|
||||
|
||||
/**
|
||||
* list virtual machine routers by host id. pass in null to get all
|
||||
|
||||
@ -145,7 +145,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean updateIf(DomainRouterVO router, VirtualMachine.Event event, Long hostId) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("updateIf called on " + router.toString() + " event " + event.toString() + " host " + hostId);
|
||||
@ -194,7 +194,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listByDataCenter(long dcId) {
|
||||
|
||||
@ -39,5 +39,5 @@ public interface SecondaryStorageVmDao extends GenericDao<SecondaryStorageVmVO,
|
||||
|
||||
public List<Long> getRunningSecStorageVmListByMsid(long msid);
|
||||
|
||||
public boolean updateIf(SecondaryStorageVmVO vm, VirtualMachine.Event event, Long hostId);
|
||||
//public boolean updateIf(SecondaryStorageVmVO vm, VirtualMachine.Event event, Long hostId);
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
||||
assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean updateIf(SecondaryStorageVmVO vm, VirtualMachine.Event event, Long hostId) {
|
||||
State oldState = vm.getState();
|
||||
State newState = oldState.getNextState(event);
|
||||
@ -132,7 +132,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -57,7 +57,7 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long> {
|
||||
* @param hostId
|
||||
* @return true if updated, false if not.
|
||||
*/
|
||||
boolean updateIf(UserVmVO vm, VirtualMachine.Event event, Long hostId);
|
||||
//boolean updateIf(UserVmVO vm, VirtualMachine.Event event, Long hostId);
|
||||
|
||||
/**
|
||||
* Updates display name and group for vm; enables/disables ha
|
||||
|
||||
@ -175,7 +175,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean updateIf(UserVmVO vm, VirtualMachine.Event event, Long hostId) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("UpdateIf called " + vm.toString() + " event " + event.toString() + " host " + hostId);
|
||||
@ -224,7 +224,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> findDestroyedVms(Date date) {
|
||||
|
||||
@ -53,7 +53,7 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
||||
*/
|
||||
public List<VMInstanceVO> listNonExpungedByZoneAndTemplate(long zoneId, long templateId);
|
||||
|
||||
boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId);
|
||||
//boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId);
|
||||
|
||||
/**
|
||||
* Find vm instance with names like.
|
||||
|
||||
@ -140,7 +140,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId) {
|
||||
|
||||
State oldState = vm.getState();
|
||||
@ -174,7 +174,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
s_logger.debug(str.toString());
|
||||
}
|
||||
return result > 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> listByHostId(long hostid) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user