use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.
the class AddDiskCommandTest method spyDiskValidator.
private DiskValidator spyDiskValidator(Disk disk) {
DiskValidator diskValidator = spy(new DiskValidator(disk));
doReturn(diskValidator).when(command).getDiskValidator(disk);
return diskValidator;
}
use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.
the class TransferDiskImageCommand method validateImageTransfer.
@Override
protected boolean validateImageTransfer() {
DiskImage diskImage = getDiskImage();
DiskValidator diskValidator = getDiskValidator(diskImage);
DiskImagesValidator diskImagesValidator = getDiskImagesValidator(diskImage);
StorageDomainValidator storageDomainValidator = getStorageDomainValidator(storageDomainDao.getForStoragePool(diskImage.getStorageIds().get(0), diskImage.getStoragePoolId()));
return validate(diskValidator.isDiskExists()) && validateActiveDiskPluggedToAnyNonDownVm(diskImage, diskValidator) && validate(diskImagesValidator.diskImagesNotIllegal()) && validate(diskImagesValidator.diskImagesNotLocked()) && validate(storageDomainValidator.isDomainExistAndActive());
}
use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.
the class AmendImageGroupVolumesCommand method validate.
@Override
protected boolean validate() {
DiskValidator diskValidator = createDiskValidator();
if (!validate(diskValidator.isDiskExists())) {
return false;
}
if (!validate(diskValidator.isDiskPluggedToAnyNonDownVm(false))) {
return false;
}
setStoragePoolId(getDiskImage().getStoragePoolId());
if (!validate(new StoragePoolValidator(getStoragePool()).existsAndUp())) {
return false;
}
if (!FeatureSupported.qcowCompatSupported(getStoragePool().getCompatibilityVersion())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_AMEND_NOT_SUPPORTED_BY_DC_VERSION, String.format("$dataCenterVersion %s", getStoragePool().getCompatibilityVersion().toString()));
}
if (getDiskImage().getVmEntityType().isTemplateType()) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_CANT_AMEND_TEMPLATE_DISK);
}
setStorageDomainId(getDiskImage().getStorageIds().get(0));
StorageDomainValidator storageDomainValidator = new StorageDomainValidator(getStorageDomain());
if (!validate(storageDomainValidator.isDomainExistAndActive())) {
return false;
}
DiskImagesValidator diskImagesValidator = new DiskImagesValidator(Collections.singletonList(getDiskImage()));
return validate(diskImagesValidator.diskImagesNotIllegal()) && validate(diskImagesValidator.diskImagesNotLocked());
}
use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.
the class CopyImageGroupCommand method validate.
@Override
protected boolean validate() {
// Not relevant for import VM/VMTemplate
if (getParameters().isImportEntity()) {
return true;
}
Guid imageGroupId = Guid.isNullOrEmpty(getParameters().getImageGroupID()) ? getImageGroupId() : getParameters().getImageGroupID();
Disk disk = diskDao.get(imageGroupId);
DiskValidator diskValidator = createDiskValidator(disk);
if (diskValidator.isDiskExists().isValid()) {
return validate(diskValidator.validateUnsupportedDiskStorageType(DiskStorageType.LUN, DiskStorageType.CINDER));
}
return true;
}
use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.
the class AddDiskCommand method validate.
@Override
protected boolean validate() {
if (!isFloatingDisk() && (!validate(new VmValidator(getVm()).isVmExists()) || !validateDiskVmData())) {
return false;
}
Disk diskInfo = getParameters().getDiskInfo();
if (diskInfo.getDiskStorageType() == DiskStorageType.IMAGE || diskInfo.getDiskStorageType() == DiskStorageType.CINDER) {
getDiskImageInfo().setDiskSnapshot(false);
}
VM vm = getVm();
DiskValidator diskValidator = getDiskValidator(getParameters().getDiskInfo());
DiskVmElementValidator diskVmElementValidator = getDiskVmElementValidator(getParameters().getDiskInfo(), getDiskVmElement());
if (vm != null) {
if (!validateDiskVmData() || !canRunActionOnNonManagedVm()) {
return false;
}
updateDisksFromDb();
if (getDiskVmElement().isBoot() && !validate(diskValidator.isVmNotContainsBootDisk(vm))) {
return false;
}
if (!validatePassDiscardSupported(diskVmElementValidator)) {
return false;
}
// if user sent drive check that its not in use
if (!isDiskPassPciAndIdeLimit()) {
return false;
}
if (!validate(diskVmElementValidator.isReadOnlyPropertyCompatibleWithInterface())) {
return false;
}
} else if (Boolean.TRUE.equals(getParameters().getPlugDiskToVm())) {
return failValidation(EngineMessage.CANNOT_ADD_FLOATING_DISK_WITH_PLUG_VM_SET);
}
if (!validateQuota()) {
return false;
}
if (DiskStorageType.IMAGE == getParameters().getDiskInfo().getDiskStorageType()) {
if (!checkIfImageDiskCanBeAdded(vm, diskVmElementValidator)) {
return false;
}
return setAndValidateDiskProfiles();
}
if (DiskStorageType.LUN == getParameters().getDiskInfo().getDiskStorageType()) {
return checkIfLunDiskCanBeAdded(diskValidator);
}
if (DiskStorageType.CINDER == getParameters().getDiskInfo().getDiskStorageType()) {
CinderDisk cinderDisk = (CinderDisk) getParameters().getDiskInfo();
cinderDisk.setStorageIds(new ArrayList<>(Collections.singletonList(getStorageDomainId())));
StorageDomainValidator storageDomainValidator = createStorageDomainValidator();
CinderDisksValidator cinderDisksValidator = new CinderDisksValidator(cinderDisk);
return validate(storageDomainValidator.isDomainExistAndActive()) && validate(cinderDisksValidator.validateCinderDiskLimits()) && validate(cinderDisksValidator.validateCinderVolumeTypesExist());
}
return true;
}
Aggregations