use of org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator in project ovirt-engine by oVirt.
the class RecoveryStoragePoolCommand method validate.
@Override
protected boolean validate() {
StoragePoolValidator storagePoolValidator = createStoragePoolValidator();
if (!validate(storagePoolValidator.exists()) || !validate(new StorageDomainValidator(getStorageDomain()).isInProcess()) || !validate(storagePoolValidator.isAnyDomainInProcess()) || !validate(storagePoolValidator.isNotInStatus(StoragePoolStatus.Uninitialized))) {
return false;
}
if (getStorageDomain() != null && getStorageDomain().getStatus() == StorageDomainStatus.Active) {
addStorageDomainStatusIllegalMessage();
return false;
}
if (electNewMaster() != null) {
return failValidation(EngineMessage.STORAGE_POOL_REINITIALIZE_WITH_MORE_THAN_ONE_DATA_DOMAIN);
}
StorageDomain domain = loadTargetedMasterDomain();
if (domain.getStorageDomainSharedStatus() != StorageDomainSharedStatus.Unattached) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL);
}
return initializeVds();
}
use of org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator in project ovirt-engine by oVirt.
the class ImportValidator method validateStorageExistsForMemoryDisks.
public ValidationResult validateStorageExistsForMemoryDisks(List<Snapshot> snapshots, boolean allowPartial, Map<Guid, String> failedDisksToImport) {
for (Snapshot snap : snapshots) {
if (snap.containsMemory()) {
DiskImage memoryDump = (DiskImage) getDiskDao().get(snap.getMemoryDiskId());
StorageDomain dumpSd = getStorageDomainDao().getForStoragePool(memoryDump.getStorageIds().get(0), params.getStoragePoolId());
ValidationResult dumpSdResult = new StorageDomainValidator(dumpSd).isDomainExistAndActive();
if (!handleStorageValidationResult(dumpSdResult, memoryDump, snap, failedDisksToImport) && !allowPartial) {
return dumpSdResult;
}
DiskImage memoryConf = (DiskImage) getDiskDao().get(snap.getMetadataDiskId());
StorageDomain confSd = getStorageDomainDao().getForStoragePool(memoryConf.getStorageIds().get(0), params.getStoragePoolId());
ValidationResult confSdResult = new StorageDomainValidator(confSd).isDomainExistAndActive();
if (!handleStorageValidationResult(confSdResult, memoryConf, snap, failedDisksToImport) && !allowPartial) {
return confSdResult;
}
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator in project ovirt-engine by oVirt.
the class AddDiskCommandTest method mockStorageDomainValidatorWithoutSpace.
private static StorageDomainValidator mockStorageDomainValidatorWithoutSpace() {
StorageDomainValidator storageDomainValidator = mockStorageDomainValidator();
when(storageDomainValidator.hasSpaceForNewDisk(any())).thenReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN));
return storageDomainValidator;
}
use of org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator in project ovirt-engine by oVirt.
the class AddVmAndCloneImageCommand method buildAndCheckDestStorageDomains.
@Override
protected boolean buildAndCheckDestStorageDomains() {
if (diskInfoDestinationMap.isEmpty()) {
List<StorageDomain> domains = storageDomainDao.getAllForStoragePool(getStoragePoolId());
Map<Guid, StorageDomain> storageDomainsMap = new HashMap<>();
for (StorageDomain storageDomain : domains) {
StorageDomainValidator validator = new StorageDomainValidator(storageDomain);
if (validate(validator.isDomainExistAndActive()) && validate(validator.domainIsValidDestination())) {
storageDomainsMap.put(storageDomain.getId(), storageDomain);
}
}
for (Disk disk : getDiskImagesToBeCloned()) {
DiskImage image = (DiskImage) disk;
for (Guid storageId : image.getStorageIds()) {
if (storageDomainsMap.containsKey(storageId)) {
diskInfoDestinationMap.put(image.getId(), image);
break;
}
}
}
if (getDiskImagesToBeCloned().size() != diskInfoDestinationMap.size()) {
logErrorOneOrMoreActiveDomainsAreMissing();
return false;
}
List<Guid> storageDomainDest = new ArrayList<>();
for (DiskImage diskImage : diskInfoDestinationMap.values()) {
Guid storageDomainId = diskImage.getStorageIds().get(0);
if (storageDomainDest.contains(storageDomainId)) {
destStorages.put(storageDomainId, storageDomainsMap.get(storageDomainId));
}
storageDomainDest.add(storageDomainId);
}
return true;
}
return super.buildAndCheckDestStorageDomains();
}
use of org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator in project ovirt-engine by oVirt.
the class RegisterDiskCommand method validate.
@Override
protected boolean validate() {
refreshDiskImageIfNecessery();
// Currently this only supports importing DiskImages or CinderDisks and does not work with LunDisks.
if (getDiskImage().getDiskStorageType() != DiskStorageType.IMAGE && getDiskImage().getDiskStorageType() != DiskStorageType.CINDER) {
addValidationMessageVariable("diskId", getDiskImage().getId());
addValidationMessageVariable("storageType", getDiskImage().getDiskStorageType());
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_DISK_STORAGE_TYPE);
return false;
}
if (!validate(new StorageDomainValidator(getStorageDomain()).isDomainExist())) {
addValidationMessageVariable("diskId", getDiskImage().getId());
addValidationMessageVariable("domainId", getStorageDomainId());
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_UNAVAILABLE);
return false;
}
if (!getStorageDomain().getStorageDomainType().isDataDomain() && !(getStorageDomain().getStorageDomainType() == StorageDomainType.Volume)) {
addValidationMessageVariable("domainId", getParameters().getStorageDomainId());
addValidationMessageVariable("domainType", getStorageDomain().getStorageDomainType());
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED);
return false;
}
if (diskDao.get(getDiskImage().getId()) != null) {
String diskAlias = ImagesHandler.getDiskAliasWithDefault(getDiskImage(), generateDefaultAliasForRegiteredDisk(Calendar.getInstance()));
addValidationMessageVariable("diskAliases", diskAlias);
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_DISKS_LOCKED);
return false;
}
if (!validate(createDiskImagesValidator(getDiskImage()).isQcowVersionSupportedForDcVersion())) {
return false;
}
if (getDiskImage().getDiskStorageType() == DiskStorageType.IMAGE && !setAndValidateDiskProfiles()) {
return false;
}
return true;
}
Aggregations