use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class DiskImagesValidator method diskImagesSnapshotsAttachedToVm.
public ValidationResult diskImagesSnapshotsAttachedToVm(Guid vmId) {
LinkedList<String> diskSnapshotInfo = new LinkedList<>();
VM vm = getVmDao().get(vmId);
for (DiskImage diskImage : diskImages) {
List<VmDevice> devices = getVmDeviceDao().getVmDevicesByDeviceId(diskImage.getId(), vmId);
if (devices.isEmpty()) {
// The specified disk image does not belong to the vm
Snapshot snapshot = getSnapshotDao().get(diskImage.getSnapshotId());
Disk disk = getDbFacade().getDiskDao().get(diskImage.getId());
diskSnapshotInfo.add(String.format("%s ,%s", disk.getDiskAlias(), snapshot.getDescription()));
}
}
if (!diskSnapshotInfo.isEmpty()) {
EngineMessage message = EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_NOT_ATTACHED_TO_VM;
return new ValidationResult(message, String.format("$disksInfo %s", String.format(StringUtils.join(diskSnapshotInfo, "%n"))), String.format("$vmName %s", vm.getName()));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class UpdateStorageDomainCommandTest method validateFailsUnSupportedVersionForDiscardAfterDelete.
@Test
public void validateFailsUnSupportedVersionForDiscardAfterDelete() {
EngineMessage message = EngineMessage.ACTION_TYPE_FAILED_DISCARD_AFTER_DELETE_NOT_SUPPORTED_BY_DC_VERSION;
when(storageDomainValidator.isDiscardAfterDeleteSupportedByDcVersion(any())).thenReturn(new ValidationResult(message));
ValidateTestUtils.runAndAssertValidateFailure(cmd, message);
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class UpdateStorageDomainCommandTest method validateFailsIllegalDiscardAfterDelete.
@Test
public void validateFailsIllegalDiscardAfterDelete() {
EngineMessage message = EngineMessage.ACTION_TYPE_FAILED_DISCARD_AFTER_DELETE_NOT_SUPPORTED_BY_UNDERLYING_STORAGE;
when(storageDomainValidator.isDiscardAfterDeleteLegalForExistingStorageDomain()).thenReturn(new ValidationResult(message));
ValidateTestUtils.runAndAssertValidateFailure(cmd, message);
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class VmInitToOpenStackMetadataAdapter method validate.
public List<EngineMessage> validate(VmInit vmInit) {
if (vmInit == null || vmInit.getNetworks() == null) {
return null;
}
List<EngineMessage> msgs = new LinkedList<>();
List<VmInitNetwork> vmInitNetworks = vmInit.getNetworks();
for (VmInitNetwork vmInitNetwork : vmInitNetworks) {
if (!isStartOnBoot(vmInitNetwork)) {
msgs.add(EngineMessage.VALIDATION_CLOUD_INIT_START_ON_BOOT_INVALID);
}
if (isStaticIPv4AndAddressMissing(vmInitNetwork)) {
msgs.add(EngineMessage.VALIDATION_CLOUD_INIT_STATIC_IPV4_ADDRESS_MISSING);
}
if (isStaticIPv6AndAddressMissing(vmInitNetwork)) {
msgs.add(EngineMessage.VALIDATION_CLOUD_INIT_STATIC_IPV6_ADDRESS_MISSING);
}
if (isAutoConfIPv6(vmInitNetwork)) {
msgs.add(EngineMessage.VALIDATION_CLOUD_INIT_IPV6_AUTOCONF_UNSUPPORTED);
}
}
return msgs;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateNotRemovingUsedNetworkByVms.
@SuppressWarnings("unchecked")
ValidationResult validateNotRemovingUsedNetworkByVms(String removedNetworkName) {
final List<String> removedNetworkNames = Collections.singletonList(removedNetworkName);
final List<String> vmsNames = findActiveVmsUsingNetwork.findNamesOfActiveVmsUsingNetworks(host.getId(), removedNetworkNames);
if (vmsNames.isEmpty()) {
return ValidationResult.VALID;
}
EngineMessage engineMessage = EngineMessage.NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS;
return new ValidationResult(engineMessage, Stream.concat(ReplacementUtils.replaceWith(VAR_NETWORK_NAME, removedNetworkNames, SEPARATOR).stream(), ReplacementUtils.replaceWith(VAR_VM_NAMES, vmsNames, SEPARATOR).stream()).collect(Collectors.toList()));
}
Aggregations