Search in sources :

Example 6 with Nic

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

the class UnmanagedNetworkValidatorTest method testValidateAttachementsForVlans.

@Test
public void testValidateAttachementsForVlans() {
    String unmanagedBaseNicName = "eth0";
    NetworkAttachment attachement1 = new NetworkAttachment();
    attachement1.setNetworkName("network1");
    attachement1.setNicName(unmanagedBaseNicName);
    NetworkAttachment attachement2 = new NetworkAttachment();
    attachement2.setNetworkName("any2");
    attachement2.setNicName("eth1");
    List<NetworkAttachment> attachementList = Arrays.asList(attachement1, attachement2);
    Nic nic = createNic(unmanagedBaseNicName);
    VdsNetworkInterface vlanNic = createVlanNic(nic, "eth0.100", 100, false);
    List<VdsNetworkInterface> existingInterfaces = Collections.singletonList(vlanNic);
    Set<String> nicsWithUnmanagedNetworks = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
    assertEquals(1, nicsWithUnmanagedNetworks.size());
    String filteredNicName = nicsWithUnmanagedNetworks.iterator().next();
    assertEquals(unmanagedBaseNicName, filteredNicName);
    ValidationResult result = validator.validateAttachements(filteredNicName, attachementList);
    assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_ATTACHEMENT_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(NETWORK, "network1"), ReplacementUtils.createSetVariableString(NIC, "eth0")));
    result = validator.validateAttachements("eth7", attachementList);
    assertTrue(result.isValid());
}
Also used : Nic(org.ovirt.engine.core.common.businessentities.network.Nic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 7 with Nic

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

the class UnmanagedNetworkValidatorTest method testValidateRemovedUnmanagedNetworks.

@Test
public void testValidateRemovedUnmanagedNetworks() {
    String networkName = "networkName";
    Nic nic = createNicWithNetworkImplementationDetails("eth0", false);
    nic.setNetworkName(networkName);
    Network network = new Network();
    network.setName(networkName);
    ValidationResult result = validator.validateRemovedUnmanagedNetworks(Collections.singletonList(networkName), Collections.singletonList(nic), new BusinessEntityMap<>(Collections.emptySet()));
    assertTrue(result.isValid());
    result = validator.validateRemovedUnmanagedNetworks(Collections.singletonList(networkName), Collections.singletonList(nic), new BusinessEntityMap<>(Collections.singletonList(network)));
    assertThat(result, failsWith(EngineMessage.REMOVED_UNMANAGED_NETWORK_IS_A_CLUSTER_NETWORK, ReplacementUtils.createSetVariableString(NETWORK, networkName)));
    String unmanagedNetworkNotPresentOnAnyNic = "unmanagedNetworkNotPresentOnAnyNic";
    result = validator.validateRemovedUnmanagedNetworks(Arrays.asList(networkName, unmanagedNetworkNotPresentOnAnyNic), Collections.singletonList(nic), new BusinessEntityMap<>(Collections.emptySet()));
    assertThat(result, failsWith(EngineMessage.REMOVED_UNMANAGED_NETWORK_DOES_NOT_EXISIT_ON_HOST, ReplacementUtils.createSetVariableString(NETWORK, unmanagedNetworkNotPresentOnAnyNic)));
}
Also used : BusinessEntityMap(org.ovirt.engine.core.common.businessentities.BusinessEntityMap) Network(org.ovirt.engine.core.common.businessentities.network.Network) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 8 with Nic

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

the class UnmanagedNetworkValidatorTest method createNic.

private Nic createNic(String name) {
    Nic nic = new Nic();
    nic.setName(name);
    return nic;
}
Also used : Nic(org.ovirt.engine.core.common.businessentities.network.Nic)

Example 9 with Nic

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

the class UnmanagedNetworkValidatorTest method testValidateLabelsForVlan.

@Test
public void testValidateLabelsForVlan() {
    Nic nic = createNic("eth0");
    NicLabel label = new NicLabel(null, "eth1", "label1");
    NicLabel labelWithUnmanagedNetwork = new NicLabel(null, "eth0", "labelOnUnmanaged");
    Collection<NicLabel> labels = Arrays.asList(label, labelWithUnmanagedNetwork);
    VdsNetworkInterface vlanNic = createVlanNic(nic, "eth0.100", 100, false);
    List<VdsNetworkInterface> existingInterfaces = Collections.singletonList(vlanNic);
    Set<String> nicsWithUnmanagedNetworks = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
    assertEquals(1, nicsWithUnmanagedNetworks.size());
    String vlanNicName = nicsWithUnmanagedNetworks.iterator().next();
    ValidationResult result = validator.validateLabels(vlanNicName, labels);
    assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_LABEL_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(LABEL, "labelOnUnmanaged"), ReplacementUtils.createSetVariableString(NIC, "eth0")));
    NicLabel labelWithoutUnmanaged = new NicLabel(null, "eth_other", "label1");
    Collection<NicLabel> labelsNotOnUnmanagedNetwork = Collections.singletonList(labelWithoutUnmanaged);
    result = validator.validateLabels(vlanNicName, labelsNotOnUnmanagedNetwork);
    assertTrue(result.isValid());
}
Also used : Nic(org.ovirt.engine.core.common.businessentities.network.Nic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 10 with Nic

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

the class UnmanagedNetworkValidatorTest method createNicWithNetworkImplementationDetails.

private Nic createNicWithNetworkImplementationDetails(String name, boolean isManaged) {
    Nic nic = createNic(name);
    NetworkImplementationDetails networkImplementationDetails1 = new NetworkImplementationDetails(true, isManaged);
    nic.setNetworkImplementationDetails(networkImplementationDetails1);
    return nic;
}
Also used : Nic(org.ovirt.engine.core.common.businessentities.network.Nic) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails)

Aggregations

Nic (org.ovirt.engine.core.common.businessentities.network.Nic)13 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)9 Test (org.junit.Test)4 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)4 List (java.util.List)3 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)2 Vlan (org.ovirt.engine.core.common.businessentities.network.Vlan)2 Map (java.util.Map)1 Collectors.joining (java.util.stream.Collectors.joining)1 StringUtils (org.apache.commons.lang.StringUtils)1 Bonding (org.ovirt.engine.api.model.Bonding)1 BootProtocol (org.ovirt.engine.api.model.BootProtocol)1 HostNic (org.ovirt.engine.api.model.HostNic)1 HostNicVirtualFunctionsConfiguration (org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration)1 Ip (org.ovirt.engine.api.model.Ip)1 IpVersion (org.ovirt.engine.api.model.IpVersion)1 Mac (org.ovirt.engine.api.model.Mac)1