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);
}
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));
}
}
}
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;
}
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;
}
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;
}
Aggregations