Source:
protected boolean validate() { if (getVm() == null) { addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_VM_NOT_FOUND); return false; } if (!canRunActionOnNonManagedVm()) { return false; } if (!isSpecifiedDisksExist(getParameters().getDiskIds())) { return false; } if (getParameters().getDiskIds() != null) { String notAllowSnapshot = diskDao.getAllForVm(getVm().getId()).stream() .filter(disk -> getParameters().getDiskIds().contains(disk.getId())) .filter(disk -> !disk.isAllowSnapshot()) .map(disk -> disk.getId().toString()) .collect(Collectors.joining(",")); if (!notAllowSnapshot.isEmpty()) { addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_CANNOT_SNAPSHOT_DISKS); addValidationMessageVariable("diskIds", notAllowSnapshot); return false; } } VmValidator vmValidator = createVmValidator(); StoragePoolValidator spValidator = createStoragePoolValidator(); DiskImagesValidator diskImagesValidatorForChain = createDiskImageValidator(DisksFilter.filterImageDisks(getDisksList(), ONLY_NOT_SHAREABLE, ONLY_SNAPABLE, ONLY_ACTIVE)); if (!(validateVM(vmValidator) && validate(spValidator.isUp()) && validate(vmValidator.vmNotIlegal()) && validate(vmValidator.vmNotLocked()) && validate(snapshotsValidator.vmNotDuringSnapshot(getVmId())) && validate(snapshotsValidator.vmNotInPreview(getVmId())) && validate(vmValidator.vmNotDuringMigration()) && validate(vmValidator.vmNotRunningStateless()) && validate(diskImagesValidatorForChain.diskImagesHaveNotExceededMaxNumberOfVolumesInImageChain()) && (!getParameters().isSaveMemory() || validate(vmValidator.vmNotHavingPciPassthroughDevices())))) { return false; } List<DiskImage> disksList = getDisksListForChecks(); if (disksList.size() > 0) { DiskImagesValidator diskImagesValidator = createDiskImageValidator(disksList); if (!(validate(diskImagesValidator.diskImagesNotLocked()) && validate(diskImagesValidator.diskImagesNotIllegal()))) { return false; } } return validateStorage(); }

Target:
protected boolean validate() { if (getVm() == null) { addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_VM_NOT_FOUND); return false; } if (!canRunActionOnNonManagedVm()) { return false; } Set<Guid> specificiedDiskIds = getParameters().getDiskIds(); if (specificiedDiskIds != null && !specificiedDiskIds.isEmpty()) { if (!isSpecifiedDisksExist(specificiedDiskIds)) { return false; } String notAllowSnapshot = diskDao.getAllForVm(getVm().getId()).stream() .filter(disk -> specificiedDiskIds.contains(disk.getId())) .filter(disk -> !disk.isAllowSnapshot()) .map(BaseDisk::getDiskAlias) .collect(Collectors.joining(",")); if (!notAllowSnapshot.isEmpty()) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_DISK_SNAPSHOT_NOT_SUPPORTED, String .format("$diskAliases %s", notAllowSnapshot)); } } VmValidator vmValidator = createVmValidator(); StoragePoolValidator spValidator = createStoragePoolValidator(); DiskImagesValidator diskImagesValidatorForChain = createDiskImageValidator(DisksFilter.filterImageDisks(getDisksList(), ONLY_NOT_SHAREABLE, ONLY_SNAPABLE, ONLY_ACTIVE)); if (!(validateVM(vmValidator) && validate(spValidator.isUp()) && validate(vmValidator.vmNotIlegal()) && validate(vmValidator.vmNotLocked()) && validate(snapshotsValidator.vmNotDuringSnapshot(getVmId())) && validate(snapshotsValidator.vmNotInPreview(getVmId())) && validate(vmValidator.vmNotDuringMigration()) && validate(vmValidator.vmNotRunningStateless()) && validate(diskImagesValidatorForChain.diskImagesHaveNotExceededMaxNumberOfVolumesInImageChain()) && (!getParameters().isSaveMemory() || validate(vmValidator.vmNotHavingPciPassthroughDevices())))) { return false; } List<DiskImage> disksList = getDisksListForChecks(); if (disksList.size() > 0) { DiskImagesValidator diskImagesValidator = createDiskImageValidator(disksList); if (!(validate(diskImagesValidator.diskImagesNotLocked()) && validate(diskImagesValidator.diskImagesNotIllegal()))) { return false; } } return validateStorage(); }