@Override public Long getClusterId() { return pdsv.getClusterId(); }
private static boolean isStorageApplicableToZoneOrCluster(StoragePoolVO storagePoolVO, long clusterId, ClusterDao clusterDao) { if (storagePoolVO.getClusterId() != null) { if (storagePoolVO.getClusterId() == clusterId) { return true; } } else { List<ClusterVO> clustersInZone = clusterDao.listByZoneId(storagePoolVO.getDataCenterId()); if (clustersInZone != null) { for (ClusterVO clusterInZone : clustersInZone) { if (clusterInZone.getId() == clusterId) { return true; } } } } return false; }
/** * Return true if the VM migration is a cross cluster migration. To execute that, we check if the volume current storage pool cluster is different from the target host cluster. */ protected boolean isStorageCrossClusterMigration(Host targetHost, StoragePoolVO currentPool) { return ScopeType.CLUSTER.equals(currentPool.getScope()) && currentPool.getClusterId() != targetHost.getClusterId(); }
@Override public List<StoragePoolVO> ListByDataCenterHypervisor(long datacenterId, HypervisorType type) { List<StoragePoolVO> pools = _storagePoolDao.listByDataCenterId(datacenterId); List<StoragePoolVO> retPools = new ArrayList<StoragePoolVO>(); for (StoragePoolVO pool : pools) { if (pool.getStatus() != StoragePoolStatus.Up) { continue; } if (pool.getScope() == ScopeType.ZONE) { if (pool.getHypervisor() != null && pool.getHypervisor() == type) { retPools.add(pool); } } else { ClusterVO cluster = _clusterDao.findById(pool.getClusterId()); if (type == cluster.getHypervisorType()) { retPools.add(pool); } } } Collections.shuffle(retPools); return retPools; }
@Override public Scope getScope() { StoragePoolVO vo = dataStoreDao.findById(pdsv.getId()); if (vo.getScope() == ScopeType.CLUSTER) { return new ClusterScope(vo.getClusterId(), vo.getPodId(), vo.getDataCenterId()); } else if (vo.getScope() == ScopeType.ZONE) { return new ZoneScope(vo.getDataCenterId()); } else if (vo.getScope() == ScopeType.HOST) { List<StoragePoolHostVO> poolHosts = poolHostDao.listByPoolId(vo.getId()); if (poolHosts.size() > 0) { return new HostScope(poolHosts.get(0).getHostId(), vo.getClusterId(), vo.getDataCenterId()); } s_logger.debug("can't find a local storage in pool host table: " + vo.getId()); } return null; }
volumeStatsByUuid = _userVmMgr.getVolumeStatistics(pool.getClusterId(), pool.getUuid(), pool.getPoolType(), volumeLocators, StatsTimeout.value()); s_logger.warn("Failed to get volume stats for cluster with ID: " + pool.getClusterId(), e); continue;
if (storagePool.getClusterId().equals(host.getClusterId())) { long storagePoolId = storagePool.getId();
hostDao.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, storagePool.getClusterId(), storagePool.getPodId(), storagePool.getDataCenterId(), null); if (listHost == null || listHost.size() == 0) { throw new InvalidParameterValueException("no host in up state is found");
capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled; } else { if (storagePool.getClusterId() != null) { ClusterVO cluster = ApiDBUtils.findClusterById(storagePool.getClusterId()); if (cluster != null) { AllocationState allocationState = _configMgr.findClusterAllocationState(cluster); CapacityVO capacity = new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity, capacityType); capacity.setCapacityState(capacityState);
StoragePoolVO volumeStoragePoolVO = _storagePoolDao.findById(volumeStoragePoolId); if (volumeStoragePoolVO.getClusterId() == null) { String errMsg = "To create a non-managed volume from a managed snapshot, the destination storage pool must be cluster scoped."; boolean computeClusterSupportsVolumeClone = clusterDao.getSupportsResigning(volumeStoragePoolVO.getClusterId()); volumeStoragePoolVO.getClusterId(); VirtualMachineManager.ExecuteInSequence.value()); HostVO hostVO = getHostInCluster(volumeStoragePoolVO.getClusterId()); HostVO hostVO = getHostInCluster(volumeStoragePoolVO.getClusterId());
if (pool.getPoolType() == StoragePoolType.OCFS2 && !_ocfs2Mgr.prepareNodes(pool.getClusterId())) { throw new ConnectionException(true, "Unable to prepare OCFS2 nodes for pool " + pool.getId());
if (srcStoragePoolVO.getClusterId() != null) { hostVO = getHostInCluster(srcStoragePoolVO.getClusterId());
VolumeVO rootVolumeOfVm = rootVolumesOfVm.get(0); StoragePoolVO rootDiskPool = _storagePoolDao.findById(rootVolumeOfVm.getPoolId()); clusterId = (rootDiskPool == null ? null : rootDiskPool.getClusterId());
private HypervisorType getHypervisorType(VMInstanceVO vm, StoragePool srcVolumePool, VirtualMachineProfile profile) { HypervisorType type = null; if (vm == null) { StoragePoolVO poolVo = _poolDao.findById(srcVolumePool.getId()); if (ScopeType.CLUSTER.equals(poolVo.getScope())) { Long clusterId = poolVo.getClusterId(); if (clusterId != null) { ClusterVO cluster = _clusterDao.findById(clusterId); type = cluster.getHypervisorType(); } } else if (ScopeType.ZONE.equals(poolVo.getScope())) { Long zoneId = poolVo.getDataCenterId(); if (zoneId != null) { DataCenterVO dc = _dcDao.findById(zoneId); } } if (null == type) { type = srcVolumePool.getHypervisor(); } } else { type = profile.getHypervisorType(); } return type; }
if (destStoragePoolVO.getClusterId() != null) { hostVO = getHostInCluster(destStoragePoolVO.getClusterId());
private void handleVolumeMigrationForKVM(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo) { VirtualMachine vm = srcVolumeInfo.getAttachedVM(); if (vm != null && vm.getState() != VirtualMachine.State.Stopped) { throw new CloudRuntimeException("Currently, if a volume to migrate from non-managed storage to managed storage on KVM is attached to " + "a VM, the VM must be in the Stopped state."); } destVolumeInfo.getDataStore().getDriver().createAsync(destVolumeInfo.getDataStore(), destVolumeInfo, null); VolumeVO volumeVO = _volumeDao.findById(destVolumeInfo.getId()); volumeVO.setPath(volumeVO.get_iScsiName()); _volumeDao.update(volumeVO.getId(), volumeVO); destVolumeInfo = _volumeDataFactory.getVolume(destVolumeInfo.getId(), destVolumeInfo.getDataStore()); long srcStoragePoolId = srcVolumeInfo.getPoolId(); StoragePoolVO srcStoragePoolVO = _storagePoolDao.findById(srcStoragePoolId); HostVO hostVO; if (srcStoragePoolVO.getClusterId() != null) { hostVO = getHostInCluster(srcStoragePoolVO.getClusterId()); } else { hostVO = getHost(destVolumeInfo.getDataCenterId(), HypervisorType.KVM, false); } // migrate the volume via the hypervisor migrateVolumeForKVM(srcVolumeInfo, destVolumeInfo, hostVO, "Unable to migrate the volume from non-managed storage to managed storage"); volumeVO = _volumeDao.findById(destVolumeInfo.getId()); volumeVO.setFormat(ImageFormat.QCOW2); _volumeDao.update(volumeVO.getId(), volumeVO); }
newVolumeOnPrimaryStorage = _volumeMgr.moveVolume(newVolumeOnPrimaryStorage, vmRootVolumePool.getDataCenterId(), vmRootVolumePool.getPodId(), vmRootVolumePool.getClusterId(), volumeToAttachHyperType); } catch (ConcurrentOperationException e) {
List<HostVO> hosts = null; if (scope.equals(ScopeType.CLUSTER)) { ClusterVO cluster = _clusterDao.findById(storagePool.getClusterId()); hosts = _resourceMgr.listAllHostsInCluster(cluster.getId()); } else if (scope.equals(ScopeType.ZONE)) {
spes = primaryDataStoreDao.listBy(pool.getDataCenterId(), null, null, ScopeType.ZONE); } else { spes = primaryDataStoreDao.listBy(pool.getDataCenterId(), pool.getPodId(), pool.getClusterId(), ScopeType.CLUSTER); hosts = _resourceMgr.listHostsInClusterByStatus(pool.getClusterId(), Status.Up);
AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ); AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ); AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ); AllFieldSearch.and("storage_provider_name", AllFieldSearch.entity().getStorageProviderName(), Op.EQ); AllFieldSearch.done(); DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ); DcPodSearch.cp(); DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL); DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ); DcPodSearch.cp(); DcPodSearch.done();