Search in sources :

Example 26 with Network

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

the class NetworkValidatorTest method networkNameTakenByVdsmName.

@Test
public void networkNameTakenByVdsmName() {
    when(network.getName()).thenReturn("vdsm-name");
    when(network.getId()).thenReturn(DEFAULT_GUID);
    Network network2 = new Network();
    network2.setVdsmName("vdsm-name");
    network2.setName("vdsm-name");
    network2.setId(OTHER_GUID);
    when(networkDao.getAllForDataCenter(any())).thenReturn(Arrays.asList(network, network2));
    assertThat(validator.networkNameNotUsedAsVdsmName(), failsWith(EngineMessage.NETWORK_NAME_USED_AS_VDSM_NETWORK_NAME));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) Test(org.junit.Test)

Example 27 with Network

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

the class NetworkValidatorTest method networkNameNotTakenByVdsmName.

@Test
public void networkNameNotTakenByVdsmName() {
    when(network.getName()).thenReturn(DEFAULT_NETWORK_NAME);
    when(network.getId()).thenReturn(DEFAULT_GUID);
    Network network2 = new Network();
    network2.setVdsmName("vdsm-name");
    network2.setId(OTHER_GUID);
    when(networkDao.getAllForDataCenter(any())).thenReturn(Arrays.asList(network, network2));
    assertThat(validator.networkNameNotUsedAsVdsmName(), isValid());
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) Test(org.junit.Test)

Example 28 with Network

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

the class HostInterfaceValidatorTest method testLabeledNetworkAttachedToThisInterfaceWhenNetworkIsAssignedToWrongInterface.

@Test
public void testLabeledNetworkAttachedToThisInterfaceWhenNetworkIsAssignedToWrongInterface() throws Exception {
    String networkName = "networkA";
    Network network = new Network();
    network.setName(networkName);
    VdsNetworkInterface nicToWhichLabeledNetworkShouldBeAttached = createVdsNetworkInterfaceWithName("nicA");
    VdsNetworkInterface nicImproperlyAssignedToNetwork = createVdsNetworkInterfaceWithName("nicB");
    nicImproperlyAssignedToNetwork.setNetworkName(networkName);
    List<VdsNetworkInterface> hostInterfaces = Arrays.asList(nicToWhichLabeledNetworkShouldBeAttached, nicImproperlyAssignedToNetwork);
    HostInterfaceValidator validator = new HostInterfaceValidator(nicToWhichLabeledNetworkShouldBeAttached);
    assertThat(validator.networksAreAttachedToThisInterface(hostInterfaces, Collections.singletonList(network)), failsWith(EngineMessage.LABELED_NETWORK_ATTACHED_TO_WRONG_INTERFACE, ReplacementUtils.replaceWith(HostInterfaceValidator.VAR_ASSIGNED_NETWORKS, Collections.singletonList(networkName))));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 29 with Network

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

the class HostInterfaceValidatorTest method testLabeledNetworkAttachedToThisInterface.

@Test
public void testLabeledNetworkAttachedToThisInterface() throws Exception {
    String networkName = "networkA";
    Network network = new Network();
    network.setName(networkName);
    VdsNetworkInterface nicToWhichLabeledNetworkShouldBeAttached = createVdsNetworkInterfaceWithName("nicA");
    nicToWhichLabeledNetworkShouldBeAttached.setNetworkName(networkName);
    List<VdsNetworkInterface> hostInterfaces = Arrays.asList(nicToWhichLabeledNetworkShouldBeAttached, createVdsNetworkInterfaceWithName("nicB"));
    HostInterfaceValidator validator = new HostInterfaceValidator(nicToWhichLabeledNetworkShouldBeAttached);
    List<Network> clusterNetworksWithLabel = Collections.singletonList(network);
    assertThat(validator.networksAreAttachedToThisInterface(hostInterfaces, clusterNetworksWithLabel), isValid());
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 30 with Network

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

the class UpdateStoragePoolCommandTest method createNetwork.

private Network createNetwork(Guid networkId) {
    Network network = new Network();
    network.setId(networkId);
    return network;
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network)

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