use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class VmNicMacsUtilsTest method testValidateThereIsEnoughOfFreeMacsPositive.
@Test
public void testValidateThereIsEnoughOfFreeMacsPositive() {
when(macPoolMock.getAvailableMacsCount()).thenReturn(1);
final ValidationResult actual = underTest.validateThereIsEnoughOfFreeMacs(singletonList(vmNetworkInterfaceMock), macPoolMock, ALWAYS_TRUE);
assertThat(actual, isValid());
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class AbstractSyncLunsCommandTest method testValidateVdsDoesNotExist.
@Test
public void testValidateVdsDoesNotExist() {
when(hostValidator.hostExists()).thenReturn(new ValidationResult(EngineMessage.VDS_INVALID_SERVER_ID));
assertFalse(command.validateVds());
ValidateTestUtils.assertValidationMessages("", command, EngineMessage.VDS_INVALID_SERVER_ID);
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class AbstractSyncLunsCommandTest method validateVdsIsNotUp.
@Test
public void validateVdsIsNotUp() {
when(hostValidator.hostExists()).thenReturn(ValidationResult.VALID);
when(hostValidator.isUp()).thenReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL));
assertFalse(command.validateVds());
ValidateTestUtils.assertValidationMessages("", command, EngineMessage.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL);
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class RemoveSnapshotCommand method validateSnapshotDisksArePlugged.
private boolean validateSnapshotDisksArePlugged() {
Map<Guid, Disk> vmDisks = diskDao.getAllForVm(getVmId()).stream().collect(Collectors.toMap(Disk::getId, Function.identity()));
// If there is an unattached disk, it will not be included in vmDisks, hence it is
// retrieved by the diskDao. This is less likely to happen as it is not possible
// to unattach disks with snapshots.
String unpluggedDisks = getSourceImages().stream().map(DiskImage::getId).map(vmDiskId -> vmDisks.getOrDefault(vmDiskId, diskDao.get(vmDiskId))).filter(disk -> !disk.getPlugged()).map(Disk::getDiskAlias).collect(Collectors.joining(System.lineSeparator()));
if (!unpluggedDisks.isEmpty()) {
return validate(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_SNAPSHOT_HAS_UNPLUGGED_OR_UNATTACHED_DISKS, String.format("$diskAliases %s", unpluggedDisks)));
}
return true;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class NetworkPolicyUnit method validatePassthroughVnics.
private ValidationResult validatePassthroughVnics(Guid vmId, VDS host, List<VmNetworkInterface> vnics) {
VfScheduler vfScheduler = Injector.get(VfScheduler.class);
List<String> problematicVnics = vfScheduler.validatePassthroughVnics(vmId, host.getId(), vnics);
if (!problematicVnics.isEmpty()) {
String vnicsString = StringUtils.join(problematicVnics, ", ");
log.warn("host {} doesn't contain suitable virtual functions for VM nics {}", host.getName(), vnicsString);
return new ValidationResult(EngineMessage.VAR__DETAIL__NO_SUITABLE_VF, String.format("$vnicNames %1$s", vnicsString));
}
return ValidationResult.VALID;
}
Aggregations