mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Changed allocate method to be virtual machine type agnostic
This commit is contained in:
parent
76e79851a0
commit
541f9d7f9c
@ -25,27 +25,27 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import com.cloud.storage.VolumeManager;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
|
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.hypervisor.Hypervisor;
|
import com.cloud.hypervisor.Hypervisor;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
|
|
||||||
import com.cloud.network.dao.NetworkDao;
|
import com.cloud.network.dao.NetworkDao;
|
||||||
import com.cloud.network.dao.NetworkVO;
|
import com.cloud.network.dao.NetworkVO;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
import com.cloud.service.dao.ServiceOfferingDao;
|
||||||
import com.cloud.storage.DiskOfferingVO;
|
import com.cloud.storage.DiskOfferingVO;
|
||||||
|
import com.cloud.storage.VolumeManager;
|
||||||
import com.cloud.storage.dao.DiskOfferingDao;
|
import com.cloud.storage.dao.DiskOfferingDao;
|
||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.user.dao.AccountDao;
|
import com.cloud.user.dao.AccountDao;
|
||||||
@ -211,9 +211,7 @@ public class CloudOrchestrator implements OrchestrationService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
|
_itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return vmEntity;
|
return vmEntity;
|
||||||
}
|
}
|
||||||
@ -266,9 +264,7 @@ public class CloudOrchestrator implements OrchestrationService {
|
|||||||
|
|
||||||
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
|
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
|
||||||
|
|
||||||
if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
|
_itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return vmEntity;
|
return vmEntity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -518,7 +518,9 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false, RedundantState.UNKNOWN,
|
template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false, RedundantState.UNKNOWN,
|
||||||
_elasticLbVmOffering.getOfferHA(), false, VirtualMachine.Type.ElasticLoadBalancerVm, null);
|
_elasticLbVmOffering.getOfferHA(), false, VirtualMachine.Type.ElasticLoadBalancerVm, null);
|
||||||
elbVm.setRole(Role.LB);
|
elbVm.setRole(Role.LB);
|
||||||
elbVm = _itMgr.allocate(elbVm, template, _elasticLbVmOffering, networks, plan, null, owner);
|
elbVm = _routerDao.persist(elbVm);
|
||||||
|
_itMgr.allocate(elbVm.getInstanceName(), template, _elasticLbVmOffering, networks, plan, null);
|
||||||
|
elbVm = _routerDao.findById(elbVm.getId());
|
||||||
//TODO: create usage stats
|
//TODO: create usage stats
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,25 +780,11 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainRouterVO findByName(String name) {
|
|
||||||
if (!VirtualMachineName.isValidSystemVmName(name, _instance, _elbVmNamePrefix)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _routerDao.findById(VirtualMachineName.getSystemVmId(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DomainRouterVO findById(long id) {
|
public DomainRouterVO findById(long id) {
|
||||||
return _routerDao.findById(id);
|
return _routerDao.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainRouterVO persist(DomainRouterVO elbVm) {
|
|
||||||
return _routerDao.persist(elbVm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest, ReservationContext context) {
|
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest, ReservationContext context) {
|
||||||
DomainRouterVO elbVm = profile.getVirtualMachine();
|
DomainRouterVO elbVm = profile.getVirtualMachine();
|
||||||
@ -983,15 +971,6 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long convertToId(String vmName) {
|
|
||||||
if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, _elbVmNamePrefix)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VirtualMachineName.getSystemVmId(vmName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
|
public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -150,26 +150,11 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
|||||||
@Inject ResourceManager _resourceMgr;
|
@Inject ResourceManager _resourceMgr;
|
||||||
@Inject ConfigurationServer _configServer;
|
@Inject ConfigurationServer _configServer;
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainRouterVO findByName(String name) {
|
|
||||||
if (!VirtualMachineName.isValidSystemVmName(name, _instance, _internalLbVmNamePrefix)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _internalLbVmDao.findById(VirtualMachineName.getRouterId(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DomainRouterVO findById(long id) {
|
public DomainRouterVO findById(long id) {
|
||||||
return _internalLbVmDao.findById(id);
|
return _internalLbVmDao.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainRouterVO persist(DomainRouterVO vm) {
|
|
||||||
DomainRouterVO virtualRouter = _internalLbVmDao.persist(vm);
|
|
||||||
return virtualRouter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile,
|
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile,
|
||||||
DeployDestination dest, ReservationContext context) {
|
DeployDestination dest, ReservationContext context) {
|
||||||
@ -356,15 +341,6 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
|||||||
public void finalizeExpunge(DomainRouterVO vm) {
|
public void finalizeExpunge(DomainRouterVO vm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long convertToId(String vmName) {
|
|
||||||
if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, _internalLbVmNamePrefix)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VirtualMachineName.getRouterId(vmName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
|
public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
|
||||||
}
|
}
|
||||||
@ -794,7 +770,9 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
|||||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false,
|
template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false,
|
||||||
RedundantState.UNKNOWN, false, false, VirtualMachine.Type.InternalLoadBalancerVm, vpcId);
|
RedundantState.UNKNOWN, false, false, VirtualMachine.Type.InternalLoadBalancerVm, vpcId);
|
||||||
internalLbVm.setRole(Role.INTERNAL_LB_VM);
|
internalLbVm.setRole(Role.INTERNAL_LB_VM);
|
||||||
internalLbVm = _itMgr.allocate(internalLbVm, template, routerOffering, networks, plan, null, owner);
|
internalLbVm = _internalLbVmDao.persist(internalLbVm);
|
||||||
|
_itMgr.allocate(internalLbVm.getInstanceName(), template, routerOffering, networks, plan, null);
|
||||||
|
internalLbVm = _internalLbVmDao.findById(internalLbVm.getId());
|
||||||
} catch (InsufficientCapacityException ex) {
|
} catch (InsufficientCapacityException ex) {
|
||||||
if (allocateRetry < 2 && iter.hasNext()) {
|
if (allocateRetry < 2 && iter.hasNext()) {
|
||||||
s_logger.debug("Failed to allocate the Internal lb vm with hypervisor type " + hType + ", retrying one more time");
|
s_logger.debug("Failed to allocate the Internal lb vm with hypervisor type " + hType + ", retrying one more time");
|
||||||
|
|||||||
@ -723,8 +723,9 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
|||||||
|
|
||||||
ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(),
|
ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(),
|
||||||
systemAcct.getId(), 0, _serviceOffering.getOfferHA());
|
systemAcct.getId(), 0, _serviceOffering.getOfferHA());
|
||||||
|
proxy = _consoleProxyDao.persist(proxy);
|
||||||
try {
|
try {
|
||||||
proxy = _itMgr.allocate(proxy, template, _serviceOffering, networks, plan, null, systemAcct);
|
_itMgr.allocate(name, template, _serviceOffering, networks, plan, null);
|
||||||
} catch (InsufficientCapacityException e) {
|
} catch (InsufficientCapacityException e) {
|
||||||
s_logger.warn("InsufficientCapacity", e);
|
s_logger.warn("InsufficientCapacity", e);
|
||||||
throw new CloudRuntimeException("Insufficient capacity exception", e);
|
throw new CloudRuntimeException("Insufficient capacity exception", e);
|
||||||
@ -1008,14 +1009,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long convertToId(String vmName) {
|
|
||||||
if (!VirtualMachineName.isValidConsoleProxyName(vmName, _instance)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return VirtualMachineName.getConsoleProxyId(vmName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopProxy(long proxyVmId) {
|
public boolean stopProxy(long proxyVmId) {
|
||||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||||
@ -1479,26 +1472,11 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
|||||||
_consoleProxyDao.update(proxy.getId(), proxy);
|
_consoleProxyDao.update(proxy.getId(), proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConsoleProxyVO persist(ConsoleProxyVO proxy) {
|
|
||||||
return _consoleProxyDao.persist(proxy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConsoleProxyVO findById(long id) {
|
public ConsoleProxyVO findById(long id) {
|
||||||
return _consoleProxyDao.findById(id);
|
return _consoleProxyDao.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConsoleProxyVO findByName(String name) {
|
|
||||||
if (!VirtualMachineName.isValidConsoleProxyName(name)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return findById(VirtualMachineName.getConsoleProxyId(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, StopAnswer answer) {
|
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, StopAnswer answer) {
|
||||||
//release elastic IP here if assigned
|
//release elastic IP here if assigned
|
||||||
|
|||||||
@ -790,15 +790,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
protected VirtualNetworkApplianceManagerImpl() {
|
protected VirtualNetworkApplianceManagerImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long convertToId(final String vmName) {
|
|
||||||
if (!VirtualMachineName.isValidRouterName(vmName, _instance)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VirtualMachineName.getRouterId(vmName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private VmDataCommand generateVmDataCommand(VirtualRouter router, String vmPrivateIpAddress, String userData,
|
private VmDataCommand generateVmDataCommand(VirtualRouter router, String vmPrivateIpAddress, String userData,
|
||||||
String serviceOffering, String zoneName, String guestIpAddress, String vmName,
|
String serviceOffering, String zoneName, String guestIpAddress, String vmName,
|
||||||
String vmInstanceName, long vmId, String vmUuid, String publicKey, long guestNetworkId) {
|
String vmInstanceName, long vmId, String vmUuid, String publicKey, long guestNetworkId) {
|
||||||
@ -1046,7 +1037,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
}
|
}
|
||||||
String privateIP = router.getPrivateIpAddress();
|
String privateIP = router.getPrivateIpAddress();
|
||||||
HostVO host = _hostDao.findById(router.getHostId());
|
HostVO host = _hostDao.findById(router.getHostId());
|
||||||
if (host == null || host.getStatus() != Status.Up) {
|
if (host == null || host.getState() != Status.Up) {
|
||||||
continue;
|
continue;
|
||||||
} else if (host.getManagementServerId() != ManagementServerNode.getManagementServerId()) {
|
} else if (host.getManagementServerId() != ManagementServerNode.getManagementServerId()) {
|
||||||
/* Only cover hosts managed by this management server */
|
/* Only cover hosts managed by this management server */
|
||||||
@ -1118,7 +1109,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
} else {
|
} else {
|
||||||
String privateIP = router.getPrivateIpAddress();
|
String privateIP = router.getPrivateIpAddress();
|
||||||
HostVO host = _hostDao.findById(router.getHostId());
|
HostVO host = _hostDao.findById(router.getHostId());
|
||||||
if (host == null || host.getStatus() != Status.Up) {
|
if (host == null || host.getState() != Status.Up) {
|
||||||
router.setRedundantState(RedundantState.UNKNOWN);
|
router.setRedundantState(RedundantState.UNKNOWN);
|
||||||
updated = true;
|
updated = true;
|
||||||
} else if (privateIP != null) {
|
} else if (privateIP != null) {
|
||||||
@ -1177,7 +1168,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
if (masterRouter.getState() == State.Running && backupRouter.getState() == State.Running) {
|
if (masterRouter.getState() == State.Running && backupRouter.getState() == State.Running) {
|
||||||
HostVO masterHost = _hostDao.findById(masterRouter.getHostId());
|
HostVO masterHost = _hostDao.findById(masterRouter.getHostId());
|
||||||
HostVO backupHost = _hostDao.findById(backupRouter.getHostId());
|
HostVO backupHost = _hostDao.findById(backupRouter.getHostId());
|
||||||
if (masterHost.getStatus() == Status.Up && backupHost.getStatus() == Status.Up) {
|
if (masterHost.getState() == Status.Up && backupHost.getState() == Status.Up) {
|
||||||
String title = "Reboot " + backupRouter.getInstanceName() + " to ensure redundant virtual routers work";
|
String title = "Reboot " + backupRouter.getInstanceName() + " to ensure redundant virtual routers work";
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug(title);
|
s_logger.debug(title);
|
||||||
@ -1412,7 +1403,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (HostVO h : hosts) {
|
for (HostVO h : hosts) {
|
||||||
if (h.getStatus() == Status.Up) {
|
if (h.getState() == Status.Up) {
|
||||||
s_logger.debug("Pick up host that has hypervisor type " + h.getHypervisorType() + " in cluster " +
|
s_logger.debug("Pick up host that has hypervisor type " + h.getHypervisorType() + " in cluster " +
|
||||||
cv.getId() + " to start domain router for OVM");
|
cv.getId() + " to start domain router for OVM");
|
||||||
return h.getHypervisorType();
|
return h.getHypervisorType();
|
||||||
@ -1658,7 +1649,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), isRedundant, 0, false,
|
template.getGuestOSId(), owner.getDomainId(), owner.getId(), isRedundant, 0, false,
|
||||||
RedundantState.UNKNOWN, offerHA, false, vpcId);
|
RedundantState.UNKNOWN, offerHA, false, vpcId);
|
||||||
router.setRole(Role.VIRTUAL_ROUTER);
|
router.setRole(Role.VIRTUAL_ROUTER);
|
||||||
router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner);
|
router = _routerDao.persist(router);
|
||||||
|
_itMgr.allocate(router.getInstanceName(), template, routerOffering, networks, plan, null);
|
||||||
|
router = _routerDao.findById(router.getId());
|
||||||
} catch (InsufficientCapacityException ex) {
|
} catch (InsufficientCapacityException ex) {
|
||||||
if (allocateRetry < 2 && iter.hasNext()) {
|
if (allocateRetry < 2 && iter.hasNext()) {
|
||||||
s_logger.debug("Failed to allocate the VR with hypervisor type " + hType + ", retrying one more time");
|
s_logger.debug("Failed to allocate the VR with hypervisor type " + hType + ", retrying one more time");
|
||||||
@ -1979,7 +1972,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
State state = router.getState();
|
State state = router.getState();
|
||||||
if (router.getHostId() != null && state != State.Running) {
|
if (router.getHostId() != null && state != State.Running) {
|
||||||
HostVO host = _hostDao.findById(router.getHostId());
|
HostVO host = _hostDao.findById(router.getHostId());
|
||||||
if (host == null || host.getStatus() != Status.Up) {
|
if (host == null || host.getState() != Status.Up) {
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3025,12 +3018,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainRouterVO persist(DomainRouterVO router) {
|
|
||||||
DomainRouterVO virtualRouter = _routerDao.persist(router);
|
|
||||||
return virtualRouter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME add partial success and STOP state support
|
//FIXME add partial success and STOP state support
|
||||||
public String[] applyVpnUsers(Network network, List<? extends VpnUser> users, List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
public String[] applyVpnUsers(Network network, List<? extends VpnUser> users, List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
||||||
@ -3095,15 +3082,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
return _routerDao.findById(id);
|
return _routerDao.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainRouterVO findByName(String name) {
|
|
||||||
if (!VirtualMachineName.isValidRouterName(name)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _routerDao.findById(VirtualMachineName.getRouterId(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_START, eventDescription = "starting router Vm", async = true)
|
@Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_START, eventDescription = "starting router Vm", async = true)
|
||||||
public VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException{
|
public VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException{
|
||||||
return startRouter(id, true);
|
return startRouter(id, true);
|
||||||
@ -3810,7 +3788,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
s_logger.debug("Applying " + typeString + " in network " + network);
|
s_logger.debug("Applying " + typeString + " in network " + network);
|
||||||
|
|
||||||
if (router.isStopPending()) {
|
if (router.isStopPending()) {
|
||||||
if (_hostDao.findById(router.getHostId()).getStatus() == Status.Up) {
|
if (_hostDao.findById(router.getHostId()).getState() == Status.Up) {
|
||||||
throw new ResourceUnavailableException("Unable to process due to the stop pending router " +
|
throw new ResourceUnavailableException("Unable to process due to the stop pending router " +
|
||||||
router.getInstanceName() + " haven't been stopped after it's host coming back!",
|
router.getInstanceName() + " haven't been stopped after it's host coming back!",
|
||||||
DataCenter.class, router.getDataCenterId());
|
DataCenter.class, router.getDataCenterId());
|
||||||
@ -3840,7 +3818,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
|
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
|
||||||
", so not sending apply " + typeString + " commands to the backend");
|
", so not sending apply " + typeString + " commands to the backend");
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("Unable to apply " + typeString +", virtual router is not in the right state " + router.getState());
|
s_logger.warn("Unable to apply " + typeString + ", virtual router is not in the right state " + router.getState());
|
||||||
if (isZoneBasic && isPodLevelException) {
|
if (isZoneBasic && isPodLevelException) {
|
||||||
throw new ResourceUnavailableException("Unable to apply " + typeString +
|
throw new ResourceUnavailableException("Unable to apply " + typeString +
|
||||||
", virtual router is not in the right state", Pod.class, podId);
|
", virtual router is not in the right state", Pod.class, podId);
|
||||||
|
|||||||
@ -419,7 +419,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
|
|
||||||
SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
|
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
|
||||||
sc.addAnd(sc.getEntity().getStatus(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
|
sc.addAnd(sc.getEntity().getState(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
|
||||||
List<HostVO> ssvms = sc.list();
|
List<HostVO> ssvms = sc.list();
|
||||||
for (HostVO ssvm : ssvms) {
|
for (HostVO ssvm : ssvms) {
|
||||||
if (ssvm.getId() == ssAHostId) {
|
if (ssvm.getId() == ssAHostId) {
|
||||||
@ -575,8 +575,10 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
|
|
||||||
SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId,
|
SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId,
|
||||||
systemAcct.getDomainId(), systemAcct.getId(), role, _serviceOffering.getOfferHA());
|
systemAcct.getDomainId(), systemAcct.getId(), role, _serviceOffering.getOfferHA());
|
||||||
|
secStorageVm = _secStorageVmDao.persist(secStorageVm);
|
||||||
try {
|
try {
|
||||||
secStorageVm = _itMgr.allocate(secStorageVm, template, _serviceOffering, networks, plan, null, systemAcct);
|
_itMgr.allocate(name, template, _serviceOffering, networks, plan, null);
|
||||||
|
secStorageVm = _secStorageVmDao.findById(secStorageVm.getId());
|
||||||
} catch (InsufficientCapacityException e) {
|
} catch (InsufficientCapacityException e) {
|
||||||
s_logger.warn("InsufficientCapacity", e);
|
s_logger.warn("InsufficientCapacity", e);
|
||||||
throw new CloudRuntimeException("Insufficient capacity exception", e);
|
throw new CloudRuntimeException("Insufficient capacity exception", e);
|
||||||
@ -889,14 +891,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long convertToId(String vmName) {
|
|
||||||
if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, "s")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return VirtualMachineName.getSystemVmId(vmName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopSecStorageVm(long secStorageVmId) {
|
public boolean stopSecStorageVm(long secStorageVmId) {
|
||||||
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
|
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
|
||||||
@ -1010,24 +1004,11 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
return "secStorageVm." + id;
|
return "secStorageVm." + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SecondaryStorageVmVO findByName(String name) {
|
|
||||||
if (!VirtualMachineName.isValidSecStorageVmName(name, null)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return findById(VirtualMachineName.getSystemVmId(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecondaryStorageVmVO findById(long id) {
|
public SecondaryStorageVmVO findById(long id) {
|
||||||
return _secStorageVmDao.findById(id);
|
return _secStorageVmDao.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SecondaryStorageVmVO persist(SecondaryStorageVmVO vm) {
|
|
||||||
return _secStorageVmDao.persist(vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<SecondaryStorageVmVO> profile, DeployDestination dest, ReservationContext context) {
|
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<SecondaryStorageVmVO> profile, DeployDestination dest, ReservationContext context) {
|
||||||
|
|
||||||
@ -1377,7 +1358,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
if (dcId != null) {
|
if (dcId != null) {
|
||||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
||||||
}
|
}
|
||||||
sc.addAnd(sc.getEntity().getStatus(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
|
sc.addAnd(sc.getEntity().getState(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
|
||||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
|
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
|
||||||
return sc.list();
|
return sc.list();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,9 @@ import javax.ejb.Local;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
|
import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
|
||||||
import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
|
import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
|
||||||
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
|
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
|
||||||
@ -46,9 +49,6 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
|||||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.Command;
|
import com.cloud.agent.api.Command;
|
||||||
@ -59,7 +59,6 @@ import com.cloud.configuration.Config;
|
|||||||
import com.cloud.configuration.Resource.ResourceType;
|
import com.cloud.configuration.Resource.ResourceType;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.ClusterVO;
|
import com.cloud.dc.ClusterVO;
|
||||||
import com.cloud.dc.DataCenterVO;
|
|
||||||
import com.cloud.dc.dao.ClusterDao;
|
import com.cloud.dc.dao.ClusterDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.domain.dao.DomainDao;
|
import com.cloud.domain.dao.DomainDao;
|
||||||
@ -80,9 +79,9 @@ import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
|||||||
import com.cloud.resource.ResourceManager;
|
import com.cloud.resource.ResourceManager;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.storage.CreateSnapshotPayload;
|
import com.cloud.storage.CreateSnapshotPayload;
|
||||||
|
import com.cloud.storage.DataStoreRole;
|
||||||
import com.cloud.storage.Snapshot;
|
import com.cloud.storage.Snapshot;
|
||||||
import com.cloud.storage.Snapshot.Type;
|
import com.cloud.storage.Snapshot.Type;
|
||||||
import com.cloud.storage.DataStoreRole;
|
|
||||||
import com.cloud.storage.SnapshotPolicyVO;
|
import com.cloud.storage.SnapshotPolicyVO;
|
||||||
import com.cloud.storage.SnapshotScheduleVO;
|
import com.cloud.storage.SnapshotScheduleVO;
|
||||||
import com.cloud.storage.SnapshotVO;
|
import com.cloud.storage.SnapshotVO;
|
||||||
@ -269,7 +268,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
@DB
|
@DB
|
||||||
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "creating snapshot", async = true)
|
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "creating snapshot", async = true)
|
||||||
public Snapshot createSnapshot(Long volumeId, Long policyId, Long snapshotId, Account snapshotOwner) {
|
public Snapshot createSnapshot(Long volumeId, Long policyId, Long snapshotId, Account snapshotOwner) {
|
||||||
VolumeInfo volume = this.volFactory.getVolume(volumeId);
|
VolumeInfo volume = volFactory.getVolume(volumeId);
|
||||||
if (volume == null) {
|
if (volume == null) {
|
||||||
throw new InvalidParameterValueException("No such volume exist");
|
throw new InvalidParameterValueException("No such volume exist");
|
||||||
}
|
}
|
||||||
@ -283,7 +282,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
// does the caller have the authority to act on this volume
|
// does the caller have the authority to act on this volume
|
||||||
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
|
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
|
||||||
|
|
||||||
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
|
SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
postCreateSnapshot(volumeId, snapshot.getId(), policyId);
|
postCreateSnapshot(volumeId, snapshot.getId(), policyId);
|
||||||
@ -316,12 +315,12 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Snapshot backupSnapshot(Long snapshotId) {
|
public Snapshot backupSnapshot(Long snapshotId) {
|
||||||
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image);
|
SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image);
|
||||||
if (snapshot != null) {
|
if (snapshot != null) {
|
||||||
throw new CloudRuntimeException("Already in the backup snapshot:" + snapshotId);
|
throw new CloudRuntimeException("Already in the backup snapshot:" + snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.snapshotSrv.backupSnapshot(snapshot);
|
return snapshotSrv.backupSnapshot(snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -480,14 +479,14 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
Account caller = CallContext.current().getCallingAccount();
|
Account caller = CallContext.current().getCallingAccount();
|
||||||
|
|
||||||
// Verify parameters
|
// Verify parameters
|
||||||
SnapshotVO snapshotCheck = this._snapshotDao.findById(snapshotId);
|
SnapshotVO snapshotCheck = _snapshotDao.findById(snapshotId);
|
||||||
if (snapshotCheck == null) {
|
if (snapshotCheck == null) {
|
||||||
throw new InvalidParameterValueException("unable to find a snapshot with id " + snapshotId);
|
throw new InvalidParameterValueException("unable to find a snapshot with id " + snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
_accountMgr.checkAccess(caller, null, true, snapshotCheck);
|
_accountMgr.checkAccess(caller, null, true, snapshotCheck);
|
||||||
SnapshotStrategy snapshotStrategy = null;
|
SnapshotStrategy snapshotStrategy = null;
|
||||||
for (SnapshotStrategy strategy : this.snapshotStrategies) {
|
for (SnapshotStrategy strategy : snapshotStrategies) {
|
||||||
if (strategy.canHandle(snapshotCheck)) {
|
if (strategy.canHandle(snapshotCheck)) {
|
||||||
snapshotStrategy = strategy;
|
snapshotStrategy = strategy;
|
||||||
break;
|
break;
|
||||||
@ -515,9 +514,9 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSecondaryStorageURL(SnapshotVO snapshot) {
|
public String getSecondaryStorageURL(SnapshotVO snapshot) {
|
||||||
SnapshotDataStoreVO snapshotStore = this._snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image);
|
SnapshotDataStoreVO snapshotStore = _snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image);
|
||||||
if (snapshotStore != null){
|
if (snapshotStore != null){
|
||||||
DataStore store = this.dataStoreMgr.getDataStore(snapshotStore.getDataStoreId(), DataStoreRole.Image);
|
DataStore store = dataStoreMgr.getDataStore(snapshotStore.getDataStoreId(), DataStoreRole.Image);
|
||||||
if ( store != null ){
|
if ( store != null ){
|
||||||
return store.getUri();
|
return store.getUri();
|
||||||
}
|
}
|
||||||
@ -614,7 +613,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (snapshotTypeStr != null) {
|
if (snapshotTypeStr != null) {
|
||||||
Type snapshotType = SnapshotVO.getSnapshotType((String) snapshotTypeStr);
|
Type snapshotType = SnapshotVO.getSnapshotType(snapshotTypeStr);
|
||||||
if (snapshotType == null) {
|
if (snapshotType == null) {
|
||||||
throw new InvalidParameterValueException("Unsupported snapshot type " + snapshotTypeStr);
|
throw new InvalidParameterValueException("Unsupported snapshot type " + snapshotTypeStr);
|
||||||
}
|
}
|
||||||
@ -624,7 +623,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
sc.setParameters("snapshotTypeEQ", snapshotType.ordinal());
|
sc.setParameters("snapshotTypeEQ", snapshotType.ordinal());
|
||||||
}
|
}
|
||||||
} else if (intervalTypeStr != null && volumeId != null) {
|
} else if (intervalTypeStr != null && volumeId != null) {
|
||||||
Type type = SnapshotVO.getSnapshotType((String) intervalTypeStr);
|
Type type = SnapshotVO.getSnapshotType(intervalTypeStr);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
throw new InvalidParameterValueException("Unsupported snapstho interval type " + intervalTypeStr);
|
throw new InvalidParameterValueException("Unsupported snapstho interval type " + intervalTypeStr);
|
||||||
}
|
}
|
||||||
@ -657,7 +656,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
// This volume doesn't have any snapshots. Nothing do delete.
|
// This volume doesn't have any snapshots. Nothing do delete.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<DataStore> ssHosts = this.dataStoreMgr.getImageStoresByScope(new ZoneScope(dcId));
|
List<DataStore> ssHosts = dataStoreMgr.getImageStoresByScope(new ZoneScope(dcId));
|
||||||
for (DataStore ssHost : ssHosts) {
|
for (DataStore ssHost : ssHosts) {
|
||||||
String snapshotDir = TemplateConstants.DEFAULT_SNAPSHOT_ROOT_DIR + "/" + accountId + "/" + volumeId;
|
String snapshotDir = TemplateConstants.DEFAULT_SNAPSHOT_ROOT_DIR + "/" + accountId + "/" + volumeId;
|
||||||
DeleteSnapshotsDirCommand cmd = new DeleteSnapshotsDirCommand(ssHost.getTO(), snapshotDir);
|
DeleteSnapshotsDirCommand cmd = new DeleteSnapshotsDirCommand(ssHost.getTO(), snapshotDir);
|
||||||
@ -977,7 +976,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
CreateSnapshotPayload payload = (CreateSnapshotPayload)volume.getpayload();
|
CreateSnapshotPayload payload = (CreateSnapshotPayload)volume.getpayload();
|
||||||
Long snapshotId = payload.getSnapshotId();
|
Long snapshotId = payload.getSnapshotId();
|
||||||
Account snapshotOwner = payload.getAccount();
|
Account snapshotOwner = payload.getAccount();
|
||||||
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, volume.getDataStore());
|
SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, volume.getDataStore());
|
||||||
boolean processed = false;
|
boolean processed = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1019,7 +1018,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
|
|
||||||
String value = _configDao.getValue(Config.BackupSnapshotWait.toString());
|
String value = _configDao.getValue(Config.BackupSnapshotWait.toString());
|
||||||
_backupsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue()));
|
_backupsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue()));
|
||||||
backup = Boolean.parseBoolean(this._configDao.getValue(Config.BackupSnapshotAferTakingSnapshot.toString()));
|
backup = Boolean.parseBoolean(_configDao.getValue(Config.BackupSnapshotAferTakingSnapshot.toString()));
|
||||||
|
|
||||||
Type.HOURLY.setMax(NumbersUtil.parseInt(_configDao.getValue("snapshot.max.hourly"), HOURLYMAX));
|
Type.HOURLY.setMax(NumbersUtil.parseInt(_configDao.getValue("snapshot.max.hourly"), HOURLYMAX));
|
||||||
Type.DAILY.setMax(NumbersUtil.parseInt(_configDao.getValue("snapshot.max.daily"), DAILYMAX));
|
Type.DAILY.setMax(NumbersUtil.parseInt(_configDao.getValue("snapshot.max.daily"), DAILYMAX));
|
||||||
@ -1104,7 +1103,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||||||
@Override
|
@Override
|
||||||
public Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException {
|
public Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException {
|
||||||
Account caller = CallContext.current().getCallingAccount();
|
Account caller = CallContext.current().getCallingAccount();
|
||||||
VolumeInfo volume = this.volFactory.getVolume(volumeId);
|
VolumeInfo volume = volFactory.getVolume(volumeId);
|
||||||
supportedByHypervisor(volume);
|
supportedByHypervisor(volume);
|
||||||
|
|
||||||
// Verify permissions
|
// Verify permissions
|
||||||
|
|||||||
@ -1135,7 +1135,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||||||
throw new InvalidParameterValueException("This operation not permitted for this hypervisor of the vm");
|
throw new InvalidParameterValueException("This operation not permitted for this hypervisor of the vm");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vmInstance.getState().equals(State.Stopped)){
|
if (vmInstance.getState().equals(State.Stopped)) {
|
||||||
upgradeStoppedVirtualMachine(vmId, newServiceOfferingId);
|
upgradeStoppedVirtualMachine(vmId, newServiceOfferingId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1173,7 +1173,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||||||
|
|
||||||
// Dynamically upgrade the running vms
|
// Dynamically upgrade the running vms
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
if(vmInstance.getState().equals(State.Running)){
|
if (vmInstance.getState().equals(State.Running)) {
|
||||||
int retry = _scaleRetry;
|
int retry = _scaleRetry;
|
||||||
ExcludeList excludes = new ExcludeList();
|
ExcludeList excludes = new ExcludeList();
|
||||||
boolean enableDynamicallyScaleVm = Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vmInstance.getDataCenterId()));
|
boolean enableDynamicallyScaleVm = Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vmInstance.getDataCenterId()));
|
||||||
@ -1491,14 +1491,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||||||
return UUID.randomUUID().toString();
|
return UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long convertToId(String vmName) {
|
|
||||||
if (!VirtualMachineName.isValidVmName(vmName, _instance)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return VirtualMachineName.getVmId(vmName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
|
public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
|
||||||
try {
|
try {
|
||||||
@ -3096,24 +3088,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||||||
public void finalizeExpunge(UserVmVO vm) {
|
public void finalizeExpunge(UserVmVO vm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVmVO persist(UserVmVO vm) {
|
|
||||||
return _vmDao.persist(vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserVmVO findById(long id) {
|
public UserVmVO findById(long id) {
|
||||||
return _vmDao.findById(id);
|
return _vmDao.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVmVO findByName(String name) {
|
|
||||||
if (!VirtualMachineName.isValidVmName(name)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return findById(VirtualMachineName.getVmId(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ActionEvent(eventType = EventTypes.EVENT_VM_STOP, eventDescription = "stopping Vm", async = true)
|
@ActionEvent(eventType = EventTypes.EVENT_VM_STOP, eventDescription = "stopping Vm", async = true)
|
||||||
public UserVm stopVirtualMachine(long vmId, boolean forced)
|
public UserVm stopVirtualMachine(long vmId, boolean forced)
|
||||||
@ -3854,11 +3833,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if host is UP
|
// check if host is UP
|
||||||
if (destinationHost.getStatus() != com.cloud.host.Status.Up
|
if (destinationHost.getState() != com.cloud.host.Status.Up
|
||||||
|| destinationHost.getResourceState() != ResourceState.Enabled) {
|
|| destinationHost.getResourceState() != ResourceState.Enabled) {
|
||||||
throw new InvalidParameterValueException(
|
throw new InvalidParameterValueException(
|
||||||
"Cannot migrate VM, destination host is not in correct state, has status: "
|
"Cannot migrate VM, destination host is not in correct state, has status: "
|
||||||
+ destinationHost.getStatus() + ", state: "
|
+ destinationHost.getState() + ", state: "
|
||||||
+ destinationHost.getResourceState());
|
+ destinationHost.getResourceState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3982,10 +3961,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if destination host is up.
|
// Check if destination host is up.
|
||||||
if (destinationHost.getStatus() != com.cloud.host.Status.Up ||
|
if (destinationHost.getState() != com.cloud.host.Status.Up ||
|
||||||
destinationHost.getResourceState() != ResourceState.Enabled){
|
destinationHost.getResourceState() != ResourceState.Enabled){
|
||||||
throw new CloudRuntimeException("Cannot migrate VM, destination host is not in correct state, has " +
|
throw new CloudRuntimeException("Cannot migrate VM, destination host is not in correct state, has " +
|
||||||
"status: " + destinationHost.getStatus() + ", state: " + destinationHost.getResourceState());
|
"status: " + destinationHost.getState() + ", state: " + destinationHost.getResourceState());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<VolumeVO> vmVolumes = _volsDao.findUsableVolumesForInstance(vm.getId());
|
List<VolumeVO> vmVolumes = _volsDao.findUsableVolumesForInstance(vm.getId());
|
||||||
|
|||||||
@ -26,17 +26,8 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface VirtualMachineGuru<T extends VirtualMachine> {
|
public interface VirtualMachineGuru<T extends VirtualMachine> {
|
||||||
/**
|
|
||||||
* Find the virtual machine by name.
|
|
||||||
* @param name
|
|
||||||
* @return virtual machine.
|
|
||||||
*/
|
|
||||||
T findByName(String name);
|
|
||||||
|
|
||||||
T findById(long id);
|
T findById(long id);
|
||||||
|
|
||||||
T persist(T vm);
|
|
||||||
|
|
||||||
boolean finalizeVirtualMachineProfile(VirtualMachineProfile<T> profile, DeployDestination dest, ReservationContext context);
|
boolean finalizeVirtualMachineProfile(VirtualMachineProfile<T> profile, DeployDestination dest, ReservationContext context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,16 +54,6 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
|
|||||||
|
|
||||||
void finalizeExpunge(T vm);
|
void finalizeExpunge(T vm);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the id parsed from the name. If it cannot parse the name,
|
|
||||||
* then return null. This method is used to determine if this is
|
|
||||||
* the right handler for this vm.
|
|
||||||
*
|
|
||||||
* @param vmName vm name coming form the agent.
|
|
||||||
* @return id if the handler works for this vm and can parse id. null if not.
|
|
||||||
*/
|
|
||||||
Long convertToId(String vmName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare Vm for Stop
|
* Prepare Vm for Stop
|
||||||
* @param profile
|
* @param profile
|
||||||
|
|||||||
@ -20,13 +20,13 @@ import java.net.URI;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.cloud.deploy.DeploymentPlanner;
|
|
||||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||||
|
|
||||||
import com.cloud.agent.api.to.NicTO;
|
import com.cloud.agent.api.to.NicTO;
|
||||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
|
import com.cloud.deploy.DeploymentPlanner;
|
||||||
import com.cloud.exception.AgentUnavailableException;
|
import com.cloud.exception.AgentUnavailableException;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
@ -55,7 +55,7 @@ import com.cloud.utils.fsm.NoTransitionException;
|
|||||||
*/
|
*/
|
||||||
public interface VirtualMachineManager extends Manager {
|
public interface VirtualMachineManager extends Manager {
|
||||||
|
|
||||||
<T extends VMInstanceVO> T allocate(T vm,
|
void allocate(String vmInstanceName,
|
||||||
VMTemplateVO template,
|
VMTemplateVO template,
|
||||||
ServiceOfferingVO serviceOffering,
|
ServiceOfferingVO serviceOffering,
|
||||||
Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
|
Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
|
||||||
@ -63,26 +63,14 @@ public interface VirtualMachineManager extends Manager {
|
|||||||
List<Pair<NetworkVO, NicProfile>> networks,
|
List<Pair<NetworkVO, NicProfile>> networks,
|
||||||
Map<VirtualMachineProfile.Param, Object> params,
|
Map<VirtualMachineProfile.Param, Object> params,
|
||||||
DeploymentPlan plan,
|
DeploymentPlan plan,
|
||||||
HypervisorType hyperType,
|
HypervisorType hyperType) throws InsufficientCapacityException;
|
||||||
Account owner) throws InsufficientCapacityException;
|
|
||||||
|
|
||||||
<T extends VMInstanceVO> T allocate(T vm,
|
void allocate(String vmInstanceName,
|
||||||
VMTemplateVO template,
|
|
||||||
ServiceOfferingVO serviceOffering,
|
|
||||||
Long rootSize,
|
|
||||||
Pair<DiskOfferingVO, Long> dataDiskOffering,
|
|
||||||
List<Pair<NetworkVO, NicProfile>> networks,
|
|
||||||
DeploymentPlan plan,
|
|
||||||
HypervisorType hyperType,
|
|
||||||
Account owner) throws InsufficientCapacityException;
|
|
||||||
|
|
||||||
<T extends VMInstanceVO> T allocate(T vm,
|
|
||||||
VMTemplateVO template,
|
VMTemplateVO template,
|
||||||
ServiceOfferingVO serviceOffering,
|
ServiceOfferingVO serviceOffering,
|
||||||
List<Pair<NetworkVO, NicProfile>> networkProfiles,
|
List<Pair<NetworkVO, NicProfile>> networkProfiles,
|
||||||
DeploymentPlan plan,
|
DeploymentPlan plan,
|
||||||
HypervisorType hyperType,
|
HypervisorType hyperType) throws InsufficientCapacityException;
|
||||||
Account owner) throws InsufficientCapacityException;
|
|
||||||
|
|
||||||
<T extends VMInstanceVO> T start(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException;
|
<T extends VMInstanceVO> T start(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||||
|
|
||||||
|
|||||||
@ -36,13 +36,6 @@ import javax.ejb.Local;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import com.cloud.dc.dao.VlanDao;
|
|
||||||
import com.cloud.network.Networks;
|
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
|
||||||
import com.cloud.network.dao.IPAddressVO;
|
|
||||||
import com.cloud.network.element.DhcpServiceProvider;
|
|
||||||
import com.cloud.vm.dao.NicIpAliasDao;
|
|
||||||
import com.cloud.vm.dao.NicIpAliasVO;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
||||||
@ -93,6 +86,7 @@ import com.cloud.configuration.Config;
|
|||||||
import com.cloud.configuration.ConfigurationManager;
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.Resource.ResourceType;
|
import com.cloud.configuration.Resource.ResourceType;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
import com.cloud.dao.EntityManager;
|
||||||
import com.cloud.dc.ClusterDetailsDao;
|
import com.cloud.dc.ClusterDetailsDao;
|
||||||
import com.cloud.dc.ClusterDetailsVO;
|
import com.cloud.dc.ClusterDetailsVO;
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
@ -101,6 +95,7 @@ import com.cloud.dc.HostPodVO;
|
|||||||
import com.cloud.dc.dao.ClusterDao;
|
import com.cloud.dc.dao.ClusterDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
import com.cloud.dc.dao.HostPodDao;
|
||||||
|
import com.cloud.dc.dao.VlanDao;
|
||||||
import com.cloud.deploy.DataCenterDeployment;
|
import com.cloud.deploy.DataCenterDeployment;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
@ -135,8 +130,12 @@ import com.cloud.hypervisor.HypervisorGuruManager;
|
|||||||
import com.cloud.network.Network;
|
import com.cloud.network.Network;
|
||||||
import com.cloud.network.NetworkManager;
|
import com.cloud.network.NetworkManager;
|
||||||
import com.cloud.network.NetworkModel;
|
import com.cloud.network.NetworkModel;
|
||||||
|
import com.cloud.network.Networks;
|
||||||
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
|
import com.cloud.network.dao.IPAddressVO;
|
||||||
import com.cloud.network.dao.NetworkDao;
|
import com.cloud.network.dao.NetworkDao;
|
||||||
import com.cloud.network.dao.NetworkVO;
|
import com.cloud.network.dao.NetworkVO;
|
||||||
|
import com.cloud.network.element.DhcpServiceProvider;
|
||||||
import com.cloud.network.rules.RulesManager;
|
import com.cloud.network.rules.RulesManager;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.org.Cluster;
|
import com.cloud.org.Cluster;
|
||||||
@ -184,6 +183,8 @@ import com.cloud.vm.ItWorkVO.Step;
|
|||||||
import com.cloud.vm.VirtualMachine.Event;
|
import com.cloud.vm.VirtualMachine.Event;
|
||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
import com.cloud.vm.dao.NicDao;
|
import com.cloud.vm.dao.NicDao;
|
||||||
|
import com.cloud.vm.dao.NicIpAliasDao;
|
||||||
|
import com.cloud.vm.dao.NicIpAliasVO;
|
||||||
import com.cloud.vm.dao.UserVmDao;
|
import com.cloud.vm.dao.UserVmDao;
|
||||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
@ -280,6 +281,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
protected VlanDao _vlanDao;
|
protected VlanDao _vlanDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected NicIpAliasDao _nicIpAliasDao;
|
protected NicIpAliasDao _nicIpAliasDao;
|
||||||
|
@Inject
|
||||||
|
protected EntityManager _entityMgr;
|
||||||
|
|
||||||
protected List<DeploymentPlanner> _planners;
|
protected List<DeploymentPlanner> _planners;
|
||||||
public List<DeploymentPlanner> getPlanners() {
|
public List<DeploymentPlanner> getPlanners() {
|
||||||
@ -345,14 +348,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
|
public void allocate(String vmInstanceName, VMTemplateVO template, ServiceOfferingVO serviceOffering, Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
|
||||||
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings, List<Pair<NetworkVO, NicProfile>> networks, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan plan,
|
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings, List<Pair<NetworkVO, NicProfile>> networks, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan plan,
|
||||||
HypervisorType hyperType, Account owner) throws InsufficientCapacityException {
|
HypervisorType hyperType) throws InsufficientCapacityException {
|
||||||
|
|
||||||
|
VMInstanceVO vm = _vmDao.findVMByInstanceName(vmInstanceName);
|
||||||
|
Account owner = _entityMgr.findById(Account.class, vm.getId());
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Allocating entries for VM: " + vm);
|
s_logger.debug("Allocating entries for VM: " + vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, template, serviceOffering, owner, params);
|
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, template, serviceOffering, null, params);
|
||||||
|
|
||||||
vm.setDataCenterId(plan.getDataCenterId());
|
vm.setDataCenterId(plan.getDataCenterId());
|
||||||
if (plan.getPodId() != null) {
|
if (plan.getPodId() != null) {
|
||||||
@ -360,12 +367,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
}
|
}
|
||||||
assert (plan.getClusterId() == null && plan.getPoolId() == null) : "We currently don't support cluster and pool preset yet";
|
assert (plan.getClusterId() == null && plan.getPoolId() == null) : "We currently don't support cluster and pool preset yet";
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
VirtualMachineGuru<T> guru = (VirtualMachineGuru<T>) _vmGurus.get(vm.getType());
|
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
vm = guru.persist(vm);
|
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Allocating nics for " + vm);
|
s_logger.debug("Allocating nics for " + vm);
|
||||||
@ -401,24 +404,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Allocation completed for VM: " + vm);
|
s_logger.debug("Allocation completed for VM: " + vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, Long rootSize, Pair<DiskOfferingVO, Long> dataDiskOffering,
|
public void allocate(String vmInstanceName, VMTemplateVO template, ServiceOfferingVO serviceOffering, List<Pair<NetworkVO, NicProfile>> networks, DeploymentPlan plan,
|
||||||
List<Pair<NetworkVO, NicProfile>> networks, DeploymentPlan plan, HypervisorType hyperType, Account owner) throws InsufficientCapacityException {
|
HypervisorType hyperType) throws InsufficientCapacityException {
|
||||||
List<Pair<DiskOfferingVO, Long>> diskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(1);
|
allocate(vmInstanceName, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, null), null, networks, null, plan, hyperType);
|
||||||
if (dataDiskOffering != null) {
|
|
||||||
diskOfferings.add(dataDiskOffering);
|
|
||||||
}
|
|
||||||
return allocate(vm, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, rootSize), diskOfferings, networks, null, plan, hyperType, owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, List<Pair<NetworkVO, NicProfile>> networks, DeploymentPlan plan,
|
|
||||||
HypervisorType hyperType, Account owner) throws InsufficientCapacityException {
|
|
||||||
return allocate(vm, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, null), null, networks, null, plan, hyperType, owner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -2055,14 +2046,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VMInstanceVO castedVm = null;
|
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
info = new AgentVmInfo(vm.getInstanceName(), getVmGuru(vm), vm, State.Stopped);
|
info = new AgentVmInfo(vm.getInstanceName(), vm, State.Stopped);
|
||||||
}
|
}
|
||||||
castedVm = info.guru.findById(vm.getId());
|
|
||||||
|
|
||||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(castedVm.getHypervisorType());
|
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
||||||
Command command = compareState(hostId, castedVm, info, true, hvGuru.trackVmHostChange());
|
Command command = compareState(hostId, vm, info, true, hvGuru.trackVmHostChange());
|
||||||
if (command != null) {
|
if (command != null) {
|
||||||
commands.addCommand(command);
|
commands.addCommand(command);
|
||||||
}
|
}
|
||||||
@ -2070,22 +2059,19 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
|
|
||||||
for (final AgentVmInfo left : infos.values()) {
|
for (final AgentVmInfo left : infos.values()) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : _vmGurus.values()) {
|
VMInstanceVO vm = _vmDao.findVMByInstanceName(left.name);
|
||||||
VMInstanceVO vm = vmGuru.findByName(left.name);
|
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
found = true;
|
found = true;
|
||||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
||||||
if(hvGuru.trackVmHostChange()) {
|
if (hvGuru.trackVmHostChange()) {
|
||||||
Command command = compareState(hostId, vm, left, true, true);
|
Command command = compareState(hostId, vm, left, true, true);
|
||||||
if (command != null) {
|
if (command != null) {
|
||||||
commands.addCommand(command);
|
commands.addCommand(command);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("Stopping a VM, VM " + left.name + " migrate from Host " + vm.getHostId() + " to Host " + hostId );
|
s_logger.warn("Stopping a VM, VM " + left.name + " migrate from Host " + vm.getHostId() + " to Host " + hostId);
|
||||||
commands.addCommand(cleanup(left.name));
|
commands.addCommand(cleanup(left.name));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( ! found ) {
|
if ( ! found ) {
|
||||||
s_logger.warn("Stopping a VM that we have no record of <fullHostSync>: " + left.name);
|
s_logger.warn("Stopping a VM that we have no record of <fullHostSync>: " + left.name);
|
||||||
@ -2171,7 +2157,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
|
|
||||||
for (VMInstanceVO vm : set_vms) {
|
for (VMInstanceVO vm : set_vms) {
|
||||||
AgentVmInfo info = infos.remove(vm.getId());
|
AgentVmInfo info = infos.remove(vm.getId());
|
||||||
VMInstanceVO castedVm = null;
|
|
||||||
|
|
||||||
// sync VM Snapshots related transient states
|
// sync VM Snapshots related transient states
|
||||||
List<VMSnapshotVO> vmSnapshotsInExpungingStates = _vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging, VMSnapshot.State.Creating,VMSnapshot.State.Reverting);
|
List<VMSnapshotVO> vmSnapshotsInExpungingStates = _vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging, VMSnapshot.State.Creating,VMSnapshot.State.Reverting);
|
||||||
@ -2191,11 +2176,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((info == null && (vm.getState() == State.Running || vm.getState() == State.Starting ))
|
if ((info == null && (vm.getState() == State.Running || vm.getState() == State.Starting))
|
||||||
|| (info != null && (info.state == State.Running && vm.getState() == State.Starting)))
|
|| (info != null && (info.state == State.Running && vm.getState() == State.Starting)))
|
||||||
{
|
{
|
||||||
s_logger.info("Found vm " + vm.getInstanceName() + " in inconsistent state. " + vm.getState() + " on CS while " + (info == null ? "Stopped" : "Running") + " on agent");
|
s_logger.info("Found vm " + vm.getInstanceName() + " in inconsistent state. " + vm.getState() + " on CS while " + (info == null ? "Stopped" : "Running")
|
||||||
info = new AgentVmInfo(vm.getInstanceName(), getVmGuru(vm), vm, State.Stopped);
|
+ " on agent");
|
||||||
|
info = new AgentVmInfo(vm.getInstanceName(), vm, State.Stopped);
|
||||||
|
|
||||||
// Bug 13850- grab outstanding work item if any for this VM state so that we mark it as DONE after we change VM state, else it will remain pending
|
// Bug 13850- grab outstanding work item if any for this VM state so that we mark it as DONE after we change VM state, else it will remain pending
|
||||||
ItWorkVO work = _workDao.findByOutstandingWork(vm.getId(), vm.getState());
|
ItWorkVO work = _workDao.findByOutstandingWork(vm.getId(), vm.getState());
|
||||||
@ -2215,12 +2201,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
_workDao.update(work.getId(), work);
|
_workDao.update(work.getId(), work);
|
||||||
}
|
}
|
||||||
|
|
||||||
castedVm = info.guru.findById(vm.getId());
|
|
||||||
try {
|
try {
|
||||||
Host host = _hostDao.findByGuid(info.getHostUuid());
|
Host host = _hostDao.findByGuid(info.getHostUuid());
|
||||||
long hostId = host == null ? (vm.getHostId() == null ? vm.getLastHostId() : vm.getHostId()) : host.getId();
|
long hostId = host == null ? (vm.getHostId() == null ? vm.getLastHostId() : vm.getHostId()) : host.getId();
|
||||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(castedVm.getHypervisorType());
|
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
||||||
Command command = compareState(hostId, castedVm, info, true, hvGuru.trackVmHostChange());
|
Command command = compareState(hostId, vm, info, true, hvGuru.trackVmHostChange());
|
||||||
if (command != null){
|
if (command != null){
|
||||||
Answer answer = _agentMgr.send(hostId, command);
|
Answer answer = _agentMgr.send(hostId, command);
|
||||||
if (!answer.getResult()) {
|
if (!answer.getResult()) {
|
||||||
@ -2233,7 +2218,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (info != null && (vm.getState() == State.Stopped || vm.getState() == State.Stopping
|
else if (info != null && (vm.getState() == State.Stopped || vm.getState() == State.Stopping
|
||||||
|| vm.isRemoved() || vm.getState() == State.Destroyed || vm.getState() == State.Expunging )) {
|
|| vm.isRemoved() || vm.getState() == State.Destroyed || vm.getState() == State.Expunging)) {
|
||||||
Host host = _hostDao.findByGuid(info.getHostUuid());
|
Host host = _hostDao.findByGuid(info.getHostUuid());
|
||||||
if (host != null){
|
if (host != null){
|
||||||
s_logger.warn("Stopping a VM which is stopped/stopping/destroyed/expunging " + info.name);
|
s_logger.warn("Stopping a VM which is stopped/stopping/destroyed/expunging " + info.name);
|
||||||
@ -2255,7 +2240,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
// host id can change
|
// host id can change
|
||||||
if (info != null && vm.getState() == State.Running){
|
if (info != null && vm.getState() == State.Running) {
|
||||||
// check for host id changes
|
// check for host id changes
|
||||||
Host host = _hostDao.findByGuid(info.getHostUuid());
|
Host host = _hostDao.findByGuid(info.getHostUuid());
|
||||||
if (host != null && (vm.getHostId() == null || host.getId() != vm.getHostId())){
|
if (host != null && (vm.getHostId() == null || host.getId() != vm.getHostId())){
|
||||||
@ -2306,24 +2291,16 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
long alien_vm_count = -1;
|
long alien_vm_count = -1;
|
||||||
for (Map.Entry<String, Pair<String, State>> entry : newStates.entrySet()) {
|
for (Map.Entry<String, Pair<String, State>> entry : newStates.entrySet()) {
|
||||||
is_alien_vm = true;
|
is_alien_vm = true;
|
||||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : vmGurus) {
|
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
VMInstanceVO vm = vmGuru.findByName(name);
|
VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vmGuru, vm, entry.getValue().second(), entry.getValue().first()));
|
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first()));
|
||||||
is_alien_vm = false;
|
is_alien_vm = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Long id = vmGuru.convertToId(name);
|
|
||||||
if (id != null) {
|
|
||||||
map.put(id, new AgentVmInfo(entry.getKey(), vmGuru, null, entry.getValue().second(), entry.getValue().first()));
|
|
||||||
is_alien_vm = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// alien VMs
|
// alien VMs
|
||||||
if (is_alien_vm){
|
if (is_alien_vm){
|
||||||
map.put(alien_vm_count--, new AgentVmInfo(entry.getKey(), null, null, entry.getValue().second(), entry.getValue().first()));
|
map.put(alien_vm_count--, new AgentVmInfo(entry.getKey(), null, entry.getValue().second(), entry.getValue().first()));
|
||||||
s_logger.warn("Found an alien VM " + entry.getKey());
|
s_logger.warn("Found an alien VM " + entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2336,21 +2313,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
if (states == null) {
|
if (states == null) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
Collection<VirtualMachineGuru<? extends VMInstanceVO>> vmGurus = _vmGurus.values();
|
|
||||||
|
|
||||||
for (Map.Entry<String, VmState> entry : states.entrySet()) {
|
for (Map.Entry<String, VmState> entry : states.entrySet()) {
|
||||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : vmGurus) {
|
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
VMInstanceVO vm = vmGuru.findByName(name);
|
VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vmGuru, vm, entry.getValue().getState(), entry.getValue().getHost() ));
|
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().getState(), entry.getValue().getHost()));
|
||||||
break;
|
|
||||||
}
|
|
||||||
Long id = vmGuru.convertToId(name);
|
|
||||||
if (id != null) {
|
|
||||||
map.put(id, new AgentVmInfo(entry.getKey(), vmGuru, null,entry.getValue().getState(), entry.getValue().getHost() ));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2364,24 +2332,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<VirtualMachineGuru<? extends VMInstanceVO>> vmGurus = _vmGurus.values();
|
|
||||||
|
|
||||||
for (Map.Entry<String, State> entry : states.entrySet()) {
|
for (Map.Entry<String, State> entry : states.entrySet()) {
|
||||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : vmGurus) {
|
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
|
VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
|
||||||
VMInstanceVO vm = vmGuru.findByName(name);
|
|
||||||
|
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vmGuru, vm, entry.getValue()));
|
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue()));
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Long id = vmGuru.convertToId(name);
|
|
||||||
if (id != null) {
|
|
||||||
map.put(id, new AgentVmInfo(entry.getKey(), vmGuru, null,entry.getValue()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2792,19 +2747,17 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
public State state;
|
public State state;
|
||||||
public String hostUuid;
|
public String hostUuid;
|
||||||
public VMInstanceVO vm;
|
public VMInstanceVO vm;
|
||||||
public VirtualMachineGuru<VMInstanceVO> guru;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public AgentVmInfo(String name, VirtualMachineGuru<? extends VMInstanceVO> guru, VMInstanceVO vm, State state, String host) {
|
public AgentVmInfo(String name, VMInstanceVO vm, State state, String host) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.vm = vm;
|
this.vm = vm;
|
||||||
this.guru = (VirtualMachineGuru<VMInstanceVO>) guru;
|
|
||||||
hostUuid = host;
|
hostUuid = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentVmInfo(String name, VirtualMachineGuru<? extends VMInstanceVO> guru, VMInstanceVO vm, State state) {
|
public AgentVmInfo(String name, VMInstanceVO vm, State state) {
|
||||||
this(name, guru, vm, state, null);
|
this(name, vm, state, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHostUuid() {
|
public String getHostUuid() {
|
||||||
@ -2825,7 +2778,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that the VM is stopped / running
|
// Check that the VM is stopped / running
|
||||||
if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running) )) {
|
if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running))) {
|
||||||
s_logger.warn("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState());
|
s_logger.warn("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState());
|
||||||
throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " " + " in state " + vmInstance.getState()
|
throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " " + " in state " + vmInstance.getState()
|
||||||
+ "; make sure the virtual machine is stopped/running");
|
+ "; make sure the virtual machine is stopped/running");
|
||||||
|
|||||||
@ -1,453 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.vm;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.ejb.Local;
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.BaseCmd.HTTPMethod;
|
|
||||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.RebootVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.RemoveNicFromVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.ResetVMSSHKeyCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.StartVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.UpdateDefaultNicForVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.StopAnswer;
|
|
||||||
import com.cloud.agent.api.VmDiskStatsEntry;
|
|
||||||
import com.cloud.agent.api.VmStatsEntry;
|
|
||||||
import com.cloud.agent.manager.Commands;
|
|
||||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
|
||||||
import com.cloud.dc.DataCenter;
|
|
||||||
import com.cloud.deploy.DeployDestination;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ManagementServerException;
|
|
||||||
import com.cloud.exception.PermissionDeniedException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.exception.StorageUnavailableException;
|
|
||||||
import com.cloud.exception.VirtualMachineMigrationException;
|
|
||||||
import com.cloud.host.Host;
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|
||||||
import com.cloud.network.Network.IpAddresses;
|
|
||||||
import com.cloud.offering.ServiceOffering;
|
|
||||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
|
||||||
import com.cloud.server.Criteria;
|
|
||||||
import com.cloud.storage.StoragePool;
|
|
||||||
import com.cloud.template.VirtualMachineTemplate;
|
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.cloud.uservm.UserVm;
|
|
||||||
import com.cloud.utils.Pair;
|
|
||||||
import com.cloud.utils.component.ManagerBase;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import com.cloud.utils.exception.ExecutionException;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Local(value = { UserVmManager.class, UserVmService.class })
|
|
||||||
public class MockUserVmManagerImpl extends ManagerBase implements UserVmManager, UserVmService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVmVO findByName(String name) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVmVO findById(long id) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVmVO persist(UserVmVO vm) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<UserVmVO> profile, DeployDestination dest, ReservationContext context) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<UserVmVO> profile, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean finalizeStart(VirtualMachineProfile<UserVmVO> profile, long hostId, Commands cmds, ReservationContext context) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<UserVmVO> profile) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void finalizeStop(VirtualMachineProfile<UserVmVO> profile, StopAnswer answer) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void finalizeExpunge(UserVmVO vm) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long convertToId(String vmName) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends UserVm> getVirtualMachines(long hostId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVmVO getVirtualMachine(long vmId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stopVirtualMachine(long userId, long vmId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HashMap<Long, VmStatsEntry> getVirtualMachineStatistics(long hostId, String hostName, List<Long> vmIds) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HashMap<Long, List<VmDiskStatsEntry>> getVmDiskStatistics(long hostId, String hostName, List<Long> vmIds) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean deleteVmGroup(long groupId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addInstanceToGroup(long userVmId, String group) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstanceGroupVO getGroupForVm(long vmId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeInstanceFromInstanceGroup(long vmId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(Criteria c, Account caller, Long domainId, boolean isRecursive, List<Long> permittedAccounts, boolean listAll, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean start() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stop() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm destroyVm(DestroyVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm destroyVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm resetVMPassword(ResetVMPasswordCmd cmd, String password) throws ResourceUnavailableException, InsufficientCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException, ResourceUnavailableException,
|
|
||||||
InsufficientCapacityException, ResourceAllocationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm rebootVirtualMachine(RebootVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm updateVirtualMachine(UpdateVMCmd cmd) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm addNicToVirtualMachine(AddNicToVMCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, CloudRuntimeException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm removeNicFromVirtualMachine(RemoveNicFromVMCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, CloudRuntimeException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm updateDefaultNicForVirtualMachine(UpdateDefaultNicForVMCmd cmd) throws InvalidParameterValueException, CloudRuntimeException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm startVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstanceGroup createVmGroup(CreateVMGroupCmd cmd) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean deleteVmGroup(DeleteVMGroupCmd cmd) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm upgradeVirtualMachine(UpgradeVMCmd cmd) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm stopVirtualMachine(long vmId, boolean forced) throws ConcurrentOperationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deletePrivateTemplateRecord(Long templateId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HypervisorType getHypervisorTypeOfUserVM(long vmid) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException,
|
|
||||||
ResourceAllocationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm getUserVm(long vmId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner,
|
|
||||||
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
|
|
||||||
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
|
|
||||||
IpAddresses defaultIp, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList)
|
|
||||||
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException,
|
|
||||||
ResourceAllocationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList,
|
|
||||||
List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize,
|
|
||||||
String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData,
|
|
||||||
String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps,
|
|
||||||
Boolean displayVm, String keyboard, List<Long> affinityGroupIdList) throws InsufficientCapacityException,
|
|
||||||
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
|
|
||||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
|
|
||||||
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
|
|
||||||
IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList) throws InsufficientCapacityException,
|
|
||||||
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VirtualMachine migrateVirtualMachine(Long vmId, Host destinationHost) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
|
|
||||||
VirtualMachineMigrationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinationHost, Map<String, String> volumeToPool)
|
|
||||||
throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
|
|
||||||
VirtualMachineMigrationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm moveVMToUser(AssignVMCmd moveUserVMCmd)
|
|
||||||
throws ResourceAllocationException, ConcurrentOperationException,
|
|
||||||
ResourceUnavailableException, InsufficientCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException {
|
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean upgradeVirtualMachine(Long id, Long serviceOfferingId) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException {
|
|
||||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prepareStop(VirtualMachineProfile<UserVmVO> profile) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setupVmForPvlan(boolean add, Long hostId, NicProfile nic) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void collectVmDiskStatistics (UserVmVO userVm) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,323 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.vm;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.ejb.Local;
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import com.cloud.deploy.DeploymentPlanner;
|
|
||||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.to.NicTO;
|
|
||||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
|
||||||
import com.cloud.deploy.DeployDestination;
|
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
|
||||||
import com.cloud.exception.AgentUnavailableException;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InsufficientServerCapacityException;
|
|
||||||
import com.cloud.exception.ManagementServerException;
|
|
||||||
import com.cloud.exception.OperationTimedoutException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.exception.VirtualMachineMigrationException;
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|
||||||
import com.cloud.network.Network;
|
|
||||||
import com.cloud.network.dao.NetworkVO;
|
|
||||||
import com.cloud.offering.ServiceOffering;
|
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
|
||||||
import com.cloud.storage.DiskOfferingVO;
|
|
||||||
import com.cloud.storage.StoragePool;
|
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.storage.VolumeVO;
|
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.cloud.user.User;
|
|
||||||
import com.cloud.utils.Pair;
|
|
||||||
import com.cloud.utils.component.ManagerBase;
|
|
||||||
import com.cloud.utils.fsm.NoTransitionException;
|
|
||||||
import com.cloud.vm.VirtualMachine.Event;
|
|
||||||
import com.cloud.vm.VirtualMachine.Type;
|
|
||||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Local(value = VirtualMachineManager.class)
|
|
||||||
public class MockVirtualMachineManagerImpl extends ManagerBase implements VirtualMachineManager {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean start() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stop() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> boolean stop(T vm, User caller, Account account) throws ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> boolean expunge(T vm, User caller, Account account) throws ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> void registerGuru(Type type, VirtualMachineGuru<T> guru) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stateTransitTo(VMInstanceVO vm, Event e, Long hostId) throws NoTransitionException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException,
|
|
||||||
ConcurrentOperationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> boolean advanceExpunge(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> boolean remove(T vm, User caller, Account account) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean migrateAway(Type type, long vmid, long hostId) throws InsufficientServerCapacityException, VirtualMachineMigrationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T migrate(T vm, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
|
|
||||||
VirtualMachineMigrationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T migrateWithStorage(T vm, long srcHostId, long destHostId,
|
|
||||||
Map<VolumeVO, StoragePoolVO> volumeToPool) throws ResourceUnavailableException,
|
|
||||||
ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VMInstanceVO findByIdAndType(Type type, long vmId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVirtualMachineUpgradable(VirtualMachine vm, ServiceOffering offering) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
|
|
||||||
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings, List<Pair<NetworkVO, NicProfile>> networks, Map<Param, Object> params, DeploymentPlan plan, HypervisorType hyperType, Account owner)
|
|
||||||
throws InsufficientCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, Long rootSize, Pair<DiskOfferingVO, Long> dataDiskOffering,
|
|
||||||
List<Pair<NetworkVO, NicProfile>> networks, DeploymentPlan plan, HypervisorType hyperType, Account owner) throws InsufficientCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, List<Pair<NetworkVO, NicProfile>> networkProfiles, DeploymentPlan plan,
|
|
||||||
HypervisorType hyperType, Account owner) throws InsufficientCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
|
|
||||||
ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T advanceStart(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException,
|
|
||||||
ConcurrentOperationException, OperationTimedoutException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T advanceStart(T vm, Map<Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
|
|
||||||
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T reboot(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T advanceReboot(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException,
|
|
||||||
ConcurrentOperationException, OperationTimedoutException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T storageMigration(T vm,
|
|
||||||
StoragePool storagePoolId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VMInstanceVO findById(long vmId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.cloud.vm.VirtualMachineManager#checkIfCanUpgrade(com.cloud.vm.VirtualMachine, long)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void checkIfCanUpgrade(VirtualMachine vmInstance, long newServiceOfferingId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.cloud.vm.VirtualMachineManager#upgradeVmDb(long, long)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean upgradeVmDb(long vmId, long serviceOfferingId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.cloud.vm.VirtualMachineManager#toNicTO(com.cloud.vm.NicProfile, com.cloud.hypervisor.Hypervisor.HypervisorType)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.cloud.vm.VirtualMachineManager#toVmTO(com.cloud.vm.VirtualMachineProfile)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public VirtualMachineTO toVmTO(VirtualMachineProfile<? extends VMInstanceVO> profile) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VMInstanceVO reConfigureVm(VMInstanceVO vm, ServiceOffering newServiceOffering, boolean sameHost) throws ResourceUnavailableException, ConcurrentOperationException {
|
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VMInstanceVO findHostAndMigrate(Type vmType, VMInstanceVO vm, Long newSvcOfferingId, DeploymentPlanner.ExcludeList excludeHostList) throws InsufficientCapacityException,
|
|
||||||
ConcurrentOperationException, ResourceUnavailableException,
|
|
||||||
VirtualMachineMigrationException, ManagementServerException{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends VMInstanceVO> T migrateForScale(T vm, long srcHostId, DeployDestination dest, Long newSvcOfferingId) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException {
|
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.cloud.vm.VirtualMachineManager#addVmToNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network, com.cloud.vm.NicProfile)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile requested) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.cloud.vm.VirtualMachineManager#removeVmFromNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network, java.net.URI)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean removeNicFromVm(VirtualMachine vm, NicVO nic) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.cloud.vm.VirtualMachineManager#removeVmFromNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network, java.net.URI)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean removeVmFromNetwork(VirtualMachine vm, Network network, URI broadcastUri) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -17,81 +17,90 @@
|
|||||||
|
|
||||||
package com.cloud.vm;
|
package com.cloud.vm;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Matchers.anyLong;
|
||||||
|
import static org.mockito.Matchers.isA;
|
||||||
|
import static org.mockito.Mockito.doNothing;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.mockito.Spy;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
|
||||||
|
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.AgentManager;
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
|
import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
||||||
|
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||||
|
import com.cloud.agent.api.MigrateWithStorageAnswer;
|
||||||
|
import com.cloud.agent.api.MigrateWithStorageCommand;
|
||||||
|
import com.cloud.agent.api.MigrateWithStorageCompleteAnswer;
|
||||||
|
import com.cloud.agent.api.MigrateWithStorageCompleteCommand;
|
||||||
|
import com.cloud.agent.api.MigrateWithStorageReceiveAnswer;
|
||||||
|
import com.cloud.agent.api.MigrateWithStorageReceiveCommand;
|
||||||
|
import com.cloud.agent.api.MigrateWithStorageSendAnswer;
|
||||||
|
import com.cloud.agent.api.MigrateWithStorageSendCommand;
|
||||||
|
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
||||||
|
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||||
import com.cloud.agent.api.ScaleVmAnswer;
|
import com.cloud.agent.api.ScaleVmAnswer;
|
||||||
import com.cloud.agent.api.ScaleVmCommand;
|
import com.cloud.agent.api.ScaleVmCommand;
|
||||||
import com.cloud.capacity.CapacityManager;
|
import com.cloud.capacity.CapacityManager;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.deploy.DeployDestination;
|
|
||||||
import com.cloud.deploy.DeploymentPlanner;
|
|
||||||
import com.cloud.host.HostVO;
|
|
||||||
import com.cloud.host.dao.HostDao;
|
|
||||||
import com.cloud.server.ConfigurationServer;
|
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.storage.VolumeManager;
|
|
||||||
import com.cloud.storage.VolumeVO;
|
|
||||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
|
||||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
|
||||||
import com.cloud.agent.api.MigrateWithStorageAnswer;
|
|
||||||
import com.cloud.agent.api.MigrateWithStorageCommand;
|
|
||||||
import com.cloud.agent.api.MigrateWithStorageReceiveAnswer;
|
|
||||||
import com.cloud.agent.api.MigrateWithStorageReceiveCommand;
|
|
||||||
import com.cloud.agent.api.MigrateWithStorageSendAnswer;
|
|
||||||
import com.cloud.agent.api.MigrateWithStorageSendCommand;
|
|
||||||
import com.cloud.agent.api.MigrateWithStorageCompleteAnswer;
|
|
||||||
import com.cloud.agent.api.MigrateWithStorageCompleteCommand;
|
|
||||||
import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
|
||||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
|
||||||
import com.cloud.dc.dao.ClusterDao;
|
import com.cloud.dc.dao.ClusterDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
import com.cloud.dc.dao.HostPodDao;
|
||||||
|
import com.cloud.deploy.DeployDestination;
|
||||||
|
import com.cloud.deploy.DeploymentPlanner;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.ManagementServerException;
|
import com.cloud.exception.ManagementServerException;
|
||||||
|
import com.cloud.exception.OperationTimedoutException;
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
import com.cloud.exception.ResourceUnavailableException;
|
||||||
import com.cloud.exception.VirtualMachineMigrationException;
|
import com.cloud.exception.VirtualMachineMigrationException;
|
||||||
import com.cloud.exception.OperationTimedoutException;
|
import com.cloud.host.HostVO;
|
||||||
|
import com.cloud.host.dao.HostDao;
|
||||||
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.hypervisor.HypervisorGuru;
|
import com.cloud.hypervisor.HypervisorGuru;
|
||||||
import com.cloud.hypervisor.HypervisorGuruManager;
|
import com.cloud.hypervisor.HypervisorGuruManager;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|
||||||
import com.cloud.network.NetworkManager;
|
import com.cloud.network.NetworkManager;
|
||||||
|
import com.cloud.server.ConfigurationServer;
|
||||||
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.storage.DiskOfferingVO;
|
import com.cloud.storage.DiskOfferingVO;
|
||||||
import com.cloud.storage.StoragePoolHostVO;
|
import com.cloud.storage.StoragePoolHostVO;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
|
import com.cloud.storage.VolumeManager;
|
||||||
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.dao.DiskOfferingDao;
|
import com.cloud.storage.dao.DiskOfferingDao;
|
||||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
import com.cloud.user.*;
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.AccountManager;
|
||||||
|
import com.cloud.user.AccountVO;
|
||||||
|
import com.cloud.user.UserVO;
|
||||||
import com.cloud.user.dao.AccountDao;
|
import com.cloud.user.dao.AccountDao;
|
||||||
import com.cloud.user.dao.UserDao;
|
import com.cloud.user.dao.UserDao;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import com.cloud.vm.dao.UserVmDao;
|
|
||||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
|
||||||
import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
|
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.snapshot.VMSnapshotManager;
|
|
||||||
import com.cloud.vm.VirtualMachine.Event;
|
import com.cloud.vm.VirtualMachine.Event;
|
||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
|
import com.cloud.vm.dao.UserVmDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
|
import com.cloud.vm.snapshot.VMSnapshotManager;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.mockito.Spy;
|
|
||||||
import static org.mockito.Matchers.anyLong;
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class VirtualMachineManagerImplTest {
|
public class VirtualMachineManagerImplTest {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user