Search in sources :

Example 96 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method initValidator.

private HostSetupNetworksValidator initValidator() {
    Network network = addNewNetworkToDaoMock();
    VdsNetworkInterface vdsNetworkInterface = createNic(HostSetupNetworksValidator.VAR_INTERFACE_NAME);
    NetworkAttachment networkAttachment = createNetworkAttachment(network, vdsNetworkInterface, null);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(network).addExistingInterfaces(vdsNetworkInterface).build();
    return validator;
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 97 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testGetAttachmentsToConfigureWhenUpdatingNetworkAttachments.

@Test
public void testGetAttachmentsToConfigureWhenUpdatingNetworkAttachments() throws Exception {
    Network networkA = createNetworkWithName("networkA");
    Network networkB = createNetworkWithName("networkB");
    NetworkAttachment networkAttachmentA = createNetworkAttachment(networkA);
    NetworkAttachment networkAttachmentB = createNetworkAttachment(networkB);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachmentA, networkAttachmentB)).addExistingAttachments(networkAttachmentA, networkAttachmentB).build();
    Collection<NetworkAttachment> attachmentsToConfigure = validator.getAttachmentsToConfigure();
    assertThat(attachmentsToConfigure.size(), is(2));
    assertThat(attachmentsToConfigure.contains(networkAttachmentA), is(true));
    assertThat(attachmentsToConfigure.contains(networkAttachmentB), is(true));
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 98 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testNetworksUniquelyConfiguredOnHostWhenUniquelyConfigured.

@Test
public void testNetworksUniquelyConfiguredOnHostWhenUniquelyConfigured() throws Exception {
    Network networkA = new Network();
    networkA.setId(Guid.newGuid());
    Network networkB = new Network();
    networkB.setId(Guid.newGuid());
    NetworkAttachment networkAttachmentA = createNetworkAttachment(networkA);
    NetworkAttachment networkAttachmentB = createNetworkAttachment(networkB);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addNetworks(Arrays.asList(networkA, networkB)).build();
    assertThat(validator.networksUniquelyConfiguredOnHost(Arrays.asList(networkAttachmentA, networkAttachmentB)), isValid());
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 99 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testValidateQosNotPartiallyConfigured.

private void testValidateQosNotPartiallyConfigured(boolean networkAttachment1HasQos, boolean networkAttachment2HasQos, Matcher<ValidationResult> matcher) {
    VdsNetworkInterface baseNic = createNic("baseNic");
    VdsNetworkInterface vlanNic1 = createVlanNic(baseNic, "vlanNic1", 10);
    VdsNetworkInterface vlanNic2 = createVlanNic(baseNic, "vlanNic2", 11);
    Network network1 = createNetworkWithName("network1");
    Network network2 = createNetworkWithName("network2");
    NetworkAttachment networkAttachment1 = createNetworkAttachment(network1, baseNic);
    NetworkAttachment networkAttachment2 = createNetworkAttachment(network2, baseNic);
    AnonymousHostNetworkQos qos = createHostNetworkQos(10, 10, 10);
    if (networkAttachment1HasQos) {
        networkAttachment1.setHostNetworkQos(qos);
    }
    if (networkAttachment2HasQos) {
        networkAttachment2.setHostNetworkQos(qos);
    }
    Collection<NetworkAttachment> networkAttachments = Arrays.asList(networkAttachment1, networkAttachment2);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addNetworks(network1, network2).addExistingInterfaces(baseNic, vlanNic1, vlanNic2).build();
    assertThat(validator.validateQosNotPartiallyConfigured(networkAttachments), matcher);
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 100 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testNotRemovingLabeledNetworksWhenNicNameDoesNotReferenceExistingNicItsOkToRemove.

@Test
public void testNotRemovingLabeledNetworksWhenNicNameDoesNotReferenceExistingNicItsOkToRemove() throws Exception {
    Network labeledNetwork = new Network();
    labeledNetwork.setId(Guid.newGuid());
    labeledNetwork.setLabel("label");
    NetworkAttachment networkAttachment = createNetworkAttachment(labeledNetwork);
    networkAttachment.setNicName("noLongerExistingNicName");
    VdsNetworkInterface existingNic = new VdsNetworkInterface();
    existingNic.setName("existingNicName");
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addNetworks(Collections.singletonList(labeledNetwork)).build();
    assertThat(validator.notRemovingLabeledNetworks(networkAttachment), isValid());
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) 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