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 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.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.VirtualMachineEntityImpl;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.VolumeManager;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
_itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType);
|
||||
|
||||
return vmEntity;
|
||||
}
|
||||
@ -266,9 +264,7 @@ public class CloudOrchestrator implements OrchestrationService {
|
||||
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
_itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType);
|
||||
|
||||
return vmEntity;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
// 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,
|
||||
@ -189,9 +189,9 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
PodVlanMapDao _podVlanMapDao;
|
||||
@Inject
|
||||
ElasticLbVmMapDao _elbVmMapDao;
|
||||
@Inject
|
||||
@Inject
|
||||
NetworkDao _networksDao;
|
||||
@Inject
|
||||
@Inject
|
||||
AccountDao _accountDao;
|
||||
@Inject
|
||||
PhysicalNetworkServiceProviderDao _physicalProviderDao;
|
||||
@ -228,7 +228,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
}
|
||||
}
|
||||
|
||||
public DomainRouterVO deployLoadBalancerVM(Long networkId, IPAddressVO ipAddr, Long accountId) {
|
||||
public DomainRouterVO deployLoadBalancerVM(Long networkId, IPAddressVO ipAddr, Long accountId) {
|
||||
NetworkVO network = _networkDao.findById(networkId);
|
||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||
Long podId = getPodIdForDirectIp(ipAddr);
|
||||
@ -300,7 +300,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
String uuid = rule.getUuid();
|
||||
List<LbDestination> destinations = rule.getDestinations();
|
||||
LoadBalancerTO lb = new LoadBalancerTO(uuid, elbIp, srcPort, protocol, algorithm, revoked, false, false, destinations);
|
||||
lbs[i++] = lb;
|
||||
lbs[i++] = lb;
|
||||
}
|
||||
|
||||
NetworkOffering offering =_networkOfferingDao.findById(guestNetworkId);
|
||||
@ -411,8 +411,8 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
_elasticLbVmRamSize = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmMemory.key()), DEFAULT_ELB_VM_RAMSIZE);
|
||||
_elasticLbvmCpuMHz = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmCpuMhz.key()), DEFAULT_ELB_VM_CPU_MHZ);
|
||||
_elasticLbvmNumCpu = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmNumVcpu.key()), 1);
|
||||
_elasticLbVmOffering = new ServiceOfferingVO("System Offering For Elastic LB VM", _elasticLbvmNumCpu,
|
||||
_elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, useLocalStorage,
|
||||
_elasticLbVmOffering = new ServiceOfferingVO("System Offering For Elastic LB VM", _elasticLbvmNumCpu,
|
||||
_elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, useLocalStorage,
|
||||
true, null, true, VirtualMachine.Type.ElasticLoadBalancerVm, true);
|
||||
_elasticLbVmOffering.setUniqueName(ServiceOffering.elbVmDefaultOffUniqueName);
|
||||
_elasticLbVmOffering = _serviceOfferingDao.persistSystemServiceOffering(_elasticLbVmOffering);
|
||||
@ -430,7 +430,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
throw new ConfigurationException("ELB: Traffic type for front end of load balancer has to be guest or public; found : " + traffType);
|
||||
s_logger.info("ELB: Elastic Load Balancer: will balance on " + traffType );
|
||||
int gcIntervalMinutes = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmGcInterval.key()), 5);
|
||||
if (gcIntervalMinutes < 5)
|
||||
if (gcIntervalMinutes < 5)
|
||||
gcIntervalMinutes = 5;
|
||||
s_logger.info("ELB: Elastic Load Balancer: scheduling GC to run every " + gcIntervalMinutes + " minutes" );
|
||||
_gcThreadPool = Executors.newScheduledThreadPool(1, new NamedThreadFactory("ELBVM-GC"));
|
||||
@ -475,8 +475,8 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Starting a ELB vm for network configurations: " + guestNetwork + " in " + dest);
|
||||
}
|
||||
assert guestNetwork.getState() == Network.State.Implemented
|
||||
|| guestNetwork.getState() == Network.State.Setup
|
||||
assert guestNetwork.getState() == Network.State.Implemented
|
||||
|| guestNetwork.getState() == Network.State.Setup
|
||||
|| guestNetwork.getState() == Network.State.Implementing : "Network is not yet fully implemented: " + guestNetwork;
|
||||
|
||||
DataCenterDeployment plan = null;
|
||||
@ -513,12 +513,14 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
throw new CloudRuntimeException("Cannot find virtual router provider " + typeString + " as service provider " + provider.getId());
|
||||
}
|
||||
|
||||
elbVm = new DomainRouterVO(id, _elasticLbVmOffering.getId(), vrProvider.getId(),
|
||||
elbVm = new DomainRouterVO(id, _elasticLbVmOffering.getId(), vrProvider.getId(),
|
||||
VirtualMachineName.getSystemVmName(id, _instance, _elbVmNamePrefix), template.getId(), template.getHypervisorType(),
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), false, 0, false, RedundantState.UNKNOWN,
|
||||
_elasticLbVmOffering.getOfferHA(), false, VirtualMachine.Type.ElasticLoadBalancerVm, null);
|
||||
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
|
||||
}
|
||||
|
||||
@ -558,7 +560,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
|
||||
protected List<LoadBalancerVO> findExistingLoadBalancers(String lbName, Long ipId, Long accountId, Long domainId, Integer publicPort) {
|
||||
SearchBuilder<LoadBalancerVO> sb = _lbDao.createSearchBuilder();
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
|
||||
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
sb.and("publicPort", sb.entity().getSourcePortStart(), SearchCriteria.Op.EQ);
|
||||
if (ipId != null) {
|
||||
@ -575,7 +577,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
sc.setParameters("accountId", accountId);
|
||||
if (ipId != null) {
|
||||
sc.setParameters("sourceIpAddress", ipId);
|
||||
}
|
||||
}
|
||||
if (domainId != null) {
|
||||
sc.setParameters("domainId",domainId);
|
||||
}
|
||||
@ -595,7 +597,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
|
||||
PublicIp ip = _networkMgr.assignPublicIpAddress(frontEndNetwork.getDataCenterId(), null, account, VlanType.DirectAttached, frontEndNetwork.getId(), null, true);
|
||||
IPAddressVO ipvo = _ipAddressDao.findById(ip.getId());
|
||||
ipvo.setAssociatedWithNetworkId(frontEndNetwork.getId());
|
||||
ipvo.setAssociatedWithNetworkId(frontEndNetwork.getId());
|
||||
_ipAddressDao.update(ipvo.getId(), ipvo);
|
||||
txn.commit();
|
||||
s_logger.info("Acquired frontend IP for ELB " + ip);
|
||||
@ -606,7 +608,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
public void releaseIp(long ipId, long userId, Account caller) {
|
||||
s_logger.info("ELB: Release public IP for loadbalancing " + ipId);
|
||||
IPAddressVO ipvo = _ipAddressDao.findById(ipId);
|
||||
ipvo.setAssociatedWithNetworkId(null);
|
||||
ipvo.setAssociatedWithNetworkId(null);
|
||||
_ipAddressDao.update(ipvo.getId(), ipvo);
|
||||
_networkMgr.disassociatePublicIpAddress(ipId, userId, caller);
|
||||
_ipAddressDao.unassignIpAddress(ipId);
|
||||
@ -639,7 +641,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
existingLbs = findExistingLoadBalancers(lb.getName(), null, lb.getAccountId(), lb.getDomainId(), null);
|
||||
if (existingLbs != null) {
|
||||
throw new InvalidParameterValueException("Supplied LB name " + lb.getName() + " is not associated with IP " + lb.getSourceIpAddressId() );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s_logger.debug("Could not find any existing frontend ips for this account for this LB rule, acquiring a new frontent IP for ELB");
|
||||
PublicIp ip = allocDirectIp(account, networkId);
|
||||
@ -662,7 +664,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
try {
|
||||
lb.setSourceIpAddressId(ipId);
|
||||
|
||||
result = _lbMgr.createPublicLoadBalancer(lb.getXid(), lb.getName(), lb.getDescription(),
|
||||
result = _lbMgr.createPublicLoadBalancer(lb.getXid(), lb.getName(), lb.getDescription(),
|
||||
lb.getSourcePortStart(), lb.getDefaultPortStart(), ipId.longValue(), lb.getProtocol(),
|
||||
lb.getAlgorithm(), false, CallContext.current());
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
@ -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
|
||||
public DomainRouterVO findById(long id) {
|
||||
return _routerDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterVO persist(DomainRouterVO elbVm) {
|
||||
return _routerDao.persist(elbVm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest, ReservationContext context) {
|
||||
DomainRouterVO elbVm = profile.getVirtualMachine();
|
||||
@ -860,7 +848,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
String domain = guestNetwork.getNetworkDomain();
|
||||
if (domain != null) {
|
||||
buf.append(" domain=" + domain);
|
||||
}
|
||||
}
|
||||
|
||||
buf.append(" dns1=").append(defaultDns1);
|
||||
if (defaultDns2 != null) {
|
||||
@ -983,17 +971,8 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long convertToId(String vmName) {
|
||||
if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, _elbVmNamePrefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return VirtualMachineName.getSystemVmId(vmName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
// 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,
|
||||
@ -150,26 +150,11 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@Inject ConfigurationServer _configServer;
|
||||
|
||||
@Override
|
||||
public DomainRouterVO findByName(String name) {
|
||||
if (!VirtualMachineName.isValidSystemVmName(name, _instance, _internalLbVmNamePrefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return _internalLbVmDao.findById(VirtualMachineName.getRouterId(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterVO findById(long id) {
|
||||
return _internalLbVmDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterVO persist(DomainRouterVO vm) {
|
||||
DomainRouterVO virtualRouter = _internalLbVmDao.persist(vm);
|
||||
return virtualRouter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile,
|
||||
DeployDestination dest, ReservationContext context) {
|
||||
@ -208,7 +193,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
// Internal LB control command is sent over management server in VMware
|
||||
if (dest.getHost().getHypervisorType() == HypervisorType.VMware) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Check if we need to add management server explicit route to Internal LB. pod cidr: "
|
||||
s_logger.info("Check if we need to add management server explicit route to Internal LB. pod cidr: "
|
||||
+ dest.getPod().getCidrAddress() + "/" + dest.getPod().getCidrSize()
|
||||
+ ", pod gateway: " + dest.getPod().getGateway() + ", management host: " + _mgmtHost);
|
||||
}
|
||||
@ -325,7 +310,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
|
||||
// restart network if restartNetwork = false is not specified in profile parameters
|
||||
boolean reprogramGuestNtwk = true;
|
||||
if (profile.getParameter(Param.ReProgramGuestNetworks) != null
|
||||
if (profile.getParameter(Param.ReProgramGuestNetworks) != null
|
||||
&& (Boolean) profile.getParameter(Param.ReProgramGuestNetworks) == false) {
|
||||
reprogramGuestNtwk = false;
|
||||
}
|
||||
@ -356,15 +341,6 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
public void finalizeExpunge(DomainRouterVO vm) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long convertToId(String vmName) {
|
||||
if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, _internalLbVmNamePrefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return VirtualMachineName.getRouterId(vmName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
|
||||
}
|
||||
@ -477,9 +453,9 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
|
||||
Network guestNetwork = _ntwkModel.getNetwork(guestNetworkId);
|
||||
Nic guestNic = _nicDao.findByNtwkIdAndInstanceId(guestNetwork.getId(), internalLbVm.getId());
|
||||
NicProfile guestNicProfile = new NicProfile(guestNic, guestNetwork, guestNic.getBroadcastUri(), guestNic.getIsolationUri(),
|
||||
_ntwkModel.getNetworkRate(guestNetwork.getId(), internalLbVm.getId()),
|
||||
_ntwkModel.isSecurityGroupSupportedInNetwork(guestNetwork),
|
||||
NicProfile guestNicProfile = new NicProfile(guestNic, guestNetwork, guestNic.getBroadcastUri(), guestNic.getIsolationUri(),
|
||||
_ntwkModel.getNetworkRate(guestNetwork.getId(), internalLbVm.getId()),
|
||||
_ntwkModel.isSecurityGroupSupportedInNetwork(guestNetwork),
|
||||
_ntwkModel.getNetworkTag(internalLbVm.getHypervisorType(), guestNetwork));
|
||||
|
||||
NetworkOffering offering =_networkOfferingDao.findById(guestNetworkId);
|
||||
@ -541,7 +517,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, internalLbVm);
|
||||
|
||||
return _itMgr.expunge(internalLbVm, _accountMgr.getActiveUser(callerUserId), caller);
|
||||
return _itMgr.expunge(internalLbVm, _accountMgr.getActiveUser(callerUserId), caller);
|
||||
}
|
||||
|
||||
|
||||
@ -574,7 +550,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> deployInternalLbVm(Network guestNetwork, Ip requestedGuestIp, DeployDestination dest,
|
||||
public List<DomainRouterVO> deployInternalLbVm(Network guestNetwork, Ip requestedGuestIp, DeployDestination dest,
|
||||
Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
@ -583,7 +559,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
return startInternalLbVms(params, internalLbVms);
|
||||
}
|
||||
|
||||
protected List<DomainRouterVO> startInternalLbVms(Map<Param, Object> params, List<DomainRouterVO> internalLbVms)
|
||||
protected List<DomainRouterVO> startInternalLbVms(Map<Param, Object> params, List<DomainRouterVO> internalLbVms)
|
||||
throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
List<DomainRouterVO> runningInternalLbVms = null;
|
||||
|
||||
@ -609,8 +585,8 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
|
||||
|
||||
@DB
|
||||
protected List<DomainRouterVO> findOrDeployInternalLbVm(Network guestNetwork, Ip requestedGuestIp, DeployDestination dest,
|
||||
Account owner, Map<Param, Object> params) throws ConcurrentOperationException,
|
||||
protected List<DomainRouterVO> findOrDeployInternalLbVm(Network guestNetwork, Ip requestedGuestIp, DeployDestination dest,
|
||||
Account owner, Map<Param, Object> params) throws ConcurrentOperationException,
|
||||
InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
||||
List<DomainRouterVO> internalLbVms = new ArrayList<DomainRouterVO>();
|
||||
@ -688,7 +664,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
s_logger.debug("Adding nic for Internal LB in Guest network " + guestNetwork);
|
||||
NicProfile guestNic = new NicProfile();
|
||||
if (guestIp != null) {
|
||||
guestNic.setIp4Address(guestIp.addr());
|
||||
guestNic.setIp4Address(guestIp.addr());
|
||||
} else {
|
||||
guestNic.setIp4Address(_ntwkMgr.acquireGuestIpAddress(guestNetwork, null));
|
||||
}
|
||||
@ -789,12 +765,14 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
continue;
|
||||
}
|
||||
|
||||
internalLbVm = new DomainRouterVO(id, routerOffering.getId(), internalLbProviderId,
|
||||
internalLbVm = new DomainRouterVO(id, routerOffering.getId(), internalLbProviderId,
|
||||
VirtualMachineName.getSystemVmName(id, _instance, _internalLbVmNamePrefix), template.getId(), template.getHypervisorType(),
|
||||
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);
|
||||
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) {
|
||||
if (allocateRetry < 2 && iter.hasNext()) {
|
||||
s_logger.debug("Failed to allocate the Internal lb vm with hypervisor type " + hType + ", retrying one more time");
|
||||
@ -833,7 +811,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
|
||||
|
||||
|
||||
protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, Account caller, long callerUserId, Map<Param, Object> params)
|
||||
protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, Account caller, long callerUserId, Map<Param, Object> params)
|
||||
throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
s_logger.debug("Starting Internal LB VM " + internalLbVm);
|
||||
@ -850,7 +828,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
}
|
||||
|
||||
|
||||
protected List<HypervisorType> getHypervisors(DeployDestination dest, DeploymentPlan plan,
|
||||
protected List<HypervisorType> getHypervisors(DeployDestination dest, DeploymentPlan plan,
|
||||
List<HypervisorType> supportedHypervisors) throws InsufficientServerCapacityException {
|
||||
List<HypervisorType> hypervisors = new ArrayList<HypervisorType>();
|
||||
|
||||
@ -880,7 +858,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyLoadBalancingRules(Network network, final List<LoadBalancingRule> rules, List<? extends VirtualRouter> internalLbVms)
|
||||
public boolean applyLoadBalancingRules(Network network, final List<LoadBalancingRule> rules, List<? extends VirtualRouter> internalLbVms)
|
||||
throws ResourceUnavailableException {
|
||||
if (rules == null || rules.isEmpty()) {
|
||||
s_logger.debug("No lb rules to be applied for network " + network);
|
||||
@ -896,7 +874,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
if (lbVm.getState() == State.Running) {
|
||||
return sendLBRules(lbVm, rules, network.getId());
|
||||
} else if (lbVm.getState() == State.Stopped || lbVm.getState() == State.Stopping) {
|
||||
s_logger.debug("Internal LB VM " + lbVm.getInstanceName() + " is in " + lbVm.getState() +
|
||||
s_logger.debug("Internal LB VM " + lbVm.getInstanceName() + " is in " + lbVm.getState() +
|
||||
", so not sending apply lb rules commands to the backend");
|
||||
return true;
|
||||
} else {
|
||||
@ -943,7 +921,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
|
||||
|
||||
@Override
|
||||
public VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId)
|
||||
public VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId)
|
||||
throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
|
||||
@ -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(),
|
||||
systemAcct.getId(), 0, _serviceOffering.getOfferHA());
|
||||
proxy = _consoleProxyDao.persist(proxy);
|
||||
try {
|
||||
proxy = _itMgr.allocate(proxy, template, _serviceOffering, networks, plan, null, systemAcct);
|
||||
_itMgr.allocate(name, template, _serviceOffering, networks, plan, null);
|
||||
} catch (InsufficientCapacityException e) {
|
||||
s_logger.warn("InsufficientCapacity", e);
|
||||
throw new CloudRuntimeException("Insufficient capacity exception", e);
|
||||
@ -1008,14 +1009,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long convertToId(String vmName) {
|
||||
if (!VirtualMachineName.isValidConsoleProxyName(vmName, _instance)) {
|
||||
return null;
|
||||
}
|
||||
return VirtualMachineName.getConsoleProxyId(vmName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopProxy(long proxyVmId) {
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
@ -1479,26 +1472,11 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
||||
_consoleProxyDao.update(proxy.getId(), proxy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO persist(ConsoleProxyVO proxy) {
|
||||
return _consoleProxyDao.persist(proxy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO findById(long id) {
|
||||
return _consoleProxyDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO findByName(String name) {
|
||||
if (!VirtualMachineName.isValidConsoleProxyName(name)) {
|
||||
return null;
|
||||
}
|
||||
return findById(VirtualMachineName.getConsoleProxyId(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, StopAnswer answer) {
|
||||
//release elastic IP here if assigned
|
||||
|
||||
@ -790,15 +790,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
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,
|
||||
String serviceOffering, String zoneName, String guestIpAddress, String vmName,
|
||||
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();
|
||||
HostVO host = _hostDao.findById(router.getHostId());
|
||||
if (host == null || host.getStatus() != Status.Up) {
|
||||
if (host == null || host.getState() != Status.Up) {
|
||||
continue;
|
||||
} else if (host.getManagementServerId() != ManagementServerNode.getManagementServerId()) {
|
||||
/* Only cover hosts managed by this management server */
|
||||
@ -1118,7 +1109,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
} else {
|
||||
String privateIP = router.getPrivateIpAddress();
|
||||
HostVO host = _hostDao.findById(router.getHostId());
|
||||
if (host == null || host.getStatus() != Status.Up) {
|
||||
if (host == null || host.getState() != Status.Up) {
|
||||
router.setRedundantState(RedundantState.UNKNOWN);
|
||||
updated = true;
|
||||
} else if (privateIP != null) {
|
||||
@ -1177,7 +1168,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
if (masterRouter.getState() == State.Running && backupRouter.getState() == State.Running) {
|
||||
HostVO masterHost = _hostDao.findById(masterRouter.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";
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug(title);
|
||||
@ -1412,7 +1403,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
}
|
||||
|
||||
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 " +
|
||||
cv.getId() + " to start domain router for OVM");
|
||||
return h.getHypervisorType();
|
||||
@ -1658,7 +1649,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), isRedundant, 0, false,
|
||||
RedundantState.UNKNOWN, offerHA, false, vpcId);
|
||||
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) {
|
||||
if (allocateRetry < 2 && iter.hasNext()) {
|
||||
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();
|
||||
if (router.getHostId() != null && state != State.Running) {
|
||||
HostVO host = _hostDao.findById(router.getHostId());
|
||||
if (host == null || host.getStatus() != Status.Up) {
|
||||
if (host == null || host.getState() != Status.Up) {
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
@ -2673,7 +2666,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
if (router.getState() != State.Running) {
|
||||
s_logger.warn("Failed to start remote access VPN: router not in right state " + router.getState());
|
||||
throw new ResourceUnavailableException("Failed to start remote access VPN: router not in right state "
|
||||
+ router.getState(), DataCenter.class, network.getDataCenterId());
|
||||
+ router.getState(), DataCenter.class, network.getDataCenterId());
|
||||
}
|
||||
|
||||
Commands cmds = new Commands(OnError.Stop);
|
||||
@ -2741,7 +2734,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
} else {
|
||||
s_logger.warn("Failed to delete remote access VPN: domR " + router + " is not in right state " + router.getState());
|
||||
throw new ResourceUnavailableException("Failed to delete remote access VPN: domR is not in right state " +
|
||||
router.getState(), DataCenter.class, network.getDataCenterId());
|
||||
router.getState(), DataCenter.class, network.getDataCenterId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
//FIXME add partial success and STOP state support
|
||||
public String[] applyVpnUsers(Network network, List<? extends VpnUser> users, List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
||||
@ -3046,7 +3033,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
if (router.getState() != State.Running) {
|
||||
s_logger.warn("Failed to add/remove VPN users: router not in running state");
|
||||
throw new ResourceUnavailableException("Unable to assign ip addresses, domR is not in right state " +
|
||||
router.getState(), DataCenter.class, network.getDataCenterId());
|
||||
router.getState(), DataCenter.class, network.getDataCenterId());
|
||||
}
|
||||
|
||||
Commands cmds = new Commands(OnError.Continue);
|
||||
@ -3095,15 +3082,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
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)
|
||||
public VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException{
|
||||
return startRouter(id, true);
|
||||
@ -3810,7 +3788,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
s_logger.debug("Applying " + typeString + " in network " + network);
|
||||
|
||||
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 " +
|
||||
router.getInstanceName() + " haven't been stopped after it's host coming back!",
|
||||
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() +
|
||||
", so not sending apply " + typeString + " commands to the backend");
|
||||
} 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) {
|
||||
throw new ResourceUnavailableException("Unable to apply " + typeString +
|
||||
", virtual router is not in the right state", Pod.class, podId);
|
||||
|
||||
@ -164,7 +164,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
NetworkACLItemDao _networkACLItemDao;
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
|
||||
Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
if(s_logger.isTraceEnabled()) {
|
||||
@ -178,7 +178,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
@DB
|
||||
protected List<DomainRouterVO> findOrDeployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
|
||||
Map<Param, Object> params) throws ConcurrentOperationException,
|
||||
Map<Param, Object> params) throws ConcurrentOperationException,
|
||||
InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
||||
s_logger.debug("Deploying Virtual Router in VPC "+ vpc);
|
||||
@ -187,11 +187,11 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
throw new ConcurrentOperationException("Unable to lock vpc " + vpc.getId());
|
||||
}
|
||||
|
||||
//1) Get deployment plan and find out the list of routers
|
||||
//1) Get deployment plan and find out the list of routers
|
||||
Pair<DeploymentPlan, List<DomainRouterVO>> planAndRouters = getDeploymentPlanAndRouters(vpc.getId(), dest);
|
||||
DeploymentPlan plan = planAndRouters.first();
|
||||
List<DomainRouterVO> routers = planAndRouters.second();
|
||||
try {
|
||||
try {
|
||||
//2) Return routers if exist
|
||||
if (routers.size() >= 1) {
|
||||
return routers;
|
||||
@ -207,13 +207,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
VirtualRouterProvider vpcVrProvider = null;
|
||||
|
||||
for (PhysicalNetwork pNtwk : pNtwks) {
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(pNtwk.getId(),
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(pNtwk.getId(),
|
||||
VirtualRouterProviderType.VPCVirtualRouter.toString());
|
||||
if (provider == null) {
|
||||
throw new CloudRuntimeException("Cannot find service provider " +
|
||||
throw new CloudRuntimeException("Cannot find service provider " +
|
||||
VirtualRouterProviderType.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId());
|
||||
}
|
||||
vpcVrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(),
|
||||
vpcVrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(),
|
||||
VirtualRouterProviderType.VPCVirtualRouter);
|
||||
if (vpcVrProvider != null) {
|
||||
break;
|
||||
@ -245,7 +245,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
public boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("addVpcRouterToGuestNetwork(" + router.getUuid() + ", " + network.getCidr() + ", " + isRedundant + ")");
|
||||
@ -288,7 +288,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
public boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
if (network.getTrafficType() != TrafficType.Guest) {
|
||||
s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
|
||||
@ -318,8 +318,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
protected DomainRouterVO deployVpcRouter(Account owner, DeployDestination dest, DeploymentPlan plan, Map<Param, Object> params,
|
||||
boolean isRedundant, VirtualRouterProvider vrProvider, long svcOffId,
|
||||
Long vpcId, PublicIp sourceNatIp) throws ConcurrentOperationException,
|
||||
InsufficientAddressCapacityException, InsufficientServerCapacityException, InsufficientCapacityException,
|
||||
Long vpcId, PublicIp sourceNatIp) throws ConcurrentOperationException,
|
||||
InsufficientAddressCapacityException, InsufficientServerCapacityException, InsufficientCapacityException,
|
||||
StorageUnavailableException, ResourceUnavailableException {
|
||||
if(s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("deployVpcRouter(" + owner.getAccountName() + ", " + dest.getHost() + ", " + plan.toString() + ", " + params.toString()
|
||||
@ -327,19 +327,19 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
List<Pair<NetworkVO, NicProfile>> networks = createVpcRouterNetworks(owner, isRedundant, plan, new Pair<Boolean, PublicIp>(true, sourceNatIp),
|
||||
vpcId);
|
||||
DomainRouterVO router =
|
||||
super.deployRouter(owner, dest, plan, params, isRedundant, vrProvider, svcOffId, vpcId, networks, true,
|
||||
DomainRouterVO router =
|
||||
super.deployRouter(owner, dest, plan, params, isRedundant, vrProvider, svcOffId, vpcId, networks, true,
|
||||
_vpcMgr.getSupportedVpcHypervisors());
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
protected boolean setupVpcGuestNetwork(Network network, VirtualRouter router, boolean add, NicProfile guestNic)
|
||||
protected boolean setupVpcGuestNetwork(Network network, VirtualRouter router, boolean add, NicProfile guestNic)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
|
||||
boolean result = true;
|
||||
boolean result = true;
|
||||
if (router.getState() == State.Running) {
|
||||
SetupGuestNetworkCommand setupCmd = createSetupGuestNetworkCommand(router, add, guestNic);
|
||||
SetupGuestNetworkCommand setupCmd = createSetupGuestNetworkCommand(router, add, guestNic);
|
||||
|
||||
Commands cmds = new Commands(OnError.Stop);
|
||||
cmds.addCommand("setupguestnetwork", setupCmd);
|
||||
@ -353,7 +353,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
return result;
|
||||
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
|
||||
", so not sending setup guest network command to the backend");
|
||||
return true;
|
||||
} else {
|
||||
@ -370,7 +370,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
String defaultDns2 = null;
|
||||
|
||||
boolean dnsProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
|
||||
boolean dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||
boolean dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||
Provider.VPCVirtualRouter);
|
||||
|
||||
boolean setupDns = dnsProvided || dhcpProvided;
|
||||
@ -386,7 +386,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(router, nic.getNetworkId(), null);
|
||||
|
||||
SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, false, null,
|
||||
SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, false, null,
|
||||
defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
|
||||
|
||||
String brd = NetUtils.long2Ip(NetUtils.ip2Long(guestNic.getIp4Address()) | ~NetUtils.ip2Long(guestNic.getNetmask()));
|
||||
@ -441,7 +441,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
String macAddress = vlanMacAddress.get(ipAddr.getVlanTag());
|
||||
|
||||
IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, false,
|
||||
IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, false,
|
||||
ipAddr.isSourceNat(), ipAddr.getVlanTag(), ipAddr.getGateway(), ipAddr.getNetmask(), macAddress,
|
||||
networkRate, ipAddr.isOneToOneNat());
|
||||
|
||||
@ -509,7 +509,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
URI broadcastUri = BroadcastDomainType.Vlan.toUri(vlanTag);
|
||||
_itMgr.removeVmFromNetwork(router, publicNtwk, broadcastUri);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Failed to remove router " + router + " from vlan " + vlanTag +
|
||||
s_logger.warn("Failed to remove router " + router + " from vlan " + vlanTag +
|
||||
" in public network " + publicNtwk + " due to ", e);
|
||||
return false;
|
||||
}
|
||||
@ -540,14 +540,14 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
publicNtwk = _networkModel.getNetwork(ip.getNetworkId());
|
||||
publicNic = _itMgr.addVmToNetwork(router, publicNtwk, defaultNic);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
|
||||
s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
|
||||
" in public network " + publicNtwk + " due to ", e);
|
||||
} catch (InsufficientCapacityException e) {
|
||||
s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
|
||||
s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
|
||||
" in public network " + publicNtwk + " due to ", e);
|
||||
} finally {
|
||||
if (publicNic == null) {
|
||||
s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
|
||||
s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
|
||||
" in public network " + publicNtwk);
|
||||
return false;
|
||||
}
|
||||
@ -555,7 +555,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
//Create network usage commands. Send commands to router after IPAssoc
|
||||
NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(router.getPrivateIpAddress(), router.getInstanceName(), true, defaultNic.getIp4Address(), vpc.getCidr());
|
||||
netUsagecmds.addCommand(netUsageCmd);
|
||||
UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(),
|
||||
UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(),
|
||||
publicNtwk.getId(), publicNic.getIp4Address(), router.getId(), router.getType().toString());
|
||||
if (stats == null) {
|
||||
stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterId(), publicNic.getIp4Address(), router.getId(),
|
||||
@ -573,22 +573,22 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
List<PublicIpAddress> ipsToSend = new ArrayList<PublicIpAddress>();
|
||||
for (PublicIpAddress ipAddr : ipAddress) {
|
||||
String broadcastURI = BroadcastDomainType.Vlan.toUri(ipAddr.getVlanTag()).toString();
|
||||
Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ipAddr.getNetworkId(),
|
||||
Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ipAddr.getNetworkId(),
|
||||
router.getId(), broadcastURI);
|
||||
|
||||
String macAddress = null;
|
||||
if (nic == null) {
|
||||
if (ipAddr.getState() != IpAddress.State.Releasing) {
|
||||
throw new CloudRuntimeException("Unable to find the nic in network " + ipAddr.getNetworkId() +
|
||||
throw new CloudRuntimeException("Unable to find the nic in network " + ipAddr.getNetworkId() +
|
||||
" to apply the ip address " + ipAddr + " for");
|
||||
}
|
||||
s_logger.debug("Not sending release for ip address " + ipAddr +
|
||||
s_logger.debug("Not sending release for ip address " + ipAddr +
|
||||
" as its nic is already gone from VPC router " + router);
|
||||
} else {
|
||||
macAddress = nic.getMacAddress();
|
||||
vlanMacAddress.put(ipAddr.getVlanTag(), macAddress);
|
||||
ipsToSend.add(ipAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ipsToSend.isEmpty()) {
|
||||
createVpcAssociatePublicIPCommands(router, ipsToSend, cmds, vlanMacAddress);
|
||||
@ -607,7 +607,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
|
||||
@Override
|
||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest,
|
||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest,
|
||||
ReservationContext context) {
|
||||
|
||||
if (profile.getVirtualMachine().getVpcId() != null) {
|
||||
@ -751,7 +751,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
for (Pair<Nic, Network> nicNtwk : publicNics) {
|
||||
Nic publicNic = nicNtwk.first();
|
||||
Network publicNtwk = nicNtwk.second();
|
||||
IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(publicNtwk.getId(),
|
||||
IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(publicNtwk.getId(),
|
||||
publicNic.getIp4Address());
|
||||
|
||||
if (userIp.isSourceNat()) {
|
||||
@ -767,11 +767,11 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
}
|
||||
PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()), router.getInstanceName(), router.getType());
|
||||
cmds.addCommand(plugNicCmd);
|
||||
cmds.addCommand(plugNicCmd);
|
||||
VpcVO vpc = _vpcDao.findById(router.getVpcId());
|
||||
NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(router.getPrivateIpAddress(), router.getInstanceName(), true, publicNic.getIp4Address(), vpc.getCidr());
|
||||
usageCmds.add(netUsageCmd);
|
||||
UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(),
|
||||
UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(),
|
||||
publicNtwk.getId(), publicNic.getIp4Address(), router.getId(), router.getType().toString());
|
||||
if (stats == null) {
|
||||
stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterId(), publicNic.getIp4Address(), router.getId(),
|
||||
@ -788,7 +788,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
//add VPC router to guest networks
|
||||
for (Pair<Nic, Network> nicNtwk : guestNics) {
|
||||
Nic guestNic = nicNtwk.first();
|
||||
//plug guest nic
|
||||
//plug guest nic
|
||||
PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName(), router.getType());
|
||||
cmds.addCommand(plugNicCmd);
|
||||
|
||||
@ -838,18 +838,18 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
gateway = _vpcMgr.getVpcGateway(route.getVpcGatewayId());
|
||||
gatewayMap.put(gateway.getId(), gateway);
|
||||
}
|
||||
staticRouteProfiles.add(new StaticRouteProfile(route, gateway));
|
||||
staticRouteProfiles.add(new StaticRouteProfile(route, gateway));
|
||||
}
|
||||
|
||||
s_logger.debug("Found " + staticRouteProfiles.size() + " static routes to apply as a part of vpc route "
|
||||
s_logger.debug("Found " + staticRouteProfiles.size() + " static routes to apply as a part of vpc route "
|
||||
+ router + " start");
|
||||
if (!staticRouteProfiles.isEmpty()) {
|
||||
if (!staticRouteProfiles.isEmpty()) {
|
||||
createStaticRouteCommands(staticRouteProfiles, router, cmds);
|
||||
}
|
||||
|
||||
//5) REPROGRAM GUEST NETWORK
|
||||
boolean reprogramGuestNtwks = true;
|
||||
if (profile.getParameter(Param.ReProgramGuestNetworks) != null
|
||||
if (profile.getParameter(Param.ReProgramGuestNetworks) != null
|
||||
&& (Boolean) profile.getParameter(Param.ReProgramGuestNetworks) == false) {
|
||||
reprogramGuestNtwks = false;
|
||||
}
|
||||
@ -973,7 +973,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
* @return
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
protected boolean setupVpcPrivateNetwork(VirtualRouter router, boolean add, NicProfile privateNic)
|
||||
protected boolean setupVpcPrivateNetwork(VirtualRouter router, boolean add, NicProfile privateNic)
|
||||
throws ResourceUnavailableException {
|
||||
if(s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("deployVpcRouter(" + router.getHostName() + ", " + add + ", " + privateNic.getMacAddress() + ")");
|
||||
@ -999,7 +999,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
return false;
|
||||
}
|
||||
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
|
||||
", so not sending setup private network command to the backend");
|
||||
} else {
|
||||
s_logger.warn("Unable to setup private gateway, virtual router " + router + " is not in the right state " + router.getState());
|
||||
@ -1011,7 +1011,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyPrivateGateway(PrivateGateway gateway, VirtualRouter router)
|
||||
public boolean destroyPrivateGateway(PrivateGateway gateway, VirtualRouter router)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
if (!_networkModel.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) {
|
||||
@ -1041,7 +1041,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalizeIpAssocForNetwork(Commands cmds, VirtualRouter router, Provider provider,
|
||||
protected void finalizeIpAssocForNetwork(Commands cmds, VirtualRouter router, Provider provider,
|
||||
Long guestNetworkId, Map<String, String> vlanMacAddress) {
|
||||
|
||||
if (router.getVpcId() == null) {
|
||||
@ -1068,9 +1068,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
boolean result = true;
|
||||
for (VirtualRouter router : routers) {
|
||||
if (router.getState() == State.Running) {
|
||||
result = result && sendStaticRoutes(staticRoutes, routers.get(0));
|
||||
result = result && sendStaticRoutes(staticRoutes, routers.get(0));
|
||||
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() +
|
||||
", so not sending StaticRoute command to the backend");
|
||||
} else {
|
||||
s_logger.warn("Unable to apply StaticRoute, virtual router is not in the right state " + router.getState());
|
||||
@ -1082,7 +1082,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean sendStaticRoutes(List<StaticRouteProfile> staticRoutes, DomainRouterVO router)
|
||||
protected boolean sendStaticRoutes(List<StaticRouteProfile> staticRoutes, DomainRouterVO router)
|
||||
throws ResourceUnavailableException {
|
||||
Commands cmds = new Commands(OnError.Continue);
|
||||
createStaticRouteCommands(staticRoutes, router, cmds);
|
||||
@ -1202,7 +1202,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
|
||||
|
||||
protected List<Pair<NetworkVO, NicProfile>> createVpcRouterNetworks(Account owner, boolean isRedundant,
|
||||
protected List<Pair<NetworkVO, NicProfile>> createVpcRouterNetworks(Account owner, boolean isRedundant,
|
||||
DeploymentPlan plan, Pair<Boolean, PublicIp> sourceNatIp, long vpcId) throws ConcurrentOperationException,
|
||||
InsufficientAddressCapacityException {
|
||||
|
||||
@ -1237,7 +1237,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedVpc(vpcId, false);
|
||||
for (IPAddressVO ip : ips) {
|
||||
PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
|
||||
if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating)
|
||||
if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating)
|
||||
&& _vpcMgr.isIpAllocatedToVpc(ip)&& !publicVlans.contains(publicIp.getVlanTag())) {
|
||||
s_logger.debug("Allocating nic for router in vlan " + publicIp.getVlanTag());
|
||||
NicProfile publicNic = new NicProfile();
|
||||
@ -1269,9 +1269,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
if (privateNic != null) {
|
||||
VirtualMachine vm = _vmDao.findById(privateNic.getId());
|
||||
privateNicProfile = new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(),
|
||||
_networkModel.getNetworkRate(privateNetwork.getId(), vm.getId()),
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
|
||||
privateNicProfile = new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(),
|
||||
_networkModel.getNetworkRate(privateNetwork.getId(), vm.getId()),
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
|
||||
_networkModel.getNetworkTag(vm.getHypervisorType(), privateNetwork));
|
||||
} else {
|
||||
String vlanTag = privateNetwork.getBroadcastUri().getHost();
|
||||
@ -1306,7 +1306,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
return guestNic;
|
||||
}
|
||||
|
||||
protected Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> getNicsToChangeOnRouter
|
||||
protected Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> getNicsToChangeOnRouter
|
||||
(final List<? extends PublicIpAddress> publicIps, VirtualRouter router) {
|
||||
//1) check which nics need to be plugged/unplugged and plug/unplug them
|
||||
|
||||
@ -1327,7 +1327,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
Nic nic = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId, router.getId(), ip.getAddress().addr());
|
||||
if (nic != null) {
|
||||
nicsToUnplug.put(ip.getVlanTag(), ip);
|
||||
s_logger.debug("Need to unplug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() +
|
||||
s_logger.debug("Need to unplug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() +
|
||||
" in public network id =" + publicNtwkId);
|
||||
}
|
||||
}
|
||||
@ -1345,12 +1345,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
if (ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating) {
|
||||
//nic has to be plugged only when there are no nics for this vlan tag exist on VR
|
||||
Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(publicNtwkId, router.getId(),
|
||||
Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(publicNtwkId, router.getId(),
|
||||
broadcastUri.toString());
|
||||
|
||||
if (nic == null && nicsToPlug.get(ip.getVlanTag()) == null) {
|
||||
nicsToPlug.put(ip.getVlanTag(), ip);
|
||||
s_logger.debug("Need to plug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() +
|
||||
s_logger.debug("Need to plug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() +
|
||||
" in public network id =" + publicNtwkId);
|
||||
} else {
|
||||
PublicIpAddress nicToUnplug = nicsToUnplug.get(ip.getVlanTag());
|
||||
@ -1360,12 +1360,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
_nicDao.update(nicVO.getId(), nicVO);
|
||||
s_logger.debug("Updated the nic " + nicVO + " with the new ip address " + ip.getAddress().addr());
|
||||
nicsToUnplug.remove(ip.getVlanTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> nicsToChange =
|
||||
Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> nicsToChange =
|
||||
new Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>>(nicsToPlug, nicsToUnplug);
|
||||
return nicsToChange;
|
||||
}
|
||||
|
||||
@ -419,7 +419,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
|
||||
SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
|
||||
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();
|
||||
for (HostVO ssvm : ssvms) {
|
||||
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,
|
||||
systemAcct.getDomainId(), systemAcct.getId(), role, _serviceOffering.getOfferHA());
|
||||
secStorageVm = _secStorageVmDao.persist(secStorageVm);
|
||||
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) {
|
||||
s_logger.warn("InsufficientCapacity", e);
|
||||
throw new CloudRuntimeException("Insufficient capacity exception", e);
|
||||
@ -889,14 +891,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long convertToId(String vmName) {
|
||||
if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, "s")) {
|
||||
return null;
|
||||
}
|
||||
return VirtualMachineName.getSystemVmId(vmName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopSecStorageVm(long secStorageVmId) {
|
||||
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
|
||||
@ -1010,24 +1004,11 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
return "secStorageVm." + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecondaryStorageVmVO findByName(String name) {
|
||||
if (!VirtualMachineName.isValidSecStorageVmName(name, null)) {
|
||||
return null;
|
||||
}
|
||||
return findById(VirtualMachineName.getSystemVmId(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecondaryStorageVmVO findById(long id) {
|
||||
return _secStorageVmDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecondaryStorageVmVO persist(SecondaryStorageVmVO vm) {
|
||||
return _secStorageVmDao.persist(vm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<SecondaryStorageVmVO> profile, DeployDestination dest, ReservationContext context) {
|
||||
|
||||
@ -1377,7 +1358,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
if (dcId != null) {
|
||||
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);
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
@ -26,6 +26,9 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
|
||||
import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
|
||||
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.SnapshotDataStoreVO;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
@ -59,7 +59,6 @@ import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
@ -80,9 +79,9 @@ import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.storage.CreateSnapshotPayload;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Snapshot.Type;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.SnapshotPolicyVO;
|
||||
import com.cloud.storage.SnapshotScheduleVO;
|
||||
import com.cloud.storage.SnapshotVO;
|
||||
@ -269,7 +268,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "creating snapshot", async = true)
|
||||
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) {
|
||||
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
|
||||
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
|
||||
|
||||
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
|
||||
SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
|
||||
|
||||
try {
|
||||
postCreateSnapshot(volumeId, snapshot.getId(), policyId);
|
||||
@ -316,12 +315,12 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
|
||||
@Override
|
||||
public Snapshot backupSnapshot(Long snapshotId) {
|
||||
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image);
|
||||
SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image);
|
||||
if (snapshot != null) {
|
||||
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();
|
||||
|
||||
// Verify parameters
|
||||
SnapshotVO snapshotCheck = this._snapshotDao.findById(snapshotId);
|
||||
SnapshotVO snapshotCheck = _snapshotDao.findById(snapshotId);
|
||||
if (snapshotCheck == null) {
|
||||
throw new InvalidParameterValueException("unable to find a snapshot with id " + snapshotId);
|
||||
}
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, snapshotCheck);
|
||||
SnapshotStrategy snapshotStrategy = null;
|
||||
for (SnapshotStrategy strategy : this.snapshotStrategies) {
|
||||
for (SnapshotStrategy strategy : snapshotStrategies) {
|
||||
if (strategy.canHandle(snapshotCheck)) {
|
||||
snapshotStrategy = strategy;
|
||||
break;
|
||||
@ -496,7 +495,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
try {
|
||||
boolean result = snapshotStrategy.deleteSnapshot(snapshotId);
|
||||
if (result) {
|
||||
if (snapshotCheck.getState() == Snapshot.State.BackedUp) {
|
||||
if (snapshotCheck.getState() == Snapshot.State.BackedUp) {
|
||||
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_DELETE, snapshotCheck.getAccountId(),
|
||||
snapshotCheck.getDataCenterId(), snapshotId, snapshotCheck.getName(), null, null, 0L,
|
||||
snapshotCheck.getClass().getName(), snapshotCheck.getUuid());
|
||||
@ -515,9 +514,9 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
|
||||
@Override
|
||||
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){
|
||||
DataStore store = this.dataStoreMgr.getDataStore(snapshotStore.getDataStoreId(), DataStoreRole.Image);
|
||||
DataStore store = dataStoreMgr.getDataStore(snapshotStore.getDataStoreId(), DataStoreRole.Image);
|
||||
if ( store != null ){
|
||||
return store.getUri();
|
||||
}
|
||||
@ -614,7 +613,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
}
|
||||
|
||||
if (snapshotTypeStr != null) {
|
||||
Type snapshotType = SnapshotVO.getSnapshotType((String) snapshotTypeStr);
|
||||
Type snapshotType = SnapshotVO.getSnapshotType(snapshotTypeStr);
|
||||
if (snapshotType == null) {
|
||||
throw new InvalidParameterValueException("Unsupported snapshot type " + snapshotTypeStr);
|
||||
}
|
||||
@ -624,7 +623,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
sc.setParameters("snapshotTypeEQ", snapshotType.ordinal());
|
||||
}
|
||||
} else if (intervalTypeStr != null && volumeId != null) {
|
||||
Type type = SnapshotVO.getSnapshotType((String) intervalTypeStr);
|
||||
Type type = SnapshotVO.getSnapshotType(intervalTypeStr);
|
||||
if (type == null) {
|
||||
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.
|
||||
continue;
|
||||
}
|
||||
List<DataStore> ssHosts = this.dataStoreMgr.getImageStoresByScope(new ZoneScope(dcId));
|
||||
List<DataStore> ssHosts = dataStoreMgr.getImageStoresByScope(new ZoneScope(dcId));
|
||||
for (DataStore ssHost : ssHosts) {
|
||||
String snapshotDir = TemplateConstants.DEFAULT_SNAPSHOT_ROOT_DIR + "/" + accountId + "/" + volumeId;
|
||||
DeleteSnapshotsDirCommand cmd = new DeleteSnapshotsDirCommand(ssHost.getTO(), snapshotDir);
|
||||
@ -977,7 +976,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
CreateSnapshotPayload payload = (CreateSnapshotPayload)volume.getpayload();
|
||||
Long snapshotId = payload.getSnapshotId();
|
||||
Account snapshotOwner = payload.getAccount();
|
||||
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, volume.getDataStore());
|
||||
SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, volume.getDataStore());
|
||||
boolean processed = false;
|
||||
|
||||
try {
|
||||
@ -1019,7 +1018,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
|
||||
String value = _configDao.getValue(Config.BackupSnapshotWait.toString());
|
||||
_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.DAILY.setMax(NumbersUtil.parseInt(_configDao.getValue("snapshot.max.daily"), DAILYMAX));
|
||||
@ -1104,7 +1103,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
@Override
|
||||
public Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
VolumeInfo volume = this.volFactory.getVolume(volumeId);
|
||||
VolumeInfo volume = volFactory.getVolume(volumeId);
|
||||
supportedByHypervisor(volume);
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
if(vmInstance.getState().equals(State.Stopped)){
|
||||
if (vmInstance.getState().equals(State.Stopped)) {
|
||||
upgradeStoppedVirtualMachine(vmId, newServiceOfferingId);
|
||||
return true;
|
||||
}
|
||||
@ -1173,7 +1173,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
||||
|
||||
// Dynamically upgrade the running vms
|
||||
boolean success = false;
|
||||
if(vmInstance.getState().equals(State.Running)){
|
||||
if (vmInstance.getState().equals(State.Running)) {
|
||||
int retry = _scaleRetry;
|
||||
ExcludeList excludes = new ExcludeList();
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long convertToId(String vmName) {
|
||||
if (!VirtualMachineName.isValidVmName(vmName, _instance)) {
|
||||
return null;
|
||||
}
|
||||
return VirtualMachineName.getVmId(vmName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
|
||||
try {
|
||||
@ -3096,24 +3088,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
||||
public void finalizeExpunge(UserVmVO vm) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVmVO persist(UserVmVO vm) {
|
||||
return _vmDao.persist(vm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVmVO findById(long id) {
|
||||
return _vmDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVmVO findByName(String name) {
|
||||
if (!VirtualMachineName.isValidVmName(name)) {
|
||||
return null;
|
||||
}
|
||||
return findById(VirtualMachineName.getVmId(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VM_STOP, eventDescription = "stopping Vm", async = true)
|
||||
public UserVm stopVirtualMachine(long vmId, boolean forced)
|
||||
@ -3854,11 +3833,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
||||
}
|
||||
|
||||
// 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) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Cannot migrate VM, destination host is not in correct state, has status: "
|
||||
+ destinationHost.getStatus() + ", state: "
|
||||
+ destinationHost.getState() + ", state: "
|
||||
+ destinationHost.getResourceState());
|
||||
}
|
||||
|
||||
@ -3982,10 +3961,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
||||
}
|
||||
|
||||
// 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){
|
||||
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());
|
||||
|
||||
@ -26,17 +26,8 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
*
|
||||
*/
|
||||
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 persist(T vm);
|
||||
|
||||
boolean finalizeVirtualMachineProfile(VirtualMachineProfile<T> profile, DeployDestination dest, ReservationContext context);
|
||||
|
||||
/**
|
||||
@ -63,16 +54,6 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
|
||||
|
||||
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
|
||||
* @param profile
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
// 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,
|
||||
@ -20,13 +20,13 @@ import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlanner;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
|
||||
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.deploy.DeploymentPlanner;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
@ -55,7 +55,7 @@ import com.cloud.utils.fsm.NoTransitionException;
|
||||
*/
|
||||
public interface VirtualMachineManager extends Manager {
|
||||
|
||||
<T extends VMInstanceVO> T allocate(T vm,
|
||||
void allocate(String vmInstanceName,
|
||||
VMTemplateVO template,
|
||||
ServiceOfferingVO serviceOffering,
|
||||
Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
|
||||
@ -63,26 +63,14 @@ public interface VirtualMachineManager extends Manager {
|
||||
List<Pair<NetworkVO, NicProfile>> networks,
|
||||
Map<VirtualMachineProfile.Param, Object> params,
|
||||
DeploymentPlan plan,
|
||||
HypervisorType hyperType,
|
||||
Account owner) throws InsufficientCapacityException;
|
||||
HypervisorType hyperType) throws InsufficientCapacityException;
|
||||
|
||||
<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;
|
||||
|
||||
<T extends VMInstanceVO> T allocate(T vm,
|
||||
void allocate(String vmInstanceName,
|
||||
VMTemplateVO template,
|
||||
ServiceOfferingVO serviceOffering,
|
||||
List<Pair<NetworkVO, NicProfile>> networkProfiles,
|
||||
DeploymentPlan plan,
|
||||
HypervisorType hyperType,
|
||||
Account owner) throws InsufficientCapacityException;
|
||||
HypervisorType hyperType) throws InsufficientCapacityException;
|
||||
|
||||
<T extends VMInstanceVO> T start(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
@ -155,15 +143,15 @@ public interface VirtualMachineManager extends Manager {
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws InsufficientCapacityException
|
||||
*/
|
||||
NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile requested) throws ConcurrentOperationException,
|
||||
NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile requested) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* @param vm
|
||||
* @param nic
|
||||
* @return
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
boolean removeNicFromVm(VirtualMachine vm, NicVO nic) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
@ -172,8 +160,8 @@ public interface VirtualMachineManager extends Manager {
|
||||
* @param network
|
||||
* @param broadcastUri TODO
|
||||
* @return
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
boolean removeVmFromNetwork(VirtualMachine vm, Network network, URI broadcastUri) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
|
||||
@ -36,13 +36,6 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
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.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
||||
@ -93,6 +86,7 @@ import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dao.EntityManager;
|
||||
import com.cloud.dc.ClusterDetailsDao;
|
||||
import com.cloud.dc.ClusterDetailsVO;
|
||||
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.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
@ -135,8 +130,12 @@ import com.cloud.hypervisor.HypervisorGuruManager;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
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.NetworkVO;
|
||||
import com.cloud.network.element.DhcpServiceProvider;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
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.State;
|
||||
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.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
@ -280,6 +281,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
protected VlanDao _vlanDao;
|
||||
@Inject
|
||||
protected NicIpAliasDao _nicIpAliasDao;
|
||||
@Inject
|
||||
protected EntityManager _entityMgr;
|
||||
|
||||
protected List<DeploymentPlanner> _planners;
|
||||
public List<DeploymentPlanner> getPlanners() {
|
||||
@ -345,14 +348,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
|
||||
@Override
|
||||
@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,
|
||||
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()) {
|
||||
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());
|
||||
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";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineGuru<T> guru = (VirtualMachineGuru<T>) _vmGurus.get(vm.getType());
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
vm = guru.persist(vm);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Allocating nics for " + vm);
|
||||
@ -401,24 +404,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Allocation completed for VM: " + vm);
|
||||
}
|
||||
|
||||
return vm;
|
||||
}
|
||||
|
||||
@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 {
|
||||
List<Pair<DiskOfferingVO, Long>> diskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(1);
|
||||
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);
|
||||
public void allocate(String vmInstanceName, VMTemplateVO template, ServiceOfferingVO serviceOffering, List<Pair<NetworkVO, NicProfile>> networks, DeploymentPlan plan,
|
||||
HypervisorType hyperType) throws InsufficientCapacityException {
|
||||
allocate(vmInstanceName, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, null), null, networks, null, plan, hyperType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -2055,14 +2046,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
}
|
||||
|
||||
VMInstanceVO castedVm = 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());
|
||||
Command command = compareState(hostId, castedVm, info, true, hvGuru.trackVmHostChange());
|
||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
||||
Command command = compareState(hostId, vm, info, true, hvGuru.trackVmHostChange());
|
||||
if (command != null) {
|
||||
commands.addCommand(command);
|
||||
}
|
||||
@ -2070,21 +2059,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
|
||||
for (final AgentVmInfo left : infos.values()) {
|
||||
boolean found = false;
|
||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : _vmGurus.values()) {
|
||||
VMInstanceVO vm = vmGuru.findByName(left.name);
|
||||
if (vm != null) {
|
||||
found = true;
|
||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
||||
if(hvGuru.trackVmHostChange()) {
|
||||
Command command = compareState(hostId, vm, left, true, true);
|
||||
if (command != null) {
|
||||
commands.addCommand(command);
|
||||
}
|
||||
} else {
|
||||
s_logger.warn("Stopping a VM, VM " + left.name + " migrate from Host " + vm.getHostId() + " to Host " + hostId );
|
||||
commands.addCommand(cleanup(left.name));
|
||||
VMInstanceVO vm = _vmDao.findVMByInstanceName(left.name);
|
||||
if (vm != null) {
|
||||
found = true;
|
||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
||||
if (hvGuru.trackVmHostChange()) {
|
||||
Command command = compareState(hostId, vm, left, true, true);
|
||||
if (command != null) {
|
||||
commands.addCommand(command);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
s_logger.warn("Stopping a VM, VM " + left.name + " migrate from Host " + vm.getHostId() + " to Host " + hostId);
|
||||
commands.addCommand(cleanup(left.name));
|
||||
}
|
||||
}
|
||||
if ( ! found ) {
|
||||
@ -2171,7 +2157,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
|
||||
for (VMInstanceVO vm : set_vms) {
|
||||
AgentVmInfo info = infos.remove(vm.getId());
|
||||
VMInstanceVO castedVm = null;
|
||||
|
||||
// sync VM Snapshots related transient states
|
||||
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 ))
|
||||
|| (info != null && (info.state == 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)))
|
||||
{
|
||||
s_logger.info("Found vm " + vm.getInstanceName() + " in inconsistent state. " + vm.getState() + " on CS while " + (info == null ? "Stopped" : "Running") + " on agent");
|
||||
info = new AgentVmInfo(vm.getInstanceName(), getVmGuru(vm), vm, State.Stopped);
|
||||
s_logger.info("Found vm " + vm.getInstanceName() + " in inconsistent state. " + vm.getState() + " on CS while " + (info == null ? "Stopped" : "Running")
|
||||
+ " 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
|
||||
ItWorkVO work = _workDao.findByOutstandingWork(vm.getId(), vm.getState());
|
||||
@ -2215,12 +2201,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
_workDao.update(work.getId(), work);
|
||||
}
|
||||
|
||||
castedVm = info.guru.findById(vm.getId());
|
||||
try {
|
||||
Host host = _hostDao.findByGuid(info.getHostUuid());
|
||||
long hostId = host == null ? (vm.getHostId() == null ? vm.getLastHostId() : vm.getHostId()) : host.getId();
|
||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(castedVm.getHypervisorType());
|
||||
Command command = compareState(hostId, castedVm, info, true, hvGuru.trackVmHostChange());
|
||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
||||
Command command = compareState(hostId, vm, info, true, hvGuru.trackVmHostChange());
|
||||
if (command != null){
|
||||
Answer answer = _agentMgr.send(hostId, command);
|
||||
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
|
||||
|| 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());
|
||||
if (host != null){
|
||||
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
|
||||
// host id can change
|
||||
if (info != null && vm.getState() == State.Running){
|
||||
if (info != null && vm.getState() == State.Running) {
|
||||
// check for host id changes
|
||||
Host host = _hostDao.findByGuid(info.getHostUuid());
|
||||
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;
|
||||
for (Map.Entry<String, Pair<String, State>> entry : newStates.entrySet()) {
|
||||
is_alien_vm = true;
|
||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : vmGurus) {
|
||||
String name = entry.getKey();
|
||||
VMInstanceVO vm = vmGuru.findByName(name);
|
||||
if (vm != null) {
|
||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vmGuru, vm, entry.getValue().second(), entry.getValue().first()));
|
||||
is_alien_vm = false;
|
||||
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;
|
||||
}
|
||||
String name = entry.getKey();
|
||||
VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
|
||||
if (vm != null) {
|
||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first()));
|
||||
is_alien_vm = false;
|
||||
break;
|
||||
}
|
||||
// alien VMs
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -2336,21 +2313,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
if (states == null) {
|
||||
return map;
|
||||
}
|
||||
Collection<VirtualMachineGuru<? extends VMInstanceVO>> vmGurus = _vmGurus.values();
|
||||
|
||||
for (Map.Entry<String, VmState> entry : states.entrySet()) {
|
||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : vmGurus) {
|
||||
String name = entry.getKey();
|
||||
VMInstanceVO vm = vmGuru.findByName(name);
|
||||
if (vm != null) {
|
||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vmGuru, 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;
|
||||
}
|
||||
String name = entry.getKey();
|
||||
VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
|
||||
if (vm != null) {
|
||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().getState(), entry.getValue().getHost()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2364,24 +2332,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
return map;
|
||||
}
|
||||
|
||||
Collection<VirtualMachineGuru<? extends VMInstanceVO>> vmGurus = _vmGurus.values();
|
||||
|
||||
for (Map.Entry<String, State> entry : states.entrySet()) {
|
||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : vmGurus) {
|
||||
String name = entry.getKey();
|
||||
|
||||
VMInstanceVO vm = vmGuru.findByName(name);
|
||||
|
||||
if (vm != null) {
|
||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vmGuru, vm, entry.getValue()));
|
||||
break;
|
||||
}
|
||||
|
||||
Long id = vmGuru.convertToId(name);
|
||||
if (id != null) {
|
||||
map.put(id, new AgentVmInfo(entry.getKey(), vmGuru, null,entry.getValue()));
|
||||
break;
|
||||
}
|
||||
String name = entry.getKey();
|
||||
VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
|
||||
if (vm != null) {
|
||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2792,19 +2747,17 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
public State state;
|
||||
public String hostUuid;
|
||||
public VMInstanceVO vm;
|
||||
public VirtualMachineGuru<VMInstanceVO> guru;
|
||||
|
||||
@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.state = state;
|
||||
this.vm = vm;
|
||||
this.guru = (VirtualMachineGuru<VMInstanceVO>) guru;
|
||||
hostUuid = host;
|
||||
}
|
||||
|
||||
public AgentVmInfo(String name, VirtualMachineGuru<? extends VMInstanceVO> guru, VMInstanceVO vm, State state) {
|
||||
this(name, guru, vm, state, null);
|
||||
public AgentVmInfo(String name, VMInstanceVO vm, State state) {
|
||||
this(name, vm, state, null);
|
||||
}
|
||||
|
||||
public String getHostUuid() {
|
||||
@ -2825,7 +2778,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
// 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());
|
||||
throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " " + " in state " + vmInstance.getState()
|
||||
+ "; 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;
|
||||
|
||||
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.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.ScaleVmCommand;
|
||||
import com.cloud.capacity.CapacityManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
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.DataCenterDao;
|
||||
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.ManagementServerException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
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.HypervisorGuruManager;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
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.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
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.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.vm.dao.VMInstanceDao;
|
||||
import com.cloud.vm.snapshot.VMSnapshotManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
|
||||
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;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import com.cloud.vm.snapshot.VMSnapshotManager;
|
||||
|
||||
public class VirtualMachineManagerImplTest {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user