use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class RunVmValidator method validateIsoPath.
protected ValidationResult validateIsoPath(VM vm, String diskPath, String floppyPath, Guid activeIsoDomainId) {
if (vm.isAutoStartup()) {
return ValidationResult.VALID;
}
if (StringUtils.isEmpty(vm.getIsoPath()) && StringUtils.isEmpty(diskPath) && StringUtils.isEmpty(floppyPath)) {
return ValidationResult.VALID;
}
if (!StringUtils.isEmpty(floppyPath) && activeIsoDomainId == null) {
return new ValidationResult(EngineMessage.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO);
}
String effectiveIsoPath = StringUtils.isEmpty(diskPath) ? vm.getIsoPath() : diskPath;
if (!StringUtils.isEmpty(effectiveIsoPath)) {
if (effectiveIsoPath.matches(ValidationUtils.GUID)) {
BaseDisk disk = diskDao.get(Guid.createGuidFromString(effectiveIsoPath));
if (disk == null || disk.getContentType() != DiskContentType.ISO) {
return new ValidationResult(EngineMessage.ERROR_CANNOT_FIND_ISO_IMAGE_PATH);
}
Guid domainId = ((DiskImage) disk).getStorageIds().get(0);
StoragePoolIsoMap spim = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(domainId, vm.getStoragePoolId()));
if (spim == null || spim.getStatus() != StorageDomainStatus.Active) {
return new ValidationResult(EngineMessage.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO);
}
} else if (activeIsoDomainId == null) {
return new ValidationResult(EngineMessage.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO);
} else if (!isRepoImageExists(effectiveIsoPath, activeIsoDomainId, ImageFileType.ISO)) {
return new ValidationResult(EngineMessage.ERROR_CANNOT_FIND_ISO_IMAGE_PATH);
}
return ValidationResult.VALID;
}
if (!StringUtils.isEmpty(floppyPath) && !isRepoImageExists(floppyPath, activeIsoDomainId, ImageFileType.Floppy)) {
return new ValidationResult(EngineMessage.ERROR_CANNOT_FIND_FLOPPY_IMAGE_PATH);
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.ValidationResult 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.ValidationResult in project ovirt-engine by oVirt.
the class ImportValidator method validateSpaceRequirements.
public ValidationResult validateSpaceRequirements(Collection<DiskImage> diskImages) {
MultipleStorageDomainsValidator sdValidator = createMultipleStorageDomainsValidator(diskImages);
ValidationResult result = sdValidator.allDomainsExistAndActive();
if (!result.isValid()) {
return result;
}
result = sdValidator.allDomainsWithinThresholds();
if (!result.isValid()) {
return result;
}
if (params.getCopyCollapse()) {
return sdValidator.allDomainsHaveSpaceForClonedDisks(diskImages);
}
return sdValidator.allDomainsHaveSpaceForDisksWithSnapshots(diskImages);
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class InClusterUpgradeValidator method isUpgradePossible.
public ValidationResult isUpgradePossible(Collection<VDS> hosts, Collection<VM> vms) {
requireNonNull(hosts);
requireNonNull(vms);
final List<String> errors = new ArrayList<>();
for (final VDS host : hosts) {
final OS hostOs = OS.fromPackageVersionString(host.getHostOs());
if (!hostOs.isValid()) {
errors.addAll(toHostEngineMessage(host, EngineMessage.CLUSTER_UPGRADE_DETAIL_HOST_INVALID_OS));
}
}
for (final VM vm : vms) {
errors.addAll(checkVmReadyForUpgrade(vm));
}
if (errors.isEmpty()) {
return ValidationResult.VALID;
} else {
return new ValidationResult(EngineMessage.CLUSTER_UPGRADE_CAN_NOT_BE_STARTED, errors);
}
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class NetworkAttachmentIpConfigurationValidator method validateIpv4Configuration.
private ValidationResult validateIpv4Configuration(NetworkAttachment networkAttachment) {
IpConfiguration ipConfiguration = networkAttachment.getIpConfiguration();
if (!ipConfiguration.hasIpv4PrimaryAddressSet()) {
return ValidationResult.VALID;
}
IPv4Address iPv4Address = ipConfiguration.getIpv4PrimaryAddress();
String networkName = networkAttachment.getNetworkName();
String nicName = networkAttachment.getNicName();
if (iPv4Address.getBootProtocol() == null) {
return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_MISSING_BOOT_PROTOCOL, networkName, nicName);
}
Ipv4BootProtocol bootProtocol = iPv4Address.getBootProtocol();
if (bootProtocol == Ipv4BootProtocol.STATIC_IP) {
if (!validStaticIpv4AddressDetails(iPv4Address)) {
return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_STATIC_BOOT_PROTOCOL_MISSING_IP_ADDRESS_DETAILS, networkName, nicName);
}
} else {
if (!isEmptyIpv4AddressDetails(iPv4Address)) {
return new ValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_INCOMPATIBLE_BOOT_PROTOCOL_AND_IP_ADDRESS_DETAILS, ReplacementUtils.createSetVariableString(VAR_NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(VAR_INTERFACE_NAME, nicName), ReplacementUtils.createSetVariableString(VAR_BOOT_PROTOCOL, bootProtocol.getDisplayName()));
}
}
return ValidationResult.VALID;
}
Aggregations