Search in sources :

Example 41 with VmNetworkInterface

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

the class VfSchedulerImplTest method validVnicNotPlugged.

@Test
public void validVnicNotPlugged() {
    VmNetworkInterface vnic = mockVnic(true);
    when(vnic.isPlugged()).thenReturn(false);
    initHostWithOneVfsConfig(Collections.singletonList(vnic), 0, true, false, false, false);
    assertHostValid(Collections.singletonList(vnic));
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Test(org.junit.Test)

Example 42 with VmNetworkInterface

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

the class VfSchedulerImplTest method initHostWithOneVfsConfig.

private List<HostDevice> initHostWithOneVfsConfig(List<VmNetworkInterface> passthroughVnics, int numOfVfs, boolean allNetworksAllowed, boolean networkInSriovConfig, boolean labelInSriovConfig, boolean hasFreeVf, boolean freeVfShareIommuGroup, boolean vfDirectlyAttached) {
    HostNicVfsConfig hostNicVfsConfig = new HostNicVfsConfig();
    List<HostDevice> vfs = passthroughVnics.stream().map(vnic -> updateVfsConfig(hostNicVfsConfig, vnic, numOfVfs, allNetworksAllowed, networkInSriovConfig, labelInSriovConfig, hasFreeVf, freeVfShareIommuGroup, vfDirectlyAttached)).collect(Collectors.toList());
    mockVfsConfigsOnHost(Collections.singletonList(hostNicVfsConfig));
    return vfs;
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) Guid(org.ovirt.engine.core.compat.Guid) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) RandomUtils(org.ovirt.engine.core.utils.RandomUtils) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) HashSet(java.util.HashSet) ArgumentMatcher(org.mockito.ArgumentMatcher) VdsDao(org.ovirt.engine.core.dao.VdsDao) Map(java.util.Map) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) Network(org.ovirt.engine.core.common.businessentities.network.Network) RandomStringUtils(org.apache.commons.lang.RandomStringUtils) Before(org.junit.Before) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Assert.assertNotNull(org.junit.Assert.assertNotNull) Test(org.junit.Test) NetworkDao(org.ovirt.engine.core.dao.network.NetworkDao) Mockito.when(org.mockito.Mockito.when) HostDeviceDao(org.ovirt.engine.core.dao.HostDeviceDao) Collectors(java.util.stream.Collectors) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) InterfaceDao(org.ovirt.engine.core.dao.network.InterfaceDao) Collections(java.util.Collections) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) VDS(org.ovirt.engine.core.common.businessentities.VDS) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice)

Example 43 with VmNetworkInterface

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

the class VfSchedulerImplTest method mockVnic.

private VmNetworkInterface mockVnic(boolean passthrough, String networkName) {
    VmNetworkInterface vnic = mock(VmNetworkInterface.class);
    when(vnic.getId()).thenReturn(Guid.newGuid());
    when(vnic.getName()).thenReturn(getRandomString());
    when(vnic.isPassthrough()).thenReturn(passthrough);
    Network network = createNetwork(networkName);
    when(vnic.getNetworkName()).thenReturn(network.getName());
    when(vnic.isPlugged()).thenReturn(true);
    when(vnic.getVmId()).thenReturn(vmId);
    return vnic;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Network(org.ovirt.engine.core.common.businessentities.network.Network)

Example 44 with VmNetworkInterface

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

the class VfSchedulerImplTest method cleanVmDataTest.

@Test
public void cleanVmDataTest() {
    VmNetworkInterface vnic = mockVnic(true);
    initHostWithOneVfsConfig(Collections.singletonList(vnic), 1, true, false, false, true);
    assertHostValid(Collections.singletonList(vnic));
    vfScheduler.cleanVmData(vmId);
    assertNull(vfScheduler.getVnicToVfMap(vmId, hostId));
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Test(org.junit.Test)

Example 45 with VmNetworkInterface

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

the class VfSchedulerImplTest method hostNicNotHaveVfsOnSriovNic.

@Test
public void hostNicNotHaveVfsOnSriovNic() {
    VmNetworkInterface vnic = mockVnic(true);
    initHostWithOneVfsConfig(Collections.singletonList(vnic), 0, true, false, false, false);
    assertHostNotValid(Collections.singletonList(vnic), Collections.singletonList(vnic.getName()));
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Test(org.junit.Test)

Aggregations

VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)115 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)25 Guid (org.ovirt.engine.core.compat.Guid)19 VM (org.ovirt.engine.core.common.businessentities.VM)16 HashMap (java.util.HashMap)11 List (java.util.List)9 Map (java.util.Map)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)6 MapVnicsContext (org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext)5 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)5 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)5 VmNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics)5 Nic (org.ovirt.engine.api.model.Nic)4 VnicProfileHelper (org.ovirt.engine.core.bll.network.vm.VnicProfileHelper)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Collection (java.util.Collection)3