use of com.cloud.engine.cloud.entity.api.db.VMReservationVO in project cosmic by MissionCriticalCloud.
the class VMReservationDaoImpl method persist.
@Override
@DB
public VMReservationVO persist(final VMReservationVO reservation) {
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
final VMReservationVO dbVO = super.persist(reservation);
saveVolumeReservation(reservation);
loadVolumeReservation(dbVO);
txn.commit();
return dbVO;
}
use of com.cloud.engine.cloud.entity.api.db.VMReservationVO in project cosmic by MissionCriticalCloud.
the class DeploymentPlanningManagerImpl method postStateTransitionEvent.
@Override
public boolean postStateTransitionEvent(final StateMachine2.Transition<State, Event> transition, final VirtualMachine vo, final boolean status, final Object opaque) {
if (!status) {
return false;
}
final State oldState = transition.getCurrentState();
final State newState = transition.getToState();
if ((oldState == State.Starting) && (newState != State.Starting)) {
// cleanup all VM reservation entries
final SearchCriteria<VMReservationVO> sc = _reservationDao.createSearchCriteria();
sc.addAnd("vmId", SearchCriteria.Op.EQ, vo.getId());
_reservationDao.expunge(sc);
}
return true;
}
use of com.cloud.engine.cloud.entity.api.db.VMReservationVO in project cosmic by MissionCriticalCloud.
the class HostAntiAffinityProcessor method check.
@Override
public boolean check(final VirtualMachineProfile vmProfile, final DeployDestination plannedDestination) throws AffinityConflictException {
if (plannedDestination.getHost() == null) {
return true;
}
final long plannedHostId = plannedDestination.getHost().getId();
final VirtualMachine vm = vmProfile.getVirtualMachine();
final List<AffinityGroupVMMapVO> vmGroupMappings = _affinityGroupVMMapDao.findByVmIdType(vm.getId(), getType());
for (final AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
// if more than 1 VM's are present in the group then check for
// conflict due to parallel deployment
final List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(vmGroupMapping.getAffinityGroupId());
groupVMIds.remove(vm.getId());
for (final Long groupVMId : groupVMIds) {
final VMReservationVO vmReservation = _reservationDao.findByVmId(groupVMId);
if (vmReservation != null && vmReservation.getHostId() != null && vmReservation.getHostId().equals(plannedHostId)) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Planned destination for VM " + vm.getId() + " conflicts with an existing VM " + vmReservation.getVmId() + " reserved on the same host " + plannedHostId);
}
return false;
}
}
}
return true;
}
Aggregations