use of org.ovirt.engine.core.dao.DiskDao in project ovirt-engine by oVirt.
the class RemoveSnapshotCommand method validateSnapshotDisksArePlugged.
private boolean validateSnapshotDisksArePlugged() {
Map<Guid, Disk> vmDisks = diskDao.getAllForVm(getVmId()).stream().collect(Collectors.toMap(Disk::getId, Function.identity()));
// If there is an unattached disk, it will not be included in vmDisks, hence it is
// retrieved by the diskDao. This is less likely to happen as it is not possible
// to unattach disks with snapshots.
String unpluggedDisks = getSourceImages().stream().map(DiskImage::getId).map(vmDiskId -> vmDisks.getOrDefault(vmDiskId, diskDao.get(vmDiskId))).filter(disk -> !disk.getPlugged()).map(Disk::getDiskAlias).collect(Collectors.joining(System.lineSeparator()));
if (!unpluggedDisks.isEmpty()) {
return validate(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_SNAPSHOT_HAS_UNPLUGGED_OR_UNATTACHED_DISKS, String.format("$diskAliases %s", unpluggedDisks)));
}
return true;
}
Aggregations