Search in sources :

Example 81 with VdsNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface 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 82 with VdsNetworkInterface

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

the class UnmanagedNetworkValidatorTest method testFilterNicsWithUnmanagedNetworks.

@Test
public void testFilterNicsWithUnmanagedNetworks() {
    VdsNetworkInterface nicManaged = createNicWithNetworkImplementationDetails("eth0", true);
    VdsNetworkInterface nicUnmanaged = createNicWithNetworkImplementationDetails("eth1", false);
    List<VdsNetworkInterface> existingInterfaces = Arrays.asList(nicManaged, nicUnmanaged);
    Set<String> unmanagedNicsSet = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
    assertEquals(1, unmanagedNicsSet.size());
    assertTrue(unmanagedNicsSet.contains("eth1"));
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 83 with VdsNetworkInterface

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

the class VfSchedulerImplTest method updateVfsConfig.

private HostDevice updateVfsConfig(HostNicVfsConfig hostNicVfsConfig, VmNetworkInterface vnic, int numOfVfs, boolean allNetworksAllowed, boolean vnicNetworkInSriovConfig, boolean vnicLabelInSriovConfig, boolean hasFreeVf, boolean freeVfShareIommuGroup, boolean vfDirectlyAttached) {
    hostNicVfsConfig.setNicId(Guid.newGuid());
    hostNicVfsConfig.setNumOfVfs(numOfVfs);
    hostNicVfsConfig.setAllNetworksAllowed(allNetworksAllowed);
    updateVfsConfigNetworks(hostNicVfsConfig, vnic, vnicNetworkInSriovConfig);
    updateVfsConfigLabels(hostNicVfsConfig, vnic, vnicLabelInSriovConfig);
    VdsNetworkInterface nic = new VdsNetworkInterface();
    nic.setId(hostNicVfsConfig.getNicId());
    when(getNic(hostNicVfsConfig)).thenReturn(nic);
    HostDevice vf = null;
    if (hasFreeVf) {
        vf = createFreeVf(hostNicVfsConfig);
        mockVfShareIommuGroup(vf, freeVfShareIommuGroup);
        if (!freeVfShareIommuGroup && (allNetworksAllowed || vnicNetworkInSriovConfig || vnicLabelInSriovConfig)) {
            if (!vfDirectlyAttached) {
                expectedVnicToVfMap.put(vnic.getId(), vf.getDeviceName());
            }
            mockVfDirectlyAttached(vfDirectlyAttached, vf);
        }
    }
    return vf;
}
Also used : HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 84 with VdsNetworkInterface

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

the class HostSetupNetworksValidatorTest method testValidateModifiedBondSlavesWhenSlaveAlreadySlavesForDifferentBondWhichGetsRemoved.

@Test
public void testValidateModifiedBondSlavesWhenSlaveAlreadySlavesForDifferentBondWhichGetsRemoved() throws Exception {
    Bond bond = createBond("bondName");
    Bond differentBond = createBond("differentBond");
    VdsNetworkInterface slaveA = createBondSlave(bond, "slaveA");
    VdsNetworkInterface slaveB = createBondSlave(differentBond, "slaveB");
    setBondSlaves(bond, slaveA, slaveB);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(differentBond.getId())).addExistingInterfaces(bond, differentBond, slaveA, slaveB).build();
    doTestValidateModifiedBondSlaves(spy(validator), ValidationResult.VALID, ValidationResult.VALID, isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Test(org.junit.Test)

Example 85 with VdsNetworkInterface

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

the class HostSetupNetworksValidatorTest method validateSlaveHasNoLabelsOldLabelWasRemovedValid.

@Test
public void validateSlaveHasNoLabelsOldLabelWasRemovedValid() {
    final String removedLabelName = "lbl1";
    VdsNetworkInterface slave = createNic("slave");
    slave.setLabels(Collections.singleton(removedLabelName));
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedLabels(removedLabelName)).addExistingInterfaces(slave).build();
    assertThat(validator.validateSlaveHasNoLabels(slave.getName()), isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)233 Test (org.junit.Test)68 Network (org.ovirt.engine.core.common.businessentities.network.Network)47 ArrayList (java.util.ArrayList)46 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)35 Guid (org.ovirt.engine.core.compat.Guid)30 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)24 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)23 List (java.util.List)19 HashMap (java.util.HashMap)18 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)18 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)17 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)16 VDS (org.ovirt.engine.core.common.businessentities.VDS)15 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)14 Nic (org.ovirt.engine.core.common.businessentities.network.Nic)13 Map (java.util.Map)12 HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)9 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)8 Vlan (org.ovirt.engine.core.common.businessentities.network.Vlan)8