Search in sources :

Example 66 with EngineMessage

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

the class HostInterfaceValidator method nicIsNotLabeledWithSpecifiedLabel.

public ValidationResult nicIsNotLabeledWithSpecifiedLabel(String label) {
    boolean shouldFail = !NetworkUtils.isLabeled(iface) || !iface.getLabels().contains(label);
    EngineMessage engineMessage = EngineMessage.INTERFACE_NOT_LABELED;
    String nicNameReplacement = ReplacementUtils.getVariableAssignmentString(engineMessage, iface.getName());
    String labelReplacement = ReplacementUtils.createSetVariableString(VAR_NIC_LABEL, label);
    return ValidationResult.failWith(engineMessage, nicNameReplacement, labelReplacement).when(shouldFail);
}
Also used : EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 67 with EngineMessage

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

the class HostInterfaceValidator method interfaceIsBondOrNull.

public ValidationResult interfaceIsBondOrNull() {
    String ifaceName = iface == null ? "null" : iface.getName();
    final EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_IS_NOT_BOND;
    return ValidationResult.failWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, ifaceName)).when(iface != null && !iface.isBond());
}
Also used : EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 68 with EngineMessage

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

the class MacAddressValidator method isMacAssignableValidator.

public ValidationResult isMacAssignableValidator() {
    boolean allowDupMacs = macPool.isDuplicateMacAddressesAllowed();
    boolean illegalDuplicateMacUsage = !allowDupMacs && macPool.isMacInUse(macAddress);
    EngineMessage failMessage = EngineMessage.NETWORK_MAC_ADDRESS_IN_USE;
    return ValidationResult.failWith(failMessage, ReplacementUtils.getVariableAssignmentString(failMessage, macAddress)).when(illegalDuplicateMacUsage);
}
Also used : EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 69 with EngineMessage

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

the class ProviderValidatorTest method testValidateReadOnlyActions.

@Test
public void testValidateReadOnlyActions() {
    String providerName = "providerName";
    OpenstackNetworkProviderProperties additionalProperties = new OpenstackNetworkProviderProperties();
    additionalProperties.setReadOnly(true);
    Provider<AdditionalProperties> provider = new Provider<>();
    provider.setAdditionalProperties(additionalProperties);
    provider.setType(ProviderType.EXTERNAL_NETWORK);
    provider.setName(providerName);
    ProviderValidator validator = new ProviderValidator(provider);
    EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_EXTERNAL_PROVIDER_IS_READ_ONLY;
    assertThat(validator.validateReadOnlyActions(), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, providerName)));
    additionalProperties.setReadOnly(false);
    assertThat(validator.validateReadOnlyActions(), isValid());
    provider.setType(ProviderType.OPENSTACK_NETWORK);
    assertThat(validator.validateReadOnlyActions(), isValid());
}
Also used : AdditionalProperties(org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Provider(org.ovirt.engine.core.common.businessentities.Provider) Test(org.junit.Test)

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