Skip to content

Commit b2ba6ba

Browse files
committed
Removed unused arg and condition if format is OVA when listing volumes
1 parent f52ad0a commit b2ba6ba

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

server/src/main/java/com/cloud/vm/UserVmManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public interface UserVmManager extends UserVmService {
8686

8787
HashMap<Long, List<VmDiskStatsEntry>> getVmDiskStatistics(long hostId, String hostName, List<Long> vmIds);
8888

89-
HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, List<String> volumeLocator, int timout);
89+
HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, int timout);
9090

9191
boolean deleteVmGroup(long groupId);
9292

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,13 +1955,13 @@ public HashMap<Long, VmStatsEntry> getVirtualMachineStatistics(long hostId, Stri
19551955
}
19561956

19571957
@Override
1958-
public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, List<String> volumeLocators, int timeout) {
1958+
public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, int timeout) {
19591959
List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(clusterId, Status.Up);
19601960
StoragePoolVO storagePool = _storagePoolDao.findPoolByUUID(poolUuid);
19611961
HashMap<String, VolumeStatsEntry> volumeStatsByUuid = new HashMap<>();
19621962

19631963
for (HostVO neighbor : neighbors) {
1964-
volumeLocators = getVolumesByHost(neighbor, storagePool);
1964+
List<String> volumeLocators = getVolumesByHost(neighbor, storagePool);
19651965

19661966
// - zone wide storage for specific hypervisortypes
19671967
if ((ScopeType.ZONE.equals(storagePool.getScope()) && storagePool.getHypervisor() != neighbor.getHypervisorType()) || (volumeLocators == null || volumeLocators.size() == 0)) {
@@ -1979,7 +1979,9 @@ public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, Str
19791979

19801980
if (answer instanceof GetVolumeStatsAnswer){
19811981
GetVolumeStatsAnswer volstats = (GetVolumeStatsAnswer)answer;
1982-
volumeStatsByUuid.putAll(volstats.getVolumeStats());
1982+
if (volstats.getVolumeStats() != null) {
1983+
volumeStatsByUuid.putAll(volstats.getVolumeStats());
1984+
}
19831985
}
19841986
}
19851987
return volumeStatsByUuid.size() > 0 ? volumeStatsByUuid : null;
@@ -1988,7 +1990,8 @@ public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, Str
19881990
private List<String> getVolumesByHost(HostVO host, StoragePool pool){
19891991
List<VMInstanceVO> vmsPerHost = _vmInstanceDao.listByHostId(host.getId());
19901992
return vmsPerHost.stream()
1991-
.flatMap(vm -> _volsDao.findByInstanceIdAndPoolId(vm.getId(),pool.getId()).stream().map(vol -> vol.getState() == Volume.State.Ready ? vol.getPath() : null).filter(Objects::nonNull))
1993+
.flatMap(vm -> _volsDao.findByInstanceIdAndPoolId(vm.getId(),pool.getId()).stream().map(vol ->
1994+
vol.getState() == Volume.State.Ready ? (vol.getFormat() == ImageFormat.OVA ? vol.getChainInfo() : vol.getPath()) : null).filter(Objects::nonNull))
19921995
.collect(Collectors.toList());
19931996
}
19941997

0 commit comments

Comments
 (0)