Search in sources :

Example 6 with VMReservationVO

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;
}
Also used : VMReservationVO(com.cloud.engine.cloud.entity.api.db.VMReservationVO) TransactionLegacy(com.cloud.utils.db.TransactionLegacy) DB(com.cloud.utils.db.DB)

Example 7 with VMReservationVO

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;
}
Also used : VMReservationVO(com.cloud.engine.cloud.entity.api.db.VMReservationVO) AllocationState(com.cloud.model.enumeration.AllocationState) State(com.cloud.vm.VirtualMachine.State)

Example 8 with VMReservationVO

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;
}
Also used : VMReservationVO(com.cloud.engine.cloud.entity.api.db.VMReservationVO) VirtualMachine(com.cloud.vm.VirtualMachine)

Aggregations

VMReservationVO (com.cloud.engine.cloud.entity.api.db.VMReservationVO)8 DB (com.cloud.utils.db.DB)2 VirtualMachine (com.cloud.vm.VirtualMachine)2 AffinityGroupProcessor (com.cloud.affinity.AffinityGroupProcessor)1 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)1 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)1 AffinityConflictException (com.cloud.exception.AffinityConflictException)1 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InsufficientServerCapacityException (com.cloud.exception.InsufficientServerCapacityException)1 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 AllocationState (com.cloud.model.enumeration.AllocationState)1 Volume (com.cloud.storage.Volume)1 SearchCriteria (com.cloud.utils.db.SearchCriteria)1 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1 TransactionStatus (com.cloud.utils.db.TransactionStatus)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 VMInstanceVO (com.cloud.vm.VMInstanceVO)1