Search in sources :

Example 11 with NetworkAttachment

use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.

the class NetworkAttachmentValidatorTest method testNotRemovingManagementNetwork.

@Test
public void testNotRemovingManagementNetwork() {
    NetworkAttachmentValidator networkAttachmentValidatorSpy = spy(createNetworkAttachmentValidator(new NetworkAttachment()));
    doReturn(networkValidatorMock).when(networkAttachmentValidatorSpy).getNetworkValidator();
    ValidationResult propagatedResult = new ValidationResult(EngineMessage.NETWORK_CANNOT_REMOVE_MANAGEMENT_NETWORK, "a");
    when(networkValidatorMock.notRemovingManagementNetwork()).thenReturn(propagatedResult);
    assertThat("ValidationResult is not propagated correctly", networkAttachmentValidatorSpy.notRemovingManagementNetwork(), is(propagatedResult));
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 12 with NetworkAttachment

use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.

the class NetworkAttachmentValidatorTest method testBootProtocolSetForRoleNetworkWhenBootProtocolIsDhcp.

@Test
public void testBootProtocolSetForRoleNetworkWhenBootProtocolIsDhcp() {
    Network network = createNetwork();
    NetworkAttachment attachment = createNetworkAttachmentWithIpv4Configuration(Ipv4BootProtocol.DHCP);
    attachment.setNetworkId(network.getId());
    doTestBootProtocolSetForRoleNetworkWhenNullValuedIpConfiguration(true, false, false, isValid(), network, attachment);
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 13 with NetworkAttachment

use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.

the class NetworkAttachmentValidatorTest method testNotExternalNetworkWhenExternalNetworkIsProvided.

@Test
public void testNotExternalNetworkWhenExternalNetworkIsProvided() {
    Network externalNetwork = new Network();
    externalNetwork.setId(Guid.newGuid());
    externalNetwork.setProvidedBy(new ProviderNetwork(Guid.newGuid(), ""));
    when(networkDaoMock.get(eq(externalNetwork.getId()))).thenReturn(externalNetwork);
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(externalNetwork.getId());
    assertThat(createNetworkAttachmentValidator(attachment).notExternalNetwork(), failsWith(EngineMessage.EXTERNAL_NETWORK_HAVING_NAME_CANNOT_BE_PROVISIONED));
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 14 with NetworkAttachment

use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.

the class NetworkAttachmentValidatorTest method doTestBootProtocolSetForRoleNetworkWhenNullValuedIpConfiguration.

private void doTestBootProtocolSetForRoleNetworkWhenNullValuedIpConfiguration(boolean displayNetwork, Network network, Matcher<ValidationResult> matcher) {
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setIpConfiguration(null);
    attachment.setNetworkId(network.getId());
    doTestBootProtocolSetForRoleNetworkWhenNullValuedIpConfiguration(displayNetwork, false, false, matcher, network, attachment);
}
Also used : NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 15 with NetworkAttachment

use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.

the class NetworkAttachmentValidatorTest method testBootProtocolSetForRoleNetworkWhenIpConfigurationIsNull.

@Test
public void testBootProtocolSetForRoleNetworkWhenIpConfigurationIsNull() {
    Network network = createNetwork();
    NetworkAttachment attachment = createNetworkAttachmentWithIpv4Configuration(Ipv4BootProtocol.NONE);
    attachment.setNetworkId(network.getId());
    doTestBootProtocolSetForRoleNetworkWhenNullValuedIpConfiguration(true, true, false, failsWith(EngineMessage.ACTION_TYPE_FAILED_ROLE_NETWORK_HAS_NO_BOOT_PROTOCOL, ReplacementUtils.createSetVariableString(NetworkAttachmentValidator.VAR_ACTION_TYPE_FAILED_ROLE_NETWORK_HAS_NO_BOOT_PROTOCOL_ENTITY, network.getName())), network, attachment);
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Aggregations

NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)167 Test (org.junit.Test)79 Network (org.ovirt.engine.core.common.businessentities.network.Network)62 Guid (org.ovirt.engine.core.compat.Guid)37 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)36 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)35 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)20 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)18 HashMap (java.util.HashMap)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)14 ArrayList (java.util.ArrayList)10 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)10 ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)9 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)8 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)7 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)7 AnonymousHostNetworkQos (org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos)6 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)5 BusinessEntityMap (org.ovirt.engine.core.common.businessentities.BusinessEntityMap)5