mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Deploy, Start, Stop, Destroy VM orchestration service changes
This commit is contained in:
parent
ee39ec82d3
commit
94e8090bf3
@ -284,7 +284,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
||||
|
||||
public long getServiceOfferingId();
|
||||
|
||||
public long getDiskOfferingId();
|
||||
public Long getDiskOfferingId();
|
||||
|
||||
Type getType();
|
||||
|
||||
|
||||
@ -78,8 +78,8 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
||||
long accountId,
|
||||
long serviceOfferingId,
|
||||
String userData,
|
||||
String name) {
|
||||
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, hypervisorType, guestOsId, domainId, accountId, haEnabled, limitCpuUse);
|
||||
String name, Long diskOfferingId) {
|
||||
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, hypervisorType, guestOsId, domainId, accountId, haEnabled, limitCpuUse, diskOfferingId);
|
||||
this.userData = userData;
|
||||
this.displayName = displayName;
|
||||
this.details = new HashMap<String, String>();
|
||||
|
||||
@ -155,6 +155,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
protected String uuid = UUID.randomUUID().toString();
|
||||
;
|
||||
|
||||
@Column(name="disk_offering_id")
|
||||
protected Long diskOfferingId;
|
||||
|
||||
public VMInstanceVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
@ -195,9 +198,10 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
long domainId,
|
||||
long accountId,
|
||||
boolean haEnabled,
|
||||
boolean limitResourceUse) {
|
||||
boolean limitResourceUse, Long diskOfferingId) {
|
||||
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
|
||||
this.limitCpuUse = limitResourceUse;
|
||||
this.diskOfferingId = diskOfferingId;
|
||||
}
|
||||
|
||||
protected VMInstanceVO() {
|
||||
@ -472,9 +476,8 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDiskOfferingId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
public Long getDiskOfferingId() {
|
||||
return diskOfferingId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -28,9 +28,15 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.CloudException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* VirtualMachineEntity represents a Virtual Machine in Cloud Orchestration
|
||||
@ -78,33 +84,33 @@ public interface VirtualMachineEntity extends CloudStackEntity {
|
||||
void delTag();
|
||||
|
||||
/**
|
||||
* Start the virtual machine with a given deploy destination
|
||||
* Start the virtual machine with a given deployment plan
|
||||
* @param plannerToUse the Deployment Planner that should be used
|
||||
* @param dest destination to which to deploy the machine
|
||||
* @param plan plan to which to deploy the machine
|
||||
* @param exclude list of areas to exclude
|
||||
* @return a reservation id
|
||||
*/
|
||||
String reserve(String plannerToUse, @BeanParam DeployDestination dest, ExcludeList exclude);
|
||||
String reserve(String plannerToUse, @BeanParam DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Migrate this VM to a certain destination.
|
||||
*
|
||||
* @param reservationId reservation id from reserve call.
|
||||
*/
|
||||
void migrateTo(String reservationId);
|
||||
void migrateTo(String reservationId, String caller);
|
||||
|
||||
/**
|
||||
* Deploy this virtual machine according to the reservation from before.
|
||||
* @param reservationId reservation id from reserve call.
|
||||
*
|
||||
*/
|
||||
void deploy(String reservationId);
|
||||
void deploy(String reservationId, String caller) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Stop the virtual machine
|
||||
*
|
||||
*/
|
||||
void stop();
|
||||
boolean stop(String caller) throws ResourceUnavailableException, CloudException;
|
||||
|
||||
/**
|
||||
* Cleans up after any botched starts. CloudStack Orchestration Platform
|
||||
@ -116,7 +122,7 @@ public interface VirtualMachineEntity extends CloudStackEntity {
|
||||
/**
|
||||
* Destroys the VM.
|
||||
*/
|
||||
void destroy();
|
||||
boolean destroy(String caller) throws AgentUnavailableException, CloudException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Duplicate this VM in the database so that it will start new
|
||||
|
||||
@ -20,6 +20,7 @@ package org.apache.cloudstack.engine.service.api;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.POST;
|
||||
@ -35,6 +36,7 @@ import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
||||
@Path("orchestration")
|
||||
@Produces({"application/json", "application/xml"})
|
||||
@ -70,7 +72,7 @@ public interface OrchestrationService {
|
||||
@QueryParam("disk-size") Long diskSize,
|
||||
@QueryParam("compute-tags") List<String> computeTags,
|
||||
@QueryParam("root-disk-tags") List<String> rootDiskTags,
|
||||
@QueryParam("networks") List<String> networks,
|
||||
@QueryParam("network-nic-map") Map<String, NicProfile> networkNicMap,
|
||||
@QueryParam("deploymentplan") DeploymentPlan plan
|
||||
) throws InsufficientCapacityException;
|
||||
|
||||
@ -89,7 +91,7 @@ public interface OrchestrationService {
|
||||
@QueryParam("disk-size") Long diskSize,
|
||||
@QueryParam("compute-tags") List<String> computeTags,
|
||||
@QueryParam("root-disk-tags") List<String> rootDiskTags,
|
||||
@QueryParam("networks") List<String> networks,
|
||||
@QueryParam("network-nic-map") Map<String, NicProfile> networkNicMap,
|
||||
@QueryParam("deploymentplan") DeploymentPlan plan
|
||||
) throws InsufficientCapacityException;
|
||||
|
||||
@ -107,4 +109,6 @@ public interface OrchestrationService {
|
||||
|
||||
@POST
|
||||
TemplateEntity registerTemplate(String name, URL path, String os, Hypervisor hypervisor);
|
||||
|
||||
VirtualMachineEntity getVirtualMachine(@QueryParam("id") String id);
|
||||
}
|
||||
|
||||
@ -18,9 +18,25 @@ package org.apache.cloudstack.engine.cloud.entity.api;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
||||
public interface VMEntityManager {
|
||||
|
||||
VMEntityVO loadVirtualMachine(String vmId);
|
||||
|
||||
void saveVirtualMachine(VMEntityVO vmInstanceVO);
|
||||
|
||||
String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
void deployVirtualMachine(String reservationId, String caller) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException;
|
||||
|
||||
boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException;
|
||||
}
|
||||
|
||||
@ -16,12 +16,94 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.engine.cloud.entity.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDao;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.deploy.DeploymentPlanner;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Component
|
||||
public class VMEntityManagerImpl implements VMEntityManager {
|
||||
|
||||
@Inject
|
||||
protected VMInstanceDao _vmDao;
|
||||
@Inject
|
||||
protected VMTemplateDao _templateDao = null;
|
||||
|
||||
@Inject
|
||||
protected ServiceOfferingDao _serviceOfferingDao;
|
||||
|
||||
@Inject
|
||||
protected DiskOfferingDao _diskOfferingDao = null;
|
||||
|
||||
@Inject
|
||||
protected NetworkDao _networkDao;
|
||||
|
||||
@Inject
|
||||
protected AccountDao _accountDao = null;
|
||||
|
||||
@Inject
|
||||
protected UserDao _userDao = null;
|
||||
|
||||
@Inject
|
||||
protected VMEntityDao _vmEntityDao;
|
||||
|
||||
@Inject
|
||||
protected VMReservationDao _reservationDao;
|
||||
|
||||
@Inject
|
||||
protected VirtualMachineManager _itMgr;
|
||||
|
||||
@Inject
|
||||
protected List<DeploymentPlanner> _planners;
|
||||
|
||||
@Inject
|
||||
protected VolumeDao _volsDao;
|
||||
|
||||
@Inject
|
||||
protected StoragePoolDao _storagePoolDao;
|
||||
|
||||
@Override
|
||||
public VMEntityVO loadVirtualMachine(String vmId) {
|
||||
// TODO Auto-generated method stub
|
||||
@ -29,9 +111,114 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveVirtualMachine(VMEntityVO vmInstanceVO) {
|
||||
// TODO Auto-generated method stub
|
||||
public void saveVirtualMachine(VMEntityVO entity) {
|
||||
_vmEntityDao.persist(entity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan planToDeploy, ExcludeList exclude)
|
||||
throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
||||
//call planner and get the deployDestination.
|
||||
//load vm instance and offerings and call virtualMachineManagerImpl
|
||||
//FIXME: profile should work on VirtualMachineEntity
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
|
||||
VirtualMachineProfileImpl<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
|
||||
DeploymentPlan plan = planToDeploy;
|
||||
|
||||
List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
|
||||
if(!vols.isEmpty()){
|
||||
VolumeVO vol = vols.get(0);
|
||||
StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId());
|
||||
if (!pool.isInMaintenance()) {
|
||||
long rootVolDcId = pool.getDataCenterId();
|
||||
Long rootVolPodId = pool.getPodId();
|
||||
Long rootVolClusterId = pool.getClusterId();
|
||||
if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
|
||||
Long clusterIdSpecified = planToDeploy.getClusterId();
|
||||
if (clusterIdSpecified != null && rootVolClusterId != null) {
|
||||
if (rootVolClusterId.longValue() != clusterIdSpecified.longValue()) {
|
||||
// cannot satisfy the plan passed in to the
|
||||
// planner
|
||||
throw new ResourceUnavailableException("Root volume is ready in different cluster, Deployment plan provided cannot be satisfied, unable to create a deployment for "
|
||||
+ vm, Cluster.class, clusterIdSpecified);
|
||||
}
|
||||
}
|
||||
plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), vol.getPoolId(), null, null);
|
||||
}else{
|
||||
plan = new DataCenterDeployment(rootVolDcId, rootVolPodId, rootVolClusterId, null, vol.getPoolId(), null, null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DeploymentPlanner planner = ComponentContext.getCompanent(plannerToUse);
|
||||
DeployDestination dest = null;
|
||||
|
||||
if (planner.canHandle(vmProfile, plan, exclude)) {
|
||||
dest = planner.plan(vmProfile, plan, exclude);
|
||||
}
|
||||
|
||||
if (dest != null) {
|
||||
//save destination with VMEntityVO
|
||||
VMReservationVO vmReservation = new VMReservationVO(vm.getId(), dest.getDataCenter().getId(), dest.getPod().getId(), dest.getCluster().getId(), dest.getHost().getId());
|
||||
Map<Long,Long> volumeReservationMap = new HashMap<Long,Long>();
|
||||
for(Volume vo : dest.getStorageForDisks().keySet()){
|
||||
volumeReservationMap.put(vo.getId(), dest.getStorageForDisks().get(vo).getId());
|
||||
}
|
||||
vmReservation.setVolumeReservation(volumeReservationMap);
|
||||
|
||||
vmEntityVO.setVmReservation(vmReservation);
|
||||
_vmEntityDao.persist(vmEntityVO);
|
||||
|
||||
return vmReservation.getUuid();
|
||||
}else{
|
||||
throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deployVirtualMachine(String reservationId, String caller) throws InsufficientCapacityException, ResourceUnavailableException{
|
||||
//grab the VM Id and destination using the reservationId.
|
||||
|
||||
VMReservationVO vmReservation = _reservationDao.findByReservationId(reservationId);
|
||||
long vmId = vmReservation.getVmId();
|
||||
|
||||
VMInstanceVO vm = _vmDao.findById(vmId);
|
||||
//Pass it down
|
||||
Long poolId = null;
|
||||
Map<Long,Long> storage = vmReservation.getVolumeReservation();
|
||||
if(storage != null){
|
||||
Long[] array = new Long[storage.keySet().size()];
|
||||
storage.keySet().toArray(array);
|
||||
poolId = array[0];
|
||||
}
|
||||
|
||||
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterIdToDeployIn(), vmReservation.getPodId(), vmReservation.getClusterId(),
|
||||
vmReservation.getHostId(), poolId , null);
|
||||
|
||||
VMInstanceVO vmDeployed = _itMgr.start(vm, null, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), plan);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException {
|
||||
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
|
||||
return _itMgr.stop(vm, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException{
|
||||
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
|
||||
return _itMgr.destroy(vm, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -24,10 +24,17 @@ import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
||||
@Component
|
||||
public class VirtualMachineEntityImpl implements VirtualMachineEntity {
|
||||
|
||||
@Inject private VMEntityManager manager;
|
||||
@ -185,28 +192,25 @@ public class VirtualMachineEntityImpl implements VirtualMachineEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String reserve(String plannerToUse, DeployDestination dest,
|
||||
ExcludeList exclude) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public String reserve(String plannerToUse, DeploymentPlan plan,
|
||||
ExcludeList exclude, String caller) throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
return manager.reserveVirtualMachine(this.vmEntityVO, plannerToUse, plan, exclude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrateTo(String reservationId) {
|
||||
public void migrateTo(String reservationId, String caller) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deploy(String reservationId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void deploy(String reservationId, String caller) throws InsufficientCapacityException, ResourceUnavailableException{
|
||||
manager.deployVirtualMachine(reservationId, caller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public boolean stop(String caller) throws ResourceUnavailableException{
|
||||
return manager.stopvirtualmachine(this.vmEntityVO, caller);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,9 +220,8 @@ public class VirtualMachineEntityImpl implements VirtualMachineEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public boolean destroy(String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
return manager.destroyVirtualMachine(this.vmEntityVO, caller);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name = "vm_compute_tags")
|
||||
public class VMComputeTagVO implements InternalIdentity{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "vm_id")
|
||||
private long vmId;
|
||||
|
||||
@Column(name = "compute_tag")
|
||||
private String computeTag;
|
||||
|
||||
/**
|
||||
* There should never be a public constructor for this class. Since it's
|
||||
* only here to define the table for the DAO class.
|
||||
*/
|
||||
protected VMComputeTagVO() {
|
||||
}
|
||||
|
||||
public VMComputeTagVO(long vmId, String tag) {
|
||||
this.vmId = vmId;
|
||||
this.computeTag = tag;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public String getComputeTag() {
|
||||
return computeTag;
|
||||
}
|
||||
|
||||
}
|
||||
@ -182,6 +182,12 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
@Transient
|
||||
List<String> networkIds;
|
||||
|
||||
@Column(name="disk_offering_id")
|
||||
protected Long diskOfferingId;
|
||||
|
||||
@Transient
|
||||
private VMReservationVO vmReservation;
|
||||
|
||||
|
||||
public VMEntityVO(long id,
|
||||
long serviceOfferingId,
|
||||
@ -193,7 +199,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
long guestOSId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
boolean haEnabled) {
|
||||
boolean haEnabled, Long diskOfferingId) {
|
||||
this.id = id;
|
||||
this.hostName = name != null ? name : this.uuid;
|
||||
if (vmTemplateId != null) {
|
||||
@ -210,6 +216,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.limitCpuUse = false;
|
||||
this.diskOfferingId = diskOfferingId;
|
||||
}
|
||||
|
||||
public VMEntityVO(long id,
|
||||
@ -224,7 +231,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
long accountId,
|
||||
boolean haEnabled,
|
||||
boolean limitResourceUse) {
|
||||
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
|
||||
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled, null);
|
||||
this.limitCpuUse = limitResourceUse;
|
||||
}
|
||||
|
||||
@ -557,10 +564,17 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
this.networkIds = networkIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDiskOfferingId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
@Override
|
||||
public Long getDiskOfferingId() {
|
||||
return diskOfferingId;
|
||||
}
|
||||
|
||||
public VMReservationVO getVmReservation() {
|
||||
return vmReservation;
|
||||
}
|
||||
|
||||
public void setVmReservation(VMReservationVO vmReservation) {
|
||||
this.vmReservation = vmReservation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db;
|
||||
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "vm_network_map")
|
||||
public class VMNetworkMapVO implements InternalIdentity{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "vm_id")
|
||||
private long vmId;
|
||||
|
||||
@Column(name="network_id")
|
||||
private long networkId;
|
||||
|
||||
|
||||
/**
|
||||
* There should never be a public constructor for this class. Since it's
|
||||
* only here to define the table for the DAO class.
|
||||
*/
|
||||
protected VMNetworkMapVO() {
|
||||
}
|
||||
|
||||
public VMNetworkMapVO(long vmId, long networkId) {
|
||||
this.vmId = vmId;
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name = "vm_reservation")
|
||||
public class VMReservationVO implements Identity, InternalIdentity{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "vm_id")
|
||||
private long vmId;
|
||||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="data_center_id")
|
||||
private long dataCenterId;
|
||||
|
||||
@Column(name="pod_id")
|
||||
private long podId;
|
||||
|
||||
@Column(name="cluster_id")
|
||||
private long clusterId;
|
||||
|
||||
@Column(name="host_id")
|
||||
private long hostId;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
private Date created;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
// VolumeId -> poolId
|
||||
@Transient
|
||||
Map<Long,Long> volumeReservationMap;
|
||||
|
||||
/**
|
||||
* There should never be a public constructor for this class. Since it's
|
||||
* only here to define the table for the DAO class.
|
||||
*/
|
||||
protected VMReservationVO() {
|
||||
}
|
||||
|
||||
public VMReservationVO(long vmId, long dataCenterId, long podId, long clusterId, long hostId) {
|
||||
this.vmId = vmId;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.podId = podId;
|
||||
this.clusterId = clusterId;
|
||||
this.hostId = hostId;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public Long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public Map<Long,Long> getVolumeReservation(){
|
||||
return volumeReservationMap;
|
||||
}
|
||||
|
||||
public void setVolumeReservation(Map<Long,Long> volumeReservationMap){
|
||||
this.volumeReservationMap = volumeReservationMap;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name = "vm_root_disk_tags")
|
||||
public class VMRootDiskTagVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "vm_id")
|
||||
private long vmId;
|
||||
|
||||
@Column(name = "compute_tag")
|
||||
private String rootDiskTag;
|
||||
|
||||
/**
|
||||
* There should never be a public constructor for this class. Since it's
|
||||
* only here to define the table for the DAO class.
|
||||
*/
|
||||
protected VMRootDiskTagVO() {
|
||||
}
|
||||
|
||||
public VMRootDiskTagVO(long vmId, String rootDiskTag) {
|
||||
this.vmId = vmId;
|
||||
this.rootDiskTag = rootDiskTag;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public String getRootDiskTag() {
|
||||
return rootDiskTag;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name = "volume_reservation")
|
||||
public class VolumeReservationVO implements InternalIdentity{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "vm_reservation_id")
|
||||
private long vmReservationId;
|
||||
|
||||
@Column(name = "vm_id")
|
||||
private long vmId;
|
||||
|
||||
@Column(name="volume_id")
|
||||
private long volumeId;
|
||||
|
||||
@Column(name="pool_id")
|
||||
private long poolId;
|
||||
|
||||
// VolumeId -> poolId
|
||||
@Transient
|
||||
Map<String, String> volumeReservationMap;
|
||||
|
||||
/**
|
||||
* There should never be a public constructor for this class. Since it's
|
||||
* only here to define the table for the DAO class.
|
||||
*/
|
||||
protected VolumeReservationVO() {
|
||||
}
|
||||
|
||||
public VolumeReservationVO(long vmId, long volumeId, long poolId) {
|
||||
this.vmId = vmId;
|
||||
this.volumeId = volumeId;
|
||||
this.poolId = poolId;
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
public long geVmReservationId() {
|
||||
return vmReservationId;
|
||||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public Long getPoolId() {
|
||||
return poolId;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getVolumeReservation(){
|
||||
return volumeReservationMap;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMComputeTagVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface VMComputeTagDao extends GenericDao<VMComputeTagVO, Long>{
|
||||
|
||||
void persist(long vmId, List<String> computeTags);
|
||||
|
||||
List<String> getComputeTags(long vmId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMComputeTagVO;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Component
|
||||
@Local(value = { VMComputeTagDao.class })
|
||||
public class VMComputeTagDaoImpl extends GenericDaoBase<VMComputeTagVO, Long> implements VMComputeTagDao {
|
||||
|
||||
protected SearchBuilder<VMComputeTagVO> VmIdSearch;
|
||||
|
||||
public VMComputeTagDaoImpl() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
VmIdSearch = createSearchBuilder();
|
||||
VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
|
||||
VmIdSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void persist(long vmId, List<String> computeTags) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
txn.start();
|
||||
SearchCriteria<VMComputeTagVO> sc = VmIdSearch.create();
|
||||
sc.setParameters("vmId", vmId);
|
||||
expunge(sc);
|
||||
|
||||
for (String tag : computeTags) {
|
||||
tag = tag.trim();
|
||||
if(tag.length() > 0) {
|
||||
VMComputeTagVO vo = new VMComputeTagVO(vmId, tag);
|
||||
persist(vo);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComputeTags(long vmId) {
|
||||
|
||||
SearchCriteria<VMComputeTagVO> sc = VmIdSearch.create();
|
||||
sc.setParameters("vmId", vmId);
|
||||
|
||||
List<VMComputeTagVO> results = search(sc, null);
|
||||
List<String> computeTags = new ArrayList<String>(results.size());
|
||||
for (VMComputeTagVO result : results) {
|
||||
computeTags.add(result.getComputeTag());
|
||||
}
|
||||
|
||||
return computeTags;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
// 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 org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateDao;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
|
||||
|
||||
/*
|
||||
* Data Access Object for vm_instance table
|
||||
*/
|
||||
public interface VMEntityDao extends GenericDao<VMEntityVO, Long> {
|
||||
|
||||
void loadVmReservation(VMEntityVO vm);
|
||||
|
||||
}
|
||||
@ -0,0 +1,152 @@
|
||||
// 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 org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value = { VMEntityDao.class })
|
||||
public class VMEntityDaoImpl extends GenericDaoBase<VMEntityVO, Long> implements VMEntityDao {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(VMEntityDaoImpl.class);
|
||||
|
||||
|
||||
@Inject protected VMReservationDaoImpl _vmReservationDao;
|
||||
|
||||
@Inject protected VMComputeTagDaoImpl _vmComputeTagDao;
|
||||
|
||||
@Inject protected VMRootDiskTagDaoImpl _vmRootDiskTagsDao;
|
||||
|
||||
@Inject protected VMNetworkMapDaoImpl _vmNetworkMapDao;
|
||||
|
||||
|
||||
@Inject
|
||||
protected NetworkDao _networkDao;
|
||||
|
||||
public VMEntityDaoImpl() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
protected void init() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadVmReservation(VMEntityVO vm) {
|
||||
VMReservationVO vmReservation = _vmReservationDao.findByVmId(vm.getId());
|
||||
vm.setVmReservation(vmReservation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public VMEntityVO persist(VMEntityVO vm) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
VMEntityVO dbVO = super.persist(vm);
|
||||
|
||||
saveVmNetworks(vm);
|
||||
loadVmNetworks(dbVO);
|
||||
saveVmReservation(vm);
|
||||
loadVmReservation(dbVO);
|
||||
saveComputeTags(vm.getId(), vm.getComputeTags());
|
||||
loadComputeTags(dbVO);
|
||||
saveRootDiskTags(vm.getId(), vm.getRootDiskTags());
|
||||
loadRootDiskTags(dbVO);
|
||||
|
||||
txn.commit();
|
||||
|
||||
return dbVO;
|
||||
}
|
||||
|
||||
private void loadVmNetworks(VMEntityVO dbVO) {
|
||||
List<Long> networksIds = _vmNetworkMapDao.getNetworks(dbVO.getId());
|
||||
|
||||
List<String> networks = new ArrayList<String>();
|
||||
for(Long networkId : networksIds){
|
||||
NetworkVO network = _networkDao.findById(networkId);
|
||||
if(network != null){
|
||||
networks.add(network.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
dbVO.setNetworkIds(networks);
|
||||
|
||||
}
|
||||
|
||||
private void saveVmNetworks(VMEntityVO vm) {
|
||||
List<Long> networks = new ArrayList<Long>();
|
||||
|
||||
for(String uuid : vm.getNetworkIds()){
|
||||
NetworkVO network = _networkDao.findByUuid(uuid);
|
||||
if(network != null){
|
||||
networks.add(network.getId());
|
||||
}
|
||||
}
|
||||
_vmNetworkMapDao.persist(vm.getId(), networks);
|
||||
|
||||
}
|
||||
|
||||
private void loadRootDiskTags(VMEntityVO dbVO) {
|
||||
List<String> rootDiskTags = _vmRootDiskTagsDao.getRootDiskTags(dbVO.getId());
|
||||
dbVO.setRootDiskTags(rootDiskTags);
|
||||
|
||||
}
|
||||
|
||||
private void loadComputeTags(VMEntityVO dbVO) {
|
||||
List<String> computeTags = _vmComputeTagDao.getComputeTags(dbVO.getId());
|
||||
dbVO.setComputeTags(computeTags);
|
||||
|
||||
}
|
||||
|
||||
private void saveRootDiskTags(long vmId, List<String> rootDiskTags) {
|
||||
_vmRootDiskTagsDao.persist(vmId, rootDiskTags);
|
||||
|
||||
}
|
||||
|
||||
private void saveComputeTags(long vmId, List<String> computeTags) {
|
||||
_vmComputeTagDao.persist(vmId, computeTags);
|
||||
}
|
||||
|
||||
private void saveVmReservation(VMEntityVO vm) {
|
||||
_vmReservationDao.persist(vm.getVmReservation());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface VMNetworkMapDao extends GenericDao<VMNetworkMapVO, Long>{
|
||||
|
||||
void persist(long vmId, List<Long> networks);
|
||||
|
||||
List<Long> getNetworks(long vmId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMNetworkMapVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Component
|
||||
@Local(value = { VMNetworkMapDao.class })
|
||||
public class VMNetworkMapDaoImpl extends GenericDaoBase<VMNetworkMapVO, Long> implements VMNetworkMapDao {
|
||||
|
||||
protected SearchBuilder<VMNetworkMapVO> VmIdSearch;
|
||||
|
||||
@Inject
|
||||
protected NetworkDao _networkDao;
|
||||
|
||||
public VMNetworkMapDaoImpl() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
VmIdSearch = createSearchBuilder();
|
||||
VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
|
||||
VmIdSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void persist(long vmId, List<Long> networks) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
txn.start();
|
||||
SearchCriteria<VMNetworkMapVO> sc = VmIdSearch.create();
|
||||
sc.setParameters("vmId", vmId);
|
||||
expunge(sc);
|
||||
|
||||
for (Long networkId : networks) {
|
||||
VMNetworkMapVO vo = new VMNetworkMapVO(vmId, networkId);
|
||||
persist(vo);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getNetworks(long vmId) {
|
||||
|
||||
SearchCriteria<VMNetworkMapVO> sc = VmIdSearch.create();
|
||||
sc.setParameters("vmId", vmId);
|
||||
|
||||
List<VMNetworkMapVO> results = search(sc, null);
|
||||
List<Long> networks = new ArrayList<Long>(results.size());
|
||||
for (VMNetworkMapVO result : results) {
|
||||
networks.add(result.getNetworkId());
|
||||
}
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface VMReservationDao extends GenericDao<VMReservationVO, Long>{
|
||||
|
||||
VMReservationVO findByVmId(long vmId);
|
||||
|
||||
void loadVolumeReservation(VMReservationVO reservation);
|
||||
|
||||
VMReservationVO findByReservationId(String reservationId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.host.dao.HostTagsDaoImpl;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Component
|
||||
@Local(value = { VMReservationDao.class })
|
||||
public class VMReservationDaoImpl extends GenericDaoBase<VMReservationVO, Long> implements VMReservationDao {
|
||||
|
||||
protected SearchBuilder<VMReservationVO> VmIdSearch;
|
||||
|
||||
@Inject protected VolumeReservationDaoImpl _volumeReservationDao;
|
||||
|
||||
public VMReservationDaoImpl() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
VmIdSearch = createSearchBuilder();
|
||||
VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
|
||||
VmIdSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMReservationVO findByVmId(long vmId) {
|
||||
SearchCriteria<VMReservationVO> sc = VmIdSearch.create("vmId", vmId);
|
||||
VMReservationVO vmRes = findOneBy(sc);
|
||||
loadVolumeReservation(vmRes);
|
||||
return vmRes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void loadVolumeReservation(VMReservationVO reservation){
|
||||
List<VolumeReservationVO> volumeResList = _volumeReservationDao.listVolumeReservation(reservation.getId());
|
||||
Map<Long, Long> volumeReservationMap = new HashMap<Long,Long>();
|
||||
|
||||
for(VolumeReservationVO res : volumeResList){
|
||||
volumeReservationMap.put(res.getVolumeId(), res.getPoolId());
|
||||
}
|
||||
reservation.setVolumeReservation(volumeReservationMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public VMReservationVO persist(VMReservationVO reservation) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
VMReservationVO dbVO = super.persist(reservation);
|
||||
|
||||
saveVolumeReservation(reservation);
|
||||
loadVolumeReservation(dbVO);
|
||||
|
||||
txn.commit();
|
||||
|
||||
return dbVO;
|
||||
}
|
||||
|
||||
private void saveVolumeReservation(VMReservationVO reservation) {
|
||||
|
||||
for(Long volumeId : reservation.getVolumeReservation().keySet()){
|
||||
VolumeReservationVO volumeReservation = new VolumeReservationVO(reservation.getVmId(), volumeId, reservation.getVolumeReservation().get(volumeId));
|
||||
_volumeReservationDao.persist(volumeReservation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMReservationVO findByReservationId(String reservationId) {
|
||||
VMReservationVO vmRes = super.findByUuid(reservationId);
|
||||
loadVolumeReservation(vmRes);
|
||||
return vmRes;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMRootDiskTagVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface VMRootDiskTagDao extends GenericDao<VMRootDiskTagVO, Long>{
|
||||
|
||||
void persist(long vmId, List<String> diskTags);
|
||||
|
||||
List<String> getRootDiskTags(long vmId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMRootDiskTagVO;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Component
|
||||
@Local(value = { VMRootDiskTagDao.class })
|
||||
public class VMRootDiskTagDaoImpl extends GenericDaoBase<VMRootDiskTagVO, Long> implements VMRootDiskTagDao {
|
||||
|
||||
protected SearchBuilder<VMRootDiskTagVO> VmIdSearch;
|
||||
|
||||
public VMRootDiskTagDaoImpl() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
VmIdSearch = createSearchBuilder();
|
||||
VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
|
||||
VmIdSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void persist(long vmId, List<String> rootDiskTags) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
txn.start();
|
||||
SearchCriteria<VMRootDiskTagVO> sc = VmIdSearch.create();
|
||||
sc.setParameters("vmId", vmId);
|
||||
expunge(sc);
|
||||
|
||||
for (String tag : rootDiskTags) {
|
||||
tag = tag.trim();
|
||||
if(tag.length() > 0) {
|
||||
VMRootDiskTagVO vo = new VMRootDiskTagVO(vmId, tag);
|
||||
persist(vo);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getRootDiskTags(long vmId) {
|
||||
SearchCriteria<VMRootDiskTagVO> sc = VmIdSearch.create();
|
||||
sc.setParameters("vmId", vmId);
|
||||
|
||||
List<VMRootDiskTagVO> results = search(sc, null);
|
||||
List<String> computeTags = new ArrayList<String>(results.size());
|
||||
for (VMRootDiskTagVO result : results) {
|
||||
computeTags.add(result.getRootDiskTag());
|
||||
}
|
||||
return computeTags;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface VolumeReservationDao extends GenericDao<VolumeReservationVO, Long>{
|
||||
|
||||
VolumeReservationVO findByVmId(long vmId);
|
||||
|
||||
List<VolumeReservationVO> listVolumeReservation(long vmReservationId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package org.apache.cloudstack.engine.cloud.entity.api.db.dao;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VolumeReservationVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.host.dao.HostTagsDaoImpl;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Component
|
||||
@Local(value = { VolumeReservationDao.class })
|
||||
public class VolumeReservationDaoImpl extends GenericDaoBase<VolumeReservationVO, Long> implements VolumeReservationDao {
|
||||
|
||||
protected SearchBuilder<VolumeReservationVO> VmIdSearch;
|
||||
protected SearchBuilder<VolumeReservationVO> VmReservationIdSearch;
|
||||
|
||||
public VolumeReservationDaoImpl() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
VmIdSearch = createSearchBuilder();
|
||||
VmIdSearch.and("vmId", VmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
|
||||
VmIdSearch.done();
|
||||
|
||||
VmReservationIdSearch = createSearchBuilder();
|
||||
VmReservationIdSearch.and("vmReservationId", VmReservationIdSearch.entity().geVmReservationId(), SearchCriteria.Op.EQ);
|
||||
VmReservationIdSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeReservationVO findByVmId(long vmId) {
|
||||
SearchCriteria<VolumeReservationVO> sc = VmIdSearch.create("vmId", vmId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeReservationVO> listVolumeReservation(long vmReservationId) {
|
||||
SearchCriteria<VolumeReservationVO> sc = VmReservationIdSearch.create("vmReservationId", vmReservationId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
||||
|
||||
@Override
|
||||
public DataCenterVO loadDataCenter(String dataCenterId) {
|
||||
DataCenterVO dataCenterVO = _dataCenterDao.findByUUID(dataCenterId);
|
||||
DataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId);
|
||||
if(dataCenterVO == null){
|
||||
throw new InvalidParameterValueException("Zone does not exist");
|
||||
}
|
||||
@ -86,7 +86,7 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
||||
|
||||
@Override
|
||||
public HostPodVO loadPod(String uuid) {
|
||||
HostPodVO pod = _podDao.findByUUID(uuid);
|
||||
HostPodVO pod = _podDao.findByUuid(uuid);
|
||||
if(pod == null){
|
||||
throw new InvalidParameterValueException("Pod does not exist");
|
||||
}
|
||||
@ -95,7 +95,7 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
||||
|
||||
@Override
|
||||
public ClusterVO loadCluster(String uuid) {
|
||||
ClusterVO cluster = _clusterDao.findByUUID(uuid);
|
||||
ClusterVO cluster = _clusterDao.findByUuid(uuid);
|
||||
if(cluster == null){
|
||||
throw new InvalidParameterValueException("Pod does not exist");
|
||||
}
|
||||
@ -114,7 +114,7 @@ public class DataCenterResourceManagerImpl implements DataCenterResourceManager
|
||||
|
||||
@Override
|
||||
public HostVO loadHost(String uuid) {
|
||||
HostVO host = _hostDao.findByUUID(uuid);
|
||||
HostVO host = _hostDao.findByUuid(uuid);
|
||||
if(host == null){
|
||||
throw new InvalidParameterValueException("Host does not exist");
|
||||
}
|
||||
|
||||
@ -34,5 +34,4 @@ public interface ClusterDao extends GenericDao<ClusterVO, Long>, StateDao<DataCe
|
||||
Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds);
|
||||
List<Long> listDisabledClusters(long zoneId, Long podId);
|
||||
List<Long> listClustersWithDisabledPods(long zoneId);
|
||||
ClusterVO findByUUID(String uuid);
|
||||
}
|
||||
|
||||
@ -252,20 +252,12 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ClusterVO findByUUID(String uuid) {
|
||||
SearchCriteria<ClusterVO> sc = UUIDSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {
|
||||
|
||||
ClusterVO vo = findById(clusterEntity.getId());
|
||||
|
||||
Date oldUpdatedTime = vo.getLastUpdated();
|
||||
@Override
|
||||
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {
|
||||
|
||||
ClusterVO vo = findById(clusterEntity.getId());
|
||||
|
||||
Date oldUpdatedTime = vo.getLastUpdated();
|
||||
|
||||
SearchCriteria<ClusterVO> sc = StateChangeSearch.create();
|
||||
sc.setParameters("id", vo.getId());
|
||||
|
||||
@ -52,5 +52,4 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long>, StateDao<
|
||||
|
||||
List<DataCenterVO> findByKeyword(String keyword);
|
||||
|
||||
DataCenterVO findByUUID(String uuid);
|
||||
}
|
||||
|
||||
@ -75,13 +75,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataCenterVO findByUUID(String uuid) {
|
||||
SearchCriteria<DataCenterVO> sc = UUIDSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DataCenterVO findByToken(String zoneToken){
|
||||
SearchCriteria<DataCenterVO> sc = TokenSearch.create();
|
||||
|
||||
@ -82,6 +82,4 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<DataCenterRe
|
||||
* @return
|
||||
*/
|
||||
List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
|
||||
|
||||
HostVO findByUUID(String uuid);
|
||||
}
|
||||
|
||||
@ -725,94 +725,85 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> findHypervisorHostInCluster(long clusterId) {
|
||||
SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();
|
||||
sc.setParameters("type", Host.Type.Routing);
|
||||
sc.setParameters("cluster", clusterId);
|
||||
sc.setParameters("status", Status.Up);
|
||||
sc.setParameters("resourceState", ResourceState.Enabled);
|
||||
@Override
|
||||
public List<HostVO> findHypervisorHostInCluster(long clusterId) {
|
||||
SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();
|
||||
sc.setParameters("type", Host.Type.Routing);
|
||||
sc.setParameters("cluster", clusterId);
|
||||
sc.setParameters("status", Status.Up);
|
||||
sc.setParameters("resourceState", ResourceState.Enabled);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
@Override
|
||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> lockRows(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
Filter filter, boolean exclusive) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> lockRows(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
Filter filter, boolean exclusive) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO lockOneRandomRow(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
boolean exclusive) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO lockOneRandomRow(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
boolean exclusive) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> search(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
Filter filter) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> search(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
Filter filter) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> search(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
Filter filter, boolean enable_query_cache) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> search(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
Filter filter, boolean enable_query_cache) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> searchIncludingRemoved(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
Filter filter, Boolean lock, boolean cache) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> searchIncludingRemoved(
|
||||
SearchCriteria<org.apache.cloudstack.engine.datacenter.entity.api.db.HostVO> sc,
|
||||
Filter filter, Boolean lock, boolean cache) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> searchIncludingRemoved(
|
||||
SearchCriteria<HostVO> sc,
|
||||
Filter filter, Boolean lock, boolean cache,
|
||||
boolean enable_query_cache) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<HostVO> searchIncludingRemoved(
|
||||
SearchCriteria<HostVO> sc,
|
||||
Filter filter, Boolean lock, boolean cache,
|
||||
boolean enable_query_cache) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int remove(
|
||||
SearchCriteria<HostVO> sc) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int remove(
|
||||
SearchCriteria<HostVO> sc) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expunge(SearchCriteria<HostVO> sc) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int expunge(SearchCriteria<HostVO> sc) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostVO findOneBy(SearchCriteria<HostVO> sc) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public HostVO findByUUID(String uuid) {
|
||||
SearchCriteria<HostVO> sc = UUIDSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
@Override
|
||||
public HostVO findOneBy(SearchCriteria<HostVO> sc) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -30,7 +30,4 @@ public interface HostPodDao extends GenericDao<HostPodVO, Long>, StateDao<DataCe
|
||||
public HashMap<Long, List<Object>> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip);
|
||||
|
||||
public List<Long> listDisabledPods(long zoneId);
|
||||
|
||||
public HostPodVO findByUUID(String uuid);
|
||||
|
||||
}
|
||||
|
||||
@ -146,13 +146,7 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostPodVO findByUUID(String uuid) {
|
||||
SearchCriteria<HostPodVO> sc = UUIDSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity podEntity, Object data) {
|
||||
|
||||
|
||||
@ -40,12 +40,16 @@ 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.NetworkVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
@ -74,6 +78,13 @@ public class CloudOrchestrator implements OrchestrationService {
|
||||
|
||||
@Inject
|
||||
protected VirtualMachineEntityFactory _vmEntityFactory;
|
||||
|
||||
@Inject
|
||||
protected NetworkDao _networkDao;
|
||||
|
||||
@Inject
|
||||
protected AccountDao _accountDao = null;
|
||||
|
||||
|
||||
public VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String hypervisor, String hostName, int cpu, int speed, long memory, List<String> networks, List<String> computeTags,
|
||||
Map<String, String> details, String owner) {
|
||||
@ -143,28 +154,36 @@ public class CloudOrchestrator implements OrchestrationService {
|
||||
Long diskSize,
|
||||
List<String> computeTags,
|
||||
List<String> rootDiskTags,
|
||||
List<String> networks, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||
Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||
|
||||
// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
|
||||
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO, NicProfile>>();
|
||||
for (String uuid : networkNicMap.keySet()) {
|
||||
NetworkVO network = _networkDao.findByUuid(uuid);
|
||||
if(network != null){
|
||||
networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
|
||||
}
|
||||
}
|
||||
|
||||
VirtualMachineEntityImpl vmEntity = null;
|
||||
try {
|
||||
vmEntity = _vmEntityFactory.getObject();
|
||||
} catch (Exception e) {
|
||||
// add error handling here
|
||||
}
|
||||
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks);
|
||||
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, new ArrayList<String>(networkNicMap.keySet()));
|
||||
|
||||
|
||||
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
|
||||
|
||||
//load vm instance and offerings and call virtualMachineManagerImpl
|
||||
VMInstanceVO vm = _vmDao.findByUUID(id);
|
||||
VMInstanceVO vm = _vmDao.findByUuid(id);
|
||||
|
||||
// If the template represents an ISO, a disk offering must be passed in,
|
||||
// and will be used to create the root disk
|
||||
// Else, a disk offering is optional, and if present will be used to
|
||||
// create the data disk
|
||||
Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
|
||||
// If the template represents an ISO, a disk offering must be passed in, and will be used to create the root disk
|
||||
// Else, a disk offering is optional, and if present will be used to create the data disk
|
||||
|
||||
Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
|
||||
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>();
|
||||
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
|
||||
@ -172,8 +191,7 @@ public class CloudOrchestrator implements OrchestrationService {
|
||||
|
||||
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vm.getDiskOfferingId());
|
||||
if (diskOffering == null) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Unable to find disk offering " + vm.getDiskOfferingId());
|
||||
throw new InvalidParameterValueException("Unable to find disk offering " + vm.getDiskOfferingId());
|
||||
}
|
||||
Long size = null;
|
||||
if (diskOffering.getDiskSize() == 0) {
|
||||
@ -186,7 +204,8 @@ public class CloudOrchestrator implements OrchestrationService {
|
||||
}
|
||||
dataDiskOfferings.add(new Pair<DiskOfferingVO, Long>(diskOffering, size));
|
||||
|
||||
if (_itMgr.allocate(vm, _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, null, null, plan, hypervisorType, null) == null) {
|
||||
|
||||
if (_itMgr.allocate(vm, _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -195,7 +214,7 @@ public class CloudOrchestrator implements OrchestrationService {
|
||||
|
||||
@Override
|
||||
public VirtualMachineEntity createVirtualMachineFromScratch(String id, String owner, String isoId, String hostName, String displayName, String hypervisor, String os, int cpu, int speed, long memory,Long diskSize,
|
||||
List<String> computeTags, List<String> rootDiskTags, List<String> networks, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||
List<String> computeTags, List<String> rootDiskTags, Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||
|
||||
// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
|
||||
VirtualMachineEntityImpl vmEntity = null;
|
||||
@ -204,10 +223,10 @@ public class CloudOrchestrator implements OrchestrationService {
|
||||
} catch (Exception e) {
|
||||
// add error handling here
|
||||
}
|
||||
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks);
|
||||
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, new ArrayList<String>(networkNicMap.keySet()));
|
||||
|
||||
//load vm instance and offerings and call virtualMachineManagerImpl
|
||||
VMInstanceVO vm = _vmDao.findByUUID(id);
|
||||
VMInstanceVO vm = _vmDao.findByUuid(id);
|
||||
|
||||
|
||||
Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
|
||||
@ -251,4 +270,10 @@ public class CloudOrchestrator implements OrchestrationService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachineEntity getVirtualMachine(String id) {
|
||||
VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, vmEntityManager);
|
||||
return vmEntity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -734,31 +734,35 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
//If the plan specifies a poolId, it means that this VM's ROOT volume is ready and the pool should be reused.
|
||||
//In this case, also check if rest of the volumes are ready and can be reused.
|
||||
if(plan.getPoolId() != null){
|
||||
if (toBeCreated.getState() == Volume.State.Ready && toBeCreated.getPoolId() != null) {
|
||||
s_logger.debug("Volume is in READY state and has pool already allocated, checking if pool can be reused, poolId: "+toBeCreated.getPoolId());
|
||||
List<StoragePool> suitablePools = new ArrayList<StoragePool>();
|
||||
StoragePoolVO pool = _storagePoolDao.findById(toBeCreated.getPoolId());
|
||||
if(!pool.isInMaintenance()){
|
||||
if(!avoid.shouldAvoid(pool)){
|
||||
long exstPoolDcId = pool.getDataCenterId();
|
||||
s_logger.debug("Volume has pool already allocated, checking if pool can be reused, poolId: "+toBeCreated.getPoolId());
|
||||
List<StoragePool> suitablePools = new ArrayList<StoragePool>();
|
||||
StoragePoolVO pool;
|
||||
if(toBeCreated.getPoolId() != null){
|
||||
pool = _storagePoolDao.findById(toBeCreated.getPoolId());
|
||||
}else{
|
||||
pool = _storagePoolDao.findById(plan.getPoolId());
|
||||
}
|
||||
|
||||
if(!pool.isInMaintenance()){
|
||||
if(!avoid.shouldAvoid(pool)){
|
||||
long exstPoolDcId = pool.getDataCenterId();
|
||||
|
||||
long exstPoolPodId = pool.getPodId() != null ? pool.getPodId() : -1;
|
||||
long exstPoolClusterId = pool.getClusterId() != null ? pool.getClusterId() : -1;
|
||||
if(plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId){
|
||||
s_logger.debug("Planner need not allocate a pool for this volume since its READY");
|
||||
suitablePools.add(pool);
|
||||
suitableVolumeStoragePools.put(toBeCreated, suitablePools);
|
||||
readyAndReusedVolumes.add(toBeCreated);
|
||||
continue;
|
||||
}else{
|
||||
s_logger.debug("Pool of the volume does not fit the specified plan, need to reallocate a pool for this volume");
|
||||
}
|
||||
long exstPoolPodId = pool.getPodId() != null ? pool.getPodId() : -1;
|
||||
long exstPoolClusterId = pool.getClusterId() != null ? pool.getClusterId() : -1;
|
||||
if(plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId){
|
||||
s_logger.debug("Planner need not allocate a pool for this volume since its READY");
|
||||
suitablePools.add(pool);
|
||||
suitableVolumeStoragePools.put(toBeCreated, suitablePools);
|
||||
readyAndReusedVolumes.add(toBeCreated);
|
||||
continue;
|
||||
}else{
|
||||
s_logger.debug("Pool of the volume is in avoid set, need to reallocate a pool for this volume");
|
||||
s_logger.debug("Pool of the volume does not fit the specified plan, need to reallocate a pool for this volume");
|
||||
}
|
||||
}else{
|
||||
s_logger.debug("Pool of the volume is in maintenance, need to reallocate a pool for this volume");
|
||||
s_logger.debug("Pool of the volume is in avoid set, need to reallocate a pool for this volume");
|
||||
}
|
||||
}else{
|
||||
s_logger.debug("Pool of the volume is in maintenance, need to reallocate a pool for this volume");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ public class SecurityManagerMBeanImpl extends StandardMBean implements SecurityG
|
||||
@Override
|
||||
public void simulateVmStart(Long vmId) {
|
||||
//all we need is the vmId
|
||||
VMInstanceVO vm = new VMInstanceVO(vmId, 5, "foo", "foo", Type.User, null, HypervisorType.Any, 8, 1, 1, false, false);
|
||||
VMInstanceVO vm = new VMInstanceVO(vmId, 5, "foo", "foo", Type.User, null, HypervisorType.Any, 8, 1, 1, false, false,null);
|
||||
_sgMgr.handleVmStarted(vm);
|
||||
}
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
|
||||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
@ -97,12 +98,14 @@ import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.CloudException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
@ -542,10 +545,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
Account account = _accountDao.findById(user.getAccountId());
|
||||
|
||||
try {
|
||||
status = _itMgr.stop(vm, user, account);
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
|
||||
status = vmEntity.stop(new Long(userId).toString());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Unable to stop due to ", e);
|
||||
status = false;
|
||||
} catch (CloudException e) {
|
||||
throw new CloudRuntimeException(
|
||||
"Unable to contact the agent to stop the virtual machine "
|
||||
+ vm, e);
|
||||
}
|
||||
|
||||
if (status) {
|
||||
@ -2903,8 +2911,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>();
|
||||
|
||||
List<String> networkUuidList = new ArrayList<String>();
|
||||
|
||||
Map<String, NicProfile> networkNicMap = new HashMap<String, NicProfile>();
|
||||
|
||||
short defaultNetworkNumber = 0;
|
||||
boolean securityGroupEnabled = false;
|
||||
@ -2948,7 +2956,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
vpcNetwork = true;
|
||||
}
|
||||
|
||||
networkUuidList.add(network.getUuid());
|
||||
networkNicMap.put(network.getUuid(), profile);
|
||||
}
|
||||
|
||||
if (securityGroupIdList != null && !securityGroupIdList.isEmpty()
|
||||
@ -3030,7 +3038,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
template.getId(), hypervisorType, template.getGuestOSId(),
|
||||
offering.getOfferHA(), offering.getLimitCpuUse(),
|
||||
owner.getDomainId(), owner.getId(), offering.getId(), userData,
|
||||
hostName);
|
||||
hostName, diskOfferingId);
|
||||
vm.setUuid(uuidName);
|
||||
|
||||
if (sshPublicKey != null) {
|
||||
@ -3063,9 +3071,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
rootDiskTags.add(offering.getTags());
|
||||
|
||||
if(isIso){
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.createVirtualMachineFromScratch(vm.getUuid(), owner.getAccountName(), vm.getIsoId().toString(), hostName, displayName, hypervisor.name(), guestOSCategory.getName(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkUuidList, plan);
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.createVirtualMachineFromScratch(vm.getUuid(), new Long(owner.getAccountId()).toString(), vm.getIsoId().toString(), hostName, displayName, hypervisor.name(), guestOSCategory.getName(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkNicMap, plan);
|
||||
}else {
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.createVirtualMachine(vm.getUuid(), owner.getAccountName(), new Long(template.getId()).toString(), hostName, displayName, hypervisor.name(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkUuidList, plan);
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.createVirtualMachine(vm.getUuid(), new Long(owner.getAccountId()).toString(), new Long(template.getId()).toString(), hostName, displayName, hypervisor.name(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkNicMap, plan);
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -3377,12 +3385,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
UserVO user = _userDao.findById(userId);
|
||||
|
||||
try {
|
||||
_itMgr.advanceStop(vm, forced, user, caller);
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
|
||||
vmEntity.stop(new Long(userId).toString());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
throw new CloudRuntimeException(
|
||||
"Unable to contact the agent to stop the virtual machine "
|
||||
+ vm, e);
|
||||
} catch (OperationTimedoutException e) {
|
||||
} catch (CloudException e) {
|
||||
throw new CloudRuntimeException(
|
||||
"Unable to contact the agent to stop the virtual machine "
|
||||
+ vm, e);
|
||||
@ -3533,16 +3542,17 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
params.put(VirtualMachineProfile.Param.VmPassword, password);
|
||||
}
|
||||
|
||||
vm = _itMgr.start(vm, params, callerUser, callerAccount, plan);
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
|
||||
|
||||
String reservationId = vmEntity.reserve("FirstFitPlanner", plan, new ExcludeList(), new Long(callerUser.getId()).toString());
|
||||
vmEntity.deploy(reservationId, new Long(callerUser.getId()).toString());
|
||||
|
||||
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair = new Pair(
|
||||
vm, params);
|
||||
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair = new Pair(vm, params);
|
||||
if (vm != null && vm.isUpdateParameters()) {
|
||||
// this value is not being sent to the backend; need only for api
|
||||
// display purposes
|
||||
if (template.getEnablePassword()) {
|
||||
vm.setPassword((String) vmParamPair.second().get(
|
||||
VirtualMachineProfile.Param.VmPassword));
|
||||
vm.setPassword((String) vmParamPair.second().get(VirtualMachineProfile.Param.VmPassword));
|
||||
vm.setUpdateParameters(false);
|
||||
_vmDao.update(vm.getId(), vm);
|
||||
}
|
||||
@ -3579,8 +3589,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
State vmState = vm.getState();
|
||||
|
||||
try {
|
||||
status = _itMgr.destroy(vm, userCaller, caller);
|
||||
} catch (OperationTimedoutException e) {
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
|
||||
status = vmEntity.destroy(new Long(userId).toString());
|
||||
} catch (CloudException e) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException(
|
||||
"Unable to destroy with specified vmId", e);
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
@ -4503,4 +4514,5 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
@Override
|
||||
public void prepareStop(VirtualMachineProfile<UserVmVO> profile) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -114,7 +114,5 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
||||
* @return
|
||||
*/
|
||||
List<String> listDistinctHostNames(long networkId, VirtualMachine.Type... types);
|
||||
|
||||
VMInstanceVO findByUUID(String uuid);
|
||||
|
||||
}
|
||||
|
||||
@ -617,9 +617,4 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMInstanceVO findByUUID(String uuid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,3 +65,28 @@ CREATE TABLE `cloud`.`vm_network_map` (
|
||||
`network_id` bigint unsigned NOT NULL COMMENT 'network id',
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `cloud`.`vm_reservation` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`uuid` varchar(40) NOT NULL COMMENT 'reservation id',
|
||||
`vm_id` bigint unsigned NOT NULL COMMENT 'vm id',
|
||||
`datacenter_id` bigint unsigned NOT NULL COMMENT 'zone id',
|
||||
`pod_id` bigint unsigned NOT NULL COMMENT 'pod id',
|
||||
`cluster_id` bigint unsigned NOT NULL COMMENT 'cluster id',
|
||||
`host_id` bigint unsigned NOT NULL COMMENT 'host id',
|
||||
`created` datetime COMMENT 'date created',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
CONSTRAINT `uc_vm_reservation__uuid` UNIQUE (`uuid`),
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`volume_reservation` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`vm_reservation_id` bigint unsigned NOT NULL COMMENT 'id of the vm reservation',
|
||||
`vm_id` bigint unsigned NOT NULL COMMENT 'vm id',
|
||||
`volume_id` bigint unsigned NOT NULL COMMENT 'volume id',
|
||||
`pool_id` bigint unsigned NOT NULL COMMENT 'pool assigned to the volume',
|
||||
CONSTRAINT `fk_vm_pool_reservation__vm_reservation_id` FOREIGN KEY (`vm_reservation_id`) REFERENCES `vm_reservation`(`id`) ON DELETE CASCADE,
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user