Search in sources :

Example 91 with StoragePool

use of com.cloud.storage.StoragePool in project cosmic by MissionCriticalCloud.

the class VirtualMachineManagerImpl method orchestrateStorageMigration.

@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateStorageMigration(final VmWorkStorageMigration work) throws Exception {
    final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId());
    if (vm == null) {
        s_logger.info("Unable to find vm " + work.getVmId());
    }
    assert vm != null;
    final StoragePool pool = (PrimaryDataStoreInfo) dataStoreMgr.getPrimaryDataStore(work.getDestStoragePoolId());
    orchestrateStorageMigration(vm.getUuid(), pool);
    return new Pair<>(JobInfo.Status.SUCCEEDED, null);
}
Also used : PrimaryDataStoreInfo(com.cloud.engine.subsystem.api.storage.PrimaryDataStoreInfo) StoragePool(com.cloud.storage.StoragePool) Pair(com.cloud.utils.Pair) ReflectionUse(com.cloud.utils.ReflectionUse)

Example 92 with StoragePool

use of com.cloud.storage.StoragePool in project cosmic by MissionCriticalCloud.

the class VMEntityManagerImpl method reserveVirtualMachine.

@Override
public String reserveVirtualMachine(final VMEntityVO vmEntityVO, final DeploymentPlanner plannerToUse, final DeploymentPlan planToDeploy, final 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
    final VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
    final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm);
    vmProfile.setServiceOffering(_serviceOfferingDao.findByIdIncludingRemoved(vm.getId(), vm.getServiceOfferingId()));
    DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodIdToDeployIn(), null, null, null, null);
    if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
        plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), planToDeploy.getPoolId(), planToDeploy.getPhysicalNetworkId());
    }
    boolean planChangedByReadyVolume = false;
    final List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
    if (!vols.isEmpty()) {
        final VolumeVO vol = vols.get(0);
        final StoragePool pool = (StoragePool) dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
        if (!pool.isInMaintenance()) {
            final long rootVolDcId = pool.getDataCenterId();
            final Long rootVolPodId = pool.getPodId();
            final Long rootVolClusterId = pool.getClusterId();
            if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
                final Long clusterIdSpecified = planToDeploy.getClusterId();
                if (clusterIdSpecified != null && rootVolClusterId != null) {
                    checkIfPlanIsDeployable(vm, rootVolClusterId, 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);
                planChangedByReadyVolume = true;
            }
        }
    }
    while (true) {
        DeployDestination dest = null;
        try {
            dest = _dpMgr.planDeployment(vmProfile, plan, exclude, plannerToUse);
        } catch (final AffinityConflictException e) {
            throw new CloudRuntimeException("Unable to create deployment, affinity rules associated to the VM conflict");
        }
        if (dest != null) {
            final String reservationId = _dpMgr.finalizeReservation(dest, vmProfile, plan, exclude, plannerToUse);
            if (reservationId != null) {
                return reservationId;
            } else {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Cannot finalize the VM reservation for this destination found, retrying");
                }
                exclude.addHost(dest.getHost().getId());
                continue;
            }
        } else if (planChangedByReadyVolume) {
            // call retry it.
            return UUID.randomUUID().toString();
        } else {
            throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId(), areAffinityGroupsAssociated(vmProfile));
        }
    }
}
Also used : DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) StoragePool(com.cloud.storage.StoragePool) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) VMInstanceVO(com.cloud.vm.VMInstanceVO) InsufficientServerCapacityException(com.cloud.exception.InsufficientServerCapacityException) AffinityConflictException(com.cloud.exception.AffinityConflictException) DataCenter(com.cloud.dc.DataCenter) VolumeVO(com.cloud.storage.VolumeVO) DeployDestination(com.cloud.deploy.DeployDestination) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 93 with StoragePool

use of com.cloud.storage.StoragePool in project cosmic by MissionCriticalCloud.

the class AbstractStoragePoolAllocator method reorderPoolsByNumberOfVolumes.

protected List<StoragePool> reorderPoolsByNumberOfVolumes(final DeploymentPlan plan, final List<StoragePool> pools, final Account account) {
    if (account == null) {
        return pools;
    }
    final long dcId = plan.getDataCenterId();
    final Long podId = plan.getPodId();
    final Long clusterId = plan.getClusterId();
    final List<Long> poolIdsByVolCount = _volumeDao.listPoolIdsByVolumeCount(dcId, podId, clusterId, account.getAccountId());
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("List of pools in ascending order of number of volumes for account id: " + account.getAccountId() + " is: " + poolIdsByVolCount);
    }
    // now filter the given list of Pools by this ordered list
    final Map<Long, StoragePool> poolMap = new HashMap<>();
    for (final StoragePool pool : pools) {
        poolMap.put(pool.getId(), pool);
    }
    final List<Long> matchingPoolIds = new ArrayList<>(poolMap.keySet());
    poolIdsByVolCount.retainAll(matchingPoolIds);
    final List<StoragePool> reorderedPools = new ArrayList<>();
    for (final Long id : poolIdsByVolCount) {
        reorderedPools.add(poolMap.get(id));
    }
    return reorderedPools;
}
Also used : StoragePool(com.cloud.storage.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 94 with StoragePool

use of com.cloud.storage.StoragePool in project cosmic by MissionCriticalCloud.

the class AbstractStoragePoolAllocator method reorderPoolsByCapacity.

protected List<StoragePool> reorderPoolsByCapacity(final DeploymentPlan plan, final List<StoragePool> pools) {
    final Long clusterId = plan.getClusterId();
    final short capacityType;
    if (pools != null && pools.size() != 0) {
        capacityType = pools.get(0).getPoolType().isShared() == true ? Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED : Capacity.CAPACITY_TYPE_LOCAL_STORAGE;
    } else {
        return null;
    }
    final List<Long> poolIdsByCapacity = _capacityDao.orderHostsByFreeCapacity(clusterId, capacityType);
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("List of pools in descending order of free capacity: " + poolIdsByCapacity);
    }
    // now filter the given list of Pools by this ordered list
    final Map<Long, StoragePool> poolMap = new HashMap<>();
    for (final StoragePool pool : pools) {
        poolMap.put(pool.getId(), pool);
    }
    final List<Long> matchingPoolIds = new ArrayList<>(poolMap.keySet());
    poolIdsByCapacity.retainAll(matchingPoolIds);
    final List<StoragePool> reorderedPools = new ArrayList<>();
    for (final Long id : poolIdsByCapacity) {
        reorderedPools.add(poolMap.get(id));
    }
    return reorderedPools;
}
Also used : StoragePool(com.cloud.storage.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 95 with StoragePool

use of com.cloud.storage.StoragePool in project cosmic by MissionCriticalCloud.

the class ZoneWideStoragePoolAllocator method reorderPoolsByNumberOfVolumes.

@Override
protected List<StoragePool> reorderPoolsByNumberOfVolumes(final DeploymentPlan plan, final List<StoragePool> pools, final Account account) {
    if (account == null) {
        return pools;
    }
    final long dcId = plan.getDataCenterId();
    final List<Long> poolIdsByVolCount = _volumeDao.listZoneWidePoolIdsByVolumeCount(dcId, account.getAccountId());
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("List of pools in ascending order of number of volumes for account id: " + account.getAccountId() + " is: " + poolIdsByVolCount);
    }
    // now filter the given list of Pools by this ordered list
    final Map<Long, StoragePool> poolMap = new HashMap<>();
    for (final StoragePool pool : pools) {
        poolMap.put(pool.getId(), pool);
    }
    final List<Long> matchingPoolIds = new ArrayList<>(poolMap.keySet());
    poolIdsByVolCount.retainAll(matchingPoolIds);
    final List<StoragePool> reorderedPools = new ArrayList<>();
    for (final Long id : poolIdsByVolCount) {
        reorderedPools.add(poolMap.get(id));
    }
    return reorderedPools;
}
Also used : StoragePool(com.cloud.storage.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Aggregations

StoragePool (com.cloud.storage.StoragePool)234 Answer (com.cloud.agent.api.Answer)81 Test (org.junit.Test)70 ArrayList (java.util.ArrayList)69 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)63 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)56 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)56 Volume (com.cloud.storage.Volume)55 HashMap (java.util.HashMap)47 VolumeVO (com.cloud.storage.VolumeVO)37 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)36 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)35 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)29 DiskProfile (com.cloud.vm.DiskProfile)29 UnsupportedAnswer (com.cloud.agent.api.UnsupportedAnswer)28 NfsStoragePool (com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool)28 NfsStoragePool (com.cloud.hypervisor.kvm.resource.KvmHaBase.NfsStoragePool)28 KVMStoragePool (com.cloud.hypervisor.kvm.storage.KVMStoragePool)28 KvmStoragePool (com.cloud.hypervisor.kvm.storage.KvmStoragePool)28 AttachAnswer (com.cloud.storage.command.AttachAnswer)28