Search in sources :

Example 61 with EngineMessage

use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.

the class MoveMacsTest method canMigrateMacsToAnotherMacPoolWhenMacToBeMigratedAlreadyExistInTargetPool.

@Test
public void canMigrateMacsToAnotherMacPoolWhenMacToBeMigratedAlreadyExistInTargetPool() {
    // first mac will be already used.
    String macUsedInTargetMacPool = macsToMigrate.get(0);
    when(targetMacPool.isMacInUse(macUsedInTargetMacPool)).thenReturn(true);
    when(vmNicDao.getAllMacsByClusterId(cluster.getId())).thenReturn(macsToMigrate);
    EngineMessage engineMessage = ACTION_TYPE_FAILED_CANNOT_MIGRATE_MACS_DUE_TO_DUPLICATES;
    Collection<String> replacements = ReplacementUtils.getListVariableAssignmentString(engineMessage, Collections.singleton(macUsedInTargetMacPool));
    assertThat(underTest.canMigrateMacsToAnotherMacPool(cluster, targetMacPoolId), ValidationResultMatchers.failsWith(engineMessage, replacements));
}
Also used : EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Test(org.junit.Test)

Example 62 with EngineMessage

use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.

the class MoveMacsTest method canMigrateMacsToAnotherMacPoolWhenTheresDuplicityAmongMacToBeMigrated.

@Test
public void canMigrateMacsToAnotherMacPoolWhenTheresDuplicityAmongMacToBeMigrated() {
    // first mac will be duplicated
    macsToMigrate.add(macsToMigrate.get(0));
    when(vmNicDao.getAllMacsByClusterId(cluster.getId())).thenReturn(macsToMigrate);
    EngineMessage engineMessage = ACTION_TYPE_FAILED_CANNOT_MIGRATE_MACS_DUE_TO_DUPLICATES;
    Collection<String> replacements = ReplacementUtils.getListVariableAssignmentString(engineMessage, Collections.singleton(macsToMigrate.get(0)));
    assertThat(underTest.canMigrateMacsToAnotherMacPool(cluster, targetMacPoolId), ValidationResultMatchers.failsWith(engineMessage, replacements));
}
Also used : EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Test(org.junit.Test)

Example 63 with EngineMessage

use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.

the class RunVmOnceCommand method validateImpl.

@Override
protected boolean validateImpl() {
    if (!super.validateImpl()) {
        return false;
    }
    // set (null), the action will fail if only one of those parameters is null.
    if (getParameters().getSysPrepUserName() == null ^ getParameters().getSysPrepPassword() == null) {
        return failValidation(EngineMessage.VM_CANNOT_RUN_ONCE_WITH_ILLEGAL_SYSPREP_PARAM);
    }
    if (getParameters().getVmInit() != null && getParameters().getVmInit().isPasswordAlreadyStored()) {
        VmBase temp = new VmBase();
        temp.setId(getParameters().getVmId());
        vmHandler.updateVmInitFromDB(temp, false);
        getParameters().getVmInit().setRootPassword(temp.getVmInit().getRootPassword());
    }
    List<EngineMessage> msgs = openStackMetadataAdapter.validate(getParameters().getVmInit());
    if (!CollectionUtils.isEmpty(msgs)) {
        return failValidation(msgs);
    }
    return true;
}
Also used : VmBase(org.ovirt.engine.core.common.businessentities.VmBase) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 64 with EngineMessage

use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.

the class NetworkAttachmentsValidator method validateNetworkExclusiveOnNics.

public ValidationResult validateNetworkExclusiveOnNics() {
    Map<String, List<NetworkType>> nicNameToNetworkTypesMap = createNicNameToNetworkTypesMap();
    List<String> violatedNics = findViolatedNics(nicNameToNetworkTypesMap);
    if (violatedNics.isEmpty()) {
        return ValidationResult.VALID;
    } else {
        final EngineMessage violationMessage = networkExclusivenessValidator.getViolationMessage();
        return new ValidationResult(violationMessage, ReplacementUtils.replaceWith(violationMessage + LIST_SUFFIX, violatedNics));
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 65 with EngineMessage

use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.

the class HostInterfaceValidator method interfaceExists.

/**
 * @param nicName name of interface to be reported as a inexisting one.
 * @return validation result
 */
public ValidationResult interfaceExists(String nicName) {
    EngineMessage engineMessage = EngineMessage.HOST_NETWORK_INTERFACE_HAVING_NAME_DOES_NOT_EXIST;
    String nicNameReplacement = ReplacementUtils.getVariableAssignmentString(engineMessage, nicName);
    return ValidationResult.failWith(engineMessage, nicNameReplacement).when(iface == null);
}
Also used : EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

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