@Override public List<VolumeInfo> getVolumes() { List<VolumeVO> volumes = volumeDao.findByPoolId(getId()); List<VolumeInfo> volumeInfos = new ArrayList<VolumeInfo>(); for (VolumeVO volume : volumes) { volumeInfos.add(VolumeObject.getVolumeObject(this, volume)); } return volumeInfos; }
private List<Map<String, String>> getTargets(long clusterId, long storagePoolId) { List<Map<String, String>> targets = new ArrayList<>(); StoragePoolVO storagePool = storagePoolDao.findById(storagePoolId); // If you do not pass in null for the second parameter, you only get back applicable ROOT disks. List<VolumeVO> volumes = volumeDao.findByPoolId(storagePoolId, null); if (volumes != null) { for (VolumeVO volume : volumes) { Long instanceId = volume.getInstanceId(); if (instanceId != null) { VMInstanceVO vmInstance = vmDao.findById(instanceId); Long hostIdForVm = vmInstance.getHostId() != null ? vmInstance.getHostId() : vmInstance.getLastHostId(); if (hostIdForVm != null) { HostVO hostForVm = hostDao.findById(hostIdForVm); if (hostForVm.getClusterId().equals(clusterId)) { Map<String, String> details = new HashMap<>(); details.put(ModifyTargetsCommand.IQN, volume.get_iScsiName()); details.put(ModifyTargetsCommand.STORAGE_HOST, storagePool.getHostAddress()); details.put(ModifyTargetsCommand.STORAGE_PORT, String.valueOf(storagePool.getPort())); targets.add(details); } } } } } return targets; }
private List<String> getStoragePaths(long clusterId, long storagePoolId) { List<String> storagePaths = new ArrayList<>(); // If you do not pass in null for the second parameter, you only get back applicable ROOT disks. List<VolumeVO> volumes = volumeDao.findByPoolId(storagePoolId, null); if (volumes != null) { for (VolumeVO volume : volumes) { Long instanceId = volume.getInstanceId(); if (instanceId != null) { VMInstanceVO vmInstance = vmDao.findById(instanceId); Long hostIdForVm = vmInstance.getHostId() != null ? vmInstance.getHostId() : vmInstance.getLastHostId(); if (hostIdForVm != null) { HostVO hostForVm = hostDao.findById(hostIdForVm); if (hostForVm != null && hostForVm.getClusterId().equals(clusterId)) { storagePaths.add(volume.get_iScsiName()); } } } } } return storagePaths; }
@Override public long getUsedIops(StoragePool storagePool) { long usedIops = 0; List<VolumeVO> volumes = volumeDao.findByPoolId(storagePool.getId(), null); if (volumes != null) { for (VolumeVO volume : volumes) { if (!Volume.State.Creating.equals(volume.getState())) { usedIops += volume.getMinIops() != null ? volume.getMinIops() : 0; } } } return usedIops; }
List<VolumeVO> volumes = _volsDao.findByPoolId(pool.getId(), null); List<String> volumeLocators = new ArrayList<String>(); for (VolumeVO volume : volumes) {
private long getUsedBytes(StoragePool storagePool, long volumeIdToIgnore) { long usedSpace = 0; List<VolumeVO> lstVolumes = volumeDao.findByPoolId(storagePool.getId(), null);
List<VolumeVO> allVolumes = volumeDao.findByPoolId(pool.getId());