Search in sources :

Example 86 with NetworkAttachment

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

the class LogicalNetworkModelParametersHelper method prepareSetupNetworksParamsToAttachTo.

public void prepareSetupNetworksParamsToAttachTo(NetworkInterfaceModel targetNic) {
    NetworkAttachment networkAttachment = createAttachmentWhenAttachingTo(targetNic.getOriginalIface());
    networkModel.getSetupModel().getHostSetupNetworksParametersData().addNetworkAttachmentToParameters(networkAttachment);
}
Also used : NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 87 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method createNetworkAttachment.

private NetworkAttachment createNetworkAttachment(Network network, Guid id) {
    NetworkAttachment networkAttachment = new NetworkAttachment();
    networkAttachment.setId(id);
    networkAttachment.setNetworkId(network.getId());
    networkAttachment.setNetworkName(network.getName());
    return networkAttachment;
}
Also used : NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 88 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testGetAttachmentsToConfigureWhenRemovingNetworkAttachments.

@Test
public void testGetAttachmentsToConfigureWhenRemovingNetworkAttachments() 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(networkAttachmentB).addRemovedNetworkAttachments(networkAttachmentA).build()).addExistingAttachments(Arrays.asList(networkAttachmentA, networkAttachmentB)).addNetworks((Collection<Network>) null).build();
    Collection<NetworkAttachment> attachmentsToConfigure = validator.getAttachmentsToConfigure();
    assertThat(attachmentsToConfigure.size(), is(1));
    assertThat(attachmentsToConfigure.contains(networkAttachmentA), is(false));
    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) Collection(java.util.Collection) ArgumentMatchers.anyCollection(org.mockito.ArgumentMatchers.anyCollection) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 89 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method attachmentAndNicLabelReferenceSameLabelCommonTest.

private void attachmentAndNicLabelReferenceSameLabelCommonTest(boolean referenceSameNic, boolean valid) {
    VdsNetworkInterface nic = createNic("nic");
    final String labelName = "lbl1";
    Network network = createNetworkWithNameAndLabel("net", labelName);
    NetworkAttachment attachment = createNetworkAttachment(network, nic);
    NicLabel nicLabel = referenceSameNic ? new NicLabel(nic.getId(), nic.getName(), labelName) : new NicLabel(Guid.newGuid(), nic.getName() + "not", labelName);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addLabels(nicLabel)).addNetworks(network).addExistingInterfaces(nic).build();
    if (valid) {
        assertThat(validator.validateAttachmentAndNicReferenceSameLabelNotConflict(attachment), isValid());
    } else {
        EngineMessage engineMessage = EngineMessage.NETWORK_SHOULD_BE_ATTACHED_VIA_LABEL_TO_ANOTHER_NIC;
        assertThat(validator.validateAttachmentAndNicReferenceSameLabelNotConflict(attachment), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, network.getName()), ReplacementUtils.createSetVariableString("nicName", attachment.getNicName()), ReplacementUtils.createSetVariableString("labeledNicName", nicLabel.getNicName())));
    }
}
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) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 90 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method testNotRemovingLabeledNetworksWhenLabelRelatedToRemovedBond.

@Test
public void testNotRemovingLabeledNetworksWhenLabelRelatedToRemovedBond() throws Exception {
    String label = "label";
    String nicName = "nicName";
    Network labeledNetwork = new Network();
    labeledNetwork.setId(Guid.newGuid());
    labeledNetwork.setLabel(label);
    NetworkAttachment networkAttachment = createNetworkAttachment(labeledNetwork);
    networkAttachment.setNicName(nicName);
    bond.setLabels(Collections.singleton(label));
    bond.setName(nicName);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(bond.getId())).addExistingInterfaces(Collections.singletonList(bond)).addExistingAttachments((List<NetworkAttachment>) null).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) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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