@Override public String getUuid() { return pdsv.getUuid(); }
@Override public String getUri() { String path = pdsv.getPath().replaceFirst("/*", ""); StringBuilder builder = new StringBuilder(); builder.append(pdsv.getPoolType()); builder.append("://"); builder.append(pdsv.getHostAddress()); builder.append(File.separator); builder.append(path); builder.append(File.separator); builder.append("?" + EncodingType.ROLE + "=" + getRole()); builder.append("&" + EncodingType.STOREUUID + "=" + pdsv.getUuid()); return builder.toString(); }
@Override public String getPrimaryStorageNameLabel(VolumeVO volume) { Long poolId = volume.getPoolId(); // poolId is null only if volume is destroyed, which has been checked // before. assert poolId != null; StoragePoolVO PrimaryDataStoreVO = _storagePoolDao.findById(poolId); assert PrimaryDataStoreVO != null; return PrimaryDataStoreVO.getUuid(); }
/** * Executes the managed storage checks for the mapping<volume, storage pool> entered by the user. The checks execute by this method are the following. * <ul> * <li> If the current storage pool of the volume is not a managed storage, we do not need to validate anything here. * <li> If the current storage pool is a managed storage and the target storage pool ID is different from the current one, we throw an exception. * </ul> */ protected void executeManagedStorageChecksWhenTargetStoragePoolProvided(StoragePoolVO currentPool, VolumeVO volume, StoragePoolVO targetPool) { if (!currentPool.isManaged()) { return; } if (currentPool.getId() == targetPool.getId()) { return; } throw new CloudRuntimeException(String.format("Currently, a volume on managed storage can only be 'migrated' to itself " + "[volumeId=%s, currentStoragePoolId=%s, targetStoragePoolId=%s].", volume.getUuid(), currentPool.getUuid(), targetPool.getUuid())); }
private ModifyTargetsCommand getModifyTargetsCommand(long storagePoolId, String iqn, boolean add) { StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId); Map<String, String> details = new HashMap<>(); details.put(ModifyTargetsCommand.IQN, iqn); details.put(ModifyTargetsCommand.STORAGE_TYPE, storagePool.getPoolType().name()); details.put(ModifyTargetsCommand.STORAGE_UUID, storagePool.getUuid()); details.put(ModifyTargetsCommand.STORAGE_HOST, storagePool.getHostAddress()); details.put(ModifyTargetsCommand.STORAGE_PORT, String.valueOf(storagePool.getPort())); ModifyTargetsCommand cmd = new ModifyTargetsCommand(); List<Map<String, String>> targets = new ArrayList<>(); targets.add(details); cmd.setTargets(targets); cmd.setApplyToAllHostsInCluster(true); cmd.setAdd(add); cmd.setTargetTypeToRemove(ModifyTargetsCommand.TargetTypeToRemove.DYNAMIC); return cmd; }
/** * Builds the map of storage pools and volumes with the information entered by the user. Before creating the an entry we validate if the migration is feasible checking if the migration is allowed and if the target host can access the defined target storage pool. */ protected Map<Volume, StoragePool> buildMapUsingUserInformation(VirtualMachineProfile profile, Host targetHost, Map<Long, Long> userDefinedVolumeToStoragePoolMap) { Map<Volume, StoragePool> volumeToPoolObjectMap = new HashMap<>(); if (MapUtils.isEmpty(userDefinedVolumeToStoragePoolMap)) { return volumeToPoolObjectMap; } for(Long volumeId: userDefinedVolumeToStoragePoolMap.keySet()) { VolumeVO volume = _volsDao.findById(volumeId); Long poolId = userDefinedVolumeToStoragePoolMap.get(volumeId); StoragePoolVO targetPool = _storagePoolDao.findById(poolId); StoragePoolVO currentPool = _storagePoolDao.findById(volume.getPoolId()); executeManagedStorageChecksWhenTargetStoragePoolProvided(currentPool, volume, targetPool); if (_poolHostDao.findByPoolHost(targetPool.getId(), targetHost.getId()) == null) { throw new CloudRuntimeException( String.format("Cannot migrate the volume [%s] to the storage pool [%s] while migrating VM [%s] to target host [%s]. The host does not have access to the storage pool entered.", volume.getUuid(), targetPool.getUuid(), profile.getUuid(), targetHost.getUuid())); } if (currentPool.getId() == targetPool.getId()) { s_logger.info(String.format("The volume [%s] is already allocated in storage pool [%s].", volume.getUuid(), targetPool.getUuid())); } volumeToPoolObjectMap.put(volume, targetPool); } return volumeToPoolObjectMap; }
volumeStatsByUuid = new HashMap<>(); for (final Cluster cluster : _clusterDao.listByZoneId(pool.getDataCenterId())) { final Map<String, VolumeStatsEntry> volumeStatsForCluster = _userVmMgr.getVolumeStatistics(cluster.getId(), pool.getUuid(), pool.getPoolType(), volumeLocators, StatsTimeout.value()); if (volumeStatsForCluster != null) { volumeStatsByUuid = _userVmMgr.getVolumeStatistics(pool.getClusterId(), pool.getUuid(), pool.getPoolType(), volumeLocators, StatsTimeout.value());
/** * Executes the managed storage checks for the volumes that the user has not entered a mapping of <volume, storage pool>. The following checks are performed. * <ul> * <li> If the current storage pool is not a managed storage, we do not need to proceed with this method; * <li> We check if the target host has access to the current managed storage pool. If it does not have an exception will be thrown. * </ul> */ protected void executeManagedStorageChecksWhenTargetStoragePoolNotProvided(Host targetHost, StoragePoolVO currentPool, Volume volume) { if (!currentPool.isManaged()) { return; } if (_poolHostDao.findByPoolHost(currentPool.getId(), targetHost.getId()) == null) { throw new CloudRuntimeException(String.format("The target host does not have access to the volume's managed storage pool. [volumeId=%s, storageId=%s, targetHostId=%s].", volume.getUuid(), currentPool.getUuid(), targetHost.getUuid())); } }
if (hostIds == null || hostIds.isEmpty()) continue; GetStorageStatsCommand command = new GetStorageStatsCommand(pool.getUuid(), pool.getPoolType(), pool.getPath()); long poolId = pool.getId(); try {
esvolume = ElastistorUtil.createElastistorVolume(volumeName, dataStoreVO.getUuid(), quotaSize, Iops, protocoltype, volumeName); } catch (Throwable e) { s_logger.error(e.toString(), e);
StoragePoolVO spool = ApiDBUtils.findStoragePoolById(job.getInstanceId()); if (spool != null) { jobInstanceId = spool.getUuid();
public PrimaryDataStoreDaoImpl() { AllFieldSearch = createSearchBuilder(); AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ); AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ); AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);