Search in sources :

Example 16 with Network

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

the class IscsiBondValidatorTest method addedLogicalNetworkBelongToAnotherDatacenter2.

@Test
public void addedLogicalNetworkBelongToAnotherDatacenter2() {
    Guid dataCenterId = Guid.newGuid();
    IscsiBond before = createIscsiBond("Before", dataCenterId);
    IscsiBond after = createIscsiBond("After", dataCenterId);
    List<Network> networks = new ArrayList<>();
    networks.add(createNetwork(dataCenterId));
    doReturn(networks).when(networkDao).getAllForDataCenter(dataCenterId);
    before.getNetworkIds().add(networks.get(0).getId());
    after.getNetworkIds().add(networks.get(0).getId());
    after.getNetworkIds().add(Guid.newGuid());
    ValidationResult res = validator.validateAddedLogicalNetworks(after, before);
    assertThat(res, failsWith(EngineMessage.NETWORKS_DONT_EXIST_IN_DATA_CENTER));
    assertEquals(2, res.getVariableReplacements().size());
    assertEquals("$networkIds " + after.getNetworkIds().get(1).toString(), res.getVariableReplacements().get(0));
    assertEquals("$dataCenterId " + after.getStoragePoolId().toString(), res.getVariableReplacements().get(1));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 17 with Network

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

the class NetworkAttachmentValidatorTest method testNetworkNotAttachedToHostWhenAttached.

@Test
public void testNetworkNotAttachedToHostWhenAttached() {
    Network network = createNetwork();
    when(networkDaoMock.get(network.getId())).thenReturn(network);
    when(vdsDaoMock.getAllForNetwork(eq(network.getId()))).thenReturn(Collections.singletonList(host));
    String networkName = NETWORK_NAME;
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(network.getId());
    attachment.setNetworkName(networkName);
    assertThat(createNetworkAttachmentValidator(attachment).networkNotAttachedToHost(), failsWith(EngineMessage.NETWORK_ALREADY_ATTACHED_TO_HOST, ReplacementUtils.createSetVariableString(NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(HOST_NAME, host.getName())));
}
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 18 with Network

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

the class NetworkAttachmentValidatorTest method testNetworkNotAttachedToHost.

@Test
public void testNetworkNotAttachedToHost() {
    Network network = createNetwork();
    when(networkDaoMock.get(network.getId())).thenReturn(network);
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(network.getId());
    assertThat(createNetworkAttachmentValidator(attachment).networkNotAttachedToHost(), isValid());
}
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 19 with Network

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

the class NetworkAttachmentValidatorTest method testNotExternalNetwork.

@Test
public void testNotExternalNetwork() {
    Network notExternalNetwork = new Network();
    notExternalNetwork.setId(Guid.newGuid());
    notExternalNetwork.setProvidedBy(null);
    when(networkDaoMock.get(eq(notExternalNetwork.getId()))).thenReturn(notExternalNetwork);
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(notExternalNetwork.getId());
    NetworkAttachmentValidator validator = createNetworkAttachmentValidator(attachment);
    assertThat(validator.notExternalNetwork(), isValid());
}
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 20 with Network

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

the class NetworkAttachmentValidatorTest method testNetworkAttachedToClusterWhenNotAttached.

@Test
public void testNetworkAttachedToClusterWhenNotAttached() {
    Network network = new Network();
    network.setId(Guid.newGuid());
    network.setName(NETWORK_NAME);
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(network.getId());
    attachment.setNetworkName(network.getName());
    EngineMessage engineMessage = EngineMessage.NETWORK_OF_GIVEN_NAME_NOT_EXISTS_IN_CLUSTER;
    assertThat(createNetworkAttachmentValidator(attachment).networkAttachedToCluster(), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, network.getName())));
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) 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