use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class ExtendSANStorageDomainCommandTest method validateFailsDiscardFunctionalityBreaks.
@Test
public void validateFailsDiscardFunctionalityBreaks() {
passAllValidations();
EngineMessage lunsBreakStorageDomainDiscardSupportMessage = EngineMessage.ACTION_TYPE_FAILED_LUN_BREAKS_STORAGE_DOMAIN_PASS_DISCARD_SUPPORT;
doReturn(new ValidationResult(lunsBreakStorageDomainDiscardSupportMessage)).when(discardHelper).isExistingDiscardFunctionalityPreserved(any(), any());
runAndAssertValidateFailure(command, lunsBreakStorageDomainDiscardSupportMessage);
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testInterfaceExistsWhenInterfaceIsNull.
@Test
public void testInterfaceExistsWhenInterfaceIsNull() throws Exception {
String failingSlaveName = "slaveName";
EngineMessage engineMessage = EngineMessage.HOST_NETWORK_INTERFACE_HAVING_NAME_DOES_NOT_EXIST;
String nicNameReplacement = ReplacementUtils.getVariableAssignmentString(engineMessage, failingSlaveName);
assertThat(new HostInterfaceValidator(null).interfaceExists(failingSlaveName), failsWith(engineMessage, nicNameReplacement));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class DiskImagesValidator method diskImagesSnapshotsNotAttachedToOtherVms.
public ValidationResult diskImagesSnapshotsNotAttachedToOtherVms(boolean onlyPlugged) {
LinkedList<String> pluggedDiskSnapshotInfo = new LinkedList<>();
for (DiskImage diskImage : diskImages) {
List<VmDevice> devices = getVmDeviceDao().getVmDevicesByDeviceId(diskImage.getId(), null);
for (VmDevice device : devices) {
if (device.getSnapshotId() != null && (!onlyPlugged || device.isPlugged())) {
VM vm = getVmDao().get(device.getVmId());
Snapshot snapshot = getSnapshotDao().get(device.getSnapshotId());
pluggedDiskSnapshotInfo.add(String.format("%s ,%s, %s", diskImage.getDiskAlias(), snapshot.getDescription(), vm.getName()));
}
}
}
if (!pluggedDiskSnapshotInfo.isEmpty()) {
EngineMessage message = onlyPlugged ? EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_IS_PLUGGED_TO_ANOTHER_VM : EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_IS_ATTACHED_TO_ANOTHER_VM;
return new ValidationResult(message, String.format("$disksInfo %s", String.format(StringUtils.join(pluggedDiskSnapshotInfo, "%n"))));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testBondNotUpdatedAndRemovedSimultaneouslyNotValid.
@Test
public void testBondNotUpdatedAndRemovedSimultaneouslyNotValid() {
HostSetupNetworksParameters params = new ParametersBuilder().addBonds(CreateOrUpdateBond.fromBond(bond)).addRemovedBonds(bond.getId()).build();
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(params).build();
EngineMessage engineMessage = EngineMessage.BONDS_UPDATED_AND_REMOVED_SIMULTANEOUSLY;
assertThat(validator.bondNotUpdatedAndRemovedSimultaneously(), failsWith(engineMessage, ReplacementUtils.getListVariableAssignmentString(engineMessage, Collections.singletonList(bond.getName()))));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method attachmentAndNicLabelReferenceSameLabelCommonTest.
private void attachmentAndNicLabelReferenceSameLabelCommonTest(boolean referenceSameNic, boolean valid) {
VdsNetworkInterface nic = createNic("nic");
final String labelName = "lbl1";
Network network = createNetworkWithNameAndLabel("net", labelName);
NetworkAttachment attachment = createNetworkAttachment(network, nic);
NicLabel nicLabel = referenceSameNic ? new NicLabel(nic.getId(), nic.getName(), labelName) : new NicLabel(Guid.newGuid(), nic.getName() + "not", labelName);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addLabels(nicLabel)).addNetworks(network).addExistingInterfaces(nic).build();
if (valid) {
assertThat(validator.validateAttachmentAndNicReferenceSameLabelNotConflict(attachment), isValid());
} else {
EngineMessage engineMessage = EngineMessage.NETWORK_SHOULD_BE_ATTACHED_VIA_LABEL_TO_ANOTHER_NIC;
assertThat(validator.validateAttachmentAndNicReferenceSameLabelNotConflict(attachment), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, network.getName()), ReplacementUtils.createSetVariableString("nicName", attachment.getNicName()), ReplacementUtils.createSetVariableString("labeledNicName", nicLabel.getNicName())));
}
}
Aggregations