Search in sources :

Example 1 with HostNetworkQosValidator

use of org.ovirt.engine.core.bll.validator.HostNetworkQosValidator in project ovirt-engine by oVirt.

the class HostSetupNetworksValidatorTest method testValidateQosOverriddenInterfacesWhenAttachmentHasQosOverriddenAndRequiredValuesNotPresent.

@Test
public void testValidateQosOverriddenInterfacesWhenAttachmentHasQosOverriddenAndRequiredValuesNotPresent() {
    EngineMessage hostNetworkQosValidatorFailure = EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_SETUP_NETWORKS_MISSING_VALUES;
    Network network = createNetworkWithName("network");
    HostSetupNetworksValidator validator = createValidatorForTestingValidateQosOverridden(network);
    HostSetupNetworksValidator validatorSpy = spy(validator);
    HostNetworkQosValidator hostNetworkQosValidatorMock = mock(HostNetworkQosValidator.class);
    when(hostNetworkQosValidatorMock.requiredQosValuesPresentForOverriding(eq(network.getName()))).thenReturn(new ValidationResult(hostNetworkQosValidatorFailure));
    doReturn(hostNetworkQosValidatorMock).when(validatorSpy).createHostNetworkQosValidator(any());
    assertThat(validatorSpy.validateQosOverriddenInterfaces(), ValidationResultMatchers.failsWith(hostNetworkQosValidatorFailure));
    verify(hostNetworkQosValidatorMock).requiredQosValuesPresentForOverriding(eq(network.getName()));
    verifyNoMoreInteractions(hostNetworkQosValidatorMock);
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) HostNetworkQosValidator(org.ovirt.engine.core.bll.validator.HostNetworkQosValidator) Test(org.junit.Test)

Example 2 with HostNetworkQosValidator

use of org.ovirt.engine.core.bll.validator.HostNetworkQosValidator in project ovirt-engine by oVirt.

the class HostSetupNetworksValidatorTest method testValidateQosOverriddenInterfacesWhenAttachmentHasQosOverriddenAndRequiredValuesPresentButInconsistent.

@Test
public void testValidateQosOverriddenInterfacesWhenAttachmentHasQosOverriddenAndRequiredValuesPresentButInconsistent() {
    EngineMessage hostNetworkQosValidatorFailure = EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_INCONSISTENT_VALUES;
    Network network = createNetworkWithName("network");
    HostSetupNetworksValidator validator = createValidatorForTestingValidateQosOverridden(network);
    HostSetupNetworksValidator validatorSpy = spy(validator);
    HostNetworkQosValidator hostNetworkQosValidatorMock = mock(HostNetworkQosValidator.class);
    when(hostNetworkQosValidatorMock.valuesConsistent(eq(network.getName()))).thenReturn(new ValidationResult(hostNetworkQosValidatorFailure));
    doReturn(hostNetworkQosValidatorMock).when(validatorSpy).createHostNetworkQosValidator(any());
    assertThat(validatorSpy.validateQosOverriddenInterfaces(), ValidationResultMatchers.failsWith(hostNetworkQosValidatorFailure));
    verify(hostNetworkQosValidatorMock).requiredQosValuesPresentForOverriding(eq(network.getName()));
    verify(hostNetworkQosValidatorMock).valuesConsistent(eq(network.getName()));
    verifyNoMoreInteractions(hostNetworkQosValidatorMock);
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) HostNetworkQosValidator(org.ovirt.engine.core.bll.validator.HostNetworkQosValidator) Test(org.junit.Test)

Example 3 with HostNetworkQosValidator

use of org.ovirt.engine.core.bll.validator.HostNetworkQosValidator in project ovirt-engine by oVirt.

the class HostSetupNetworksValidator method validateQosOverriddenInterfaces.

/**
 * Validates that the feature is supported if any QoS configuration was specified, and that the values associated
 * with it are valid.
 */
ValidationResult validateQosOverriddenInterfaces() {
    for (NetworkAttachment networkAttachment : params.getNetworkAttachments()) {
        if (networkAttachment.isQosOverridden()) {
            Network network = getNetworkRelatedToAttachment(networkAttachment);
            String networkName = network.getName();
            HostNetworkQos hostNetworkQos = HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos());
            HostNetworkQosValidator qosValidator = createHostNetworkQosValidator(hostNetworkQos);
            ValidationResult requiredValuesPresent = qosValidator.requiredQosValuesPresentForOverriding(networkName);
            if (!requiredValuesPresent.isValid()) {
                return requiredValuesPresent;
            }
            ValidationResult valuesConsistent = qosValidator.valuesConsistent(networkName);
            if (!valuesConsistent.isValid()) {
                return valuesConsistent;
            }
        }
    }
    return ValidationResult.VALID;
}
Also used : HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) HostNetworkQosValidator(org.ovirt.engine.core.bll.validator.HostNetworkQosValidator)

Aggregations

ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)3 HostNetworkQosValidator (org.ovirt.engine.core.bll.validator.HostNetworkQosValidator)3 Network (org.ovirt.engine.core.common.businessentities.network.Network)3 Test (org.junit.Test)2 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)2 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)1