Source:
private List<String> getAdditionalNameFilters(Cluster cluster) { List<String> additionalNameFilter = new ArrayList<>(); if (cluster == null) { return additionalNameFilter; } if (cluster.getHypervisorType() == Hypervisor.HypervisorType.VMware) { List<VMTemplateStoragePoolVO> templates = templatePoolDao.listAll(); for (VMTemplateStoragePoolVO template : templates) { additionalNameFilter.add(template.getInstallPath()); } List<VolumeVO> volumes = volumeDao.findIncludingRemovedByZone(cluster.getDataCenterId()); for (VolumeVO volumeVO : volumes) { if (volumeVO.getRemoved() == null) { continue; } if (Strings.isNullOrEmpty(volumeVO.getChainInfo())) { continue; } List<String> volumeFileNames = new ArrayList<>(); try { VirtualMachineDiskInfo diskInfo = gson.fromJson(volumeVO.getChainInfo(), VirtualMachineDiskInfo.class); String[] files = diskInfo.getDiskChain(); if (files.length == 1) { continue; } boolean firstFile = true; for (final String file : files) { if (firstFile) { firstFile = false; continue; } String path = file; String[] split = path.split(" "); path = split[split.length - 1]; split = path.split("/"); ; path = split[split.length - 1]; split = path.split("\\."); path = split[0]; if (!Strings.isNullOrEmpty(path)) { if (!additionalNameFilter.contains(path)) { volumeFileNames.add(path); } if (path.contains("-")) { split = path.split("-"); path = split[0]; if (!Strings.isNullOrEmpty(path) && !path.equals("ROOT") && !additionalNameFilter.contains(path)) { volumeFileNames.add(path); } } } } } catch (Exception e) { } if (!volumeFileNames.isEmpty()) { additionalNameFilter.addAll(volumeFileNames); } } } return additionalNameFilter; }

Target:
private List<String> getAdditionalNameFilters(Cluster cluster) { List<String> additionalNameFilter = new ArrayList<>(); if (cluster == null) { return additionalNameFilter; } if (cluster.getHypervisorType() == Hypervisor.HypervisorType.VMware) { List<VMTemplateStoragePoolVO> templates = templatePoolDao.listAll(); for (VMTemplateStoragePoolVO template : templates) { additionalNameFilter.add(template.getInstallPath()); } List<VolumeVO> volumes = volumeDao.findIncludingRemovedByZone(cluster.getDataCenterId()); for (VolumeVO volumeVO : volumes) { if (volumeVO.getRemoved() == null) { continue; } if (Strings.isNullOrEmpty(volumeVO.getChainInfo())) { continue; } List<String> volumeFileNames = new ArrayList<>(); try { VirtualMachineDiskInfo diskInfo = gson.fromJson(volumeVO.getChainInfo(), VirtualMachineDiskInfo.class); String[] files = diskInfo.getDiskChain(); if (files.length == 1) { continue; } boolean firstFile = true; for (final String file : files) { if (firstFile) { firstFile = false; continue; } String path = file; String[] split = path.split(" "); path = split[split.length - 1]; split = path.split("/"); ; path = split[split.length - 1]; split = path.split("\\."); path = split[0]; if (!Strings.isNullOrEmpty(path)) { if (!additionalNameFilter.contains(path)) { volumeFileNames.add(path); } if (path.contains("-")) { split = path.split("-"); path = split[0]; if (!Strings.isNullOrEmpty(path) && !path.equals("ROOT") && !additionalNameFilter.contains(path)) { volumeFileNames.add(path); } } } } } catch (Exception e) { LOGGER.warn(String.format("Unable to find volume file name for volume ID: %s while adding filters unmanaged VMs", volumeVO.getUuid()), e); } if (!volumeFileNames.isEmpty()) { additionalNameFilter.addAll(volumeFileNames); } } } return additionalNameFilter; }