Search in sources :

Example 21 with Network

use of org.ovirt.engine.core.common.businessentities.network.Network 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 22 with Network

use of org.ovirt.engine.core.common.businessentities.network.Network 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 23 with Network

use of org.ovirt.engine.core.common.businessentities.network.Network 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)

Example 24 with Network

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

the class NetworkAttachmentsValidatorTest method createNetworkWithIdAndName.

private Network createNetworkWithIdAndName(String networkName) {
    Network network = createNetworkWithId();
    network.setName(networkName);
    return network;
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network)

Example 25 with Network

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

the class NetworkAttachmentsValidatorTest method testVerifyUserAttachmentsDoesNotReferenceSameNetworkDuplicatelyWhenNoDuplicates.

@Test
public void testVerifyUserAttachmentsDoesNotReferenceSameNetworkDuplicatelyWhenNoDuplicates() {
    Network networkA = createNetworkWithIdAndName("networkA");
    NetworkAttachment networkAttachmentA = createNetworkAttachment(networkA);
    Network networkB = createNetworkWithIdAndName("networkB");
    NetworkAttachment networkAttachmentB = createNetworkAttachment(networkB);
    List<NetworkAttachment> attachments = Arrays.asList(networkAttachmentA, networkAttachmentB);
    BusinessEntityMap<Network> networksMap = new BusinessEntityMap<>(Arrays.asList(networkA, networkB));
    NetworkAttachmentsValidator validator = new NetworkAttachmentsValidator(attachments, networksMap, networkExclusivenessValidator);
    assertThat(validator.verifyUserAttachmentsDoesNotReferenceSameNetworkDuplicately(), isValid());
}
Also used : BusinessEntityMap(org.ovirt.engine.core.common.businessentities.BusinessEntityMap) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Aggregations

Network (org.ovirt.engine.core.common.businessentities.network.Network)292 Test (org.junit.Test)105 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)63 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)47 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)46 ArrayList (java.util.ArrayList)44 Guid (org.ovirt.engine.core.compat.Guid)44 ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)39 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)23 List (java.util.List)21 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)21 HashMap (java.util.HashMap)19 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)19 Map (java.util.Map)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 VnicProfile (org.ovirt.engine.core.common.businessentities.network.VnicProfile)13 HashSet (java.util.HashSet)9 Set (java.util.Set)9 BusinessEntityMap (org.ovirt.engine.core.common.businessentities.BusinessEntityMap)9 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)9