Search in sources :

Example 36 with EngineMessage

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);
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Test(org.junit.Test)

Example 37 with EngineMessage

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));
}
Also used : EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Test(org.junit.Test)

Example 38 with EngineMessage

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;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LinkedList(java.util.LinkedList) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 39 with EngineMessage

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()))));
}
Also used : HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Test(org.junit.Test)

Example 40 with EngineMessage

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())));
    }
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Aggregations

EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)69 Test (org.junit.Test)31 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)27 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)17 Network (org.ovirt.engine.core.common.businessentities.network.Network)16 Guid (org.ovirt.engine.core.compat.Guid)16 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)14 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)13 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Map (java.util.Map)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)6 VM (org.ovirt.engine.core.common.businessentities.VM)6 Version (org.ovirt.engine.core.compat.Version)4 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 Collectors (java.util.stream.Collectors)3 VmWatchdogValidator (org.ovirt.engine.core.bll.validator.VmWatchdogValidator)3 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)3