Search in sources :

Example 6 with HostDevice

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

the class GetHostDeviceByHostIdAndDeviceNameQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    HostDevice hostDevice = hostDeviceDao.getHostDeviceByHostIdAndDeviceName(getParameters().getHostId(), getParameters().getDeviceName());
    getQueryReturnValue().setReturnValue(hostDevice);
}
Also used : HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice)

Example 7 with HostDevice

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

the class NetworkDeviceHelperImpl method getPciDeviceByNic.

private HostDevice getPciDeviceByNic(final VdsNetworkInterface nic, List<HostDevice> deviceList, Map<String, HostDevice> devicesByName) {
    final String nicName = nic.getName();
    final HostDevice netDevice = deviceList.stream().filter(device -> nicName.equals(device.getNetworkInterfaceName())).findFirst().orElse(null);
    Objects.requireNonNull(netDevice, String.format("Host \"%s\": nic \"%s\" doesn't have a net device", nic.getVdsName(), nicName));
    final String parentDeviceName = netDevice.getParentDeviceName();
    final HostDevice pciDevice = devicesByName.get(parentDeviceName);
    Objects.requireNonNull(pciDevice, String.format("Host \"%s\": net device \"%s\" doesn't have a parent pci device \"%s\"", nic.getVdsName(), netDevice.getName(), parentDeviceName));
    return pciDevice;
}
Also used : HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice)

Example 8 with HostDevice

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

the class NetworkDeviceHelperImpl method updateVfsConfigWithNumOfVfsData.

private void updateVfsConfigWithNumOfVfsData(HostNicVfsConfig hostNicVfsConfig, VdsNetworkInterface nic, List<HostDevice> deviceList) {
    if (nic == null) {
        nic = getNicById(hostNicVfsConfig.getNicId());
    }
    HostDevice pciDevice = getPciDeviceByNic(nic, deviceList);
    hostNicVfsConfig.setMaxNumOfVfs(getMaxNumOfVfs(pciDevice));
    hostNicVfsConfig.setNumOfVfs(getNumOfVfs(pciDevice, deviceList));
}
Also used : HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice)

Example 9 with HostDevice

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

the class NetworkDeviceHelperImpl method getVf.

private HostDevice getVf(VdsNetworkInterface nic, final boolean shouldBeFree, final List<String> excludeVfs) {
    List<HostDevice> deviceList = getDevicesByHostId(nic.getVdsId());
    HostDevice pciDevice = getPciDeviceByNic(nic, deviceList);
    if (pciDevice == null) {
        throw new NullPointerException("nic doesn't have a pci device");
    }
    if (!isSriovDevice(pciDevice)) {
        throw new UnsupportedOperationException("'getVf' method should be called only for 'sriov' nics");
    }
    List<HostDevice> vfs = getVfs(pciDevice, deviceList);
    return vfs.stream().filter(vf -> isVfFree(vf) == shouldBeFree && (excludeVfs == null || !excludeVfs.contains(vf.getDeviceName()))).findFirst().orElse(null);
}
Also used : HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice)

Example 10 with HostDevice

use of org.ovirt.engine.core.common.businessentities.HostDevice 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)

Aggregations

HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)46 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)16 Guid (org.ovirt.engine.core.compat.Guid)14 Map (java.util.Map)11 List (java.util.List)10 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)10 HashMap (java.util.HashMap)9 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)9 Collectors (java.util.stream.Collectors)8 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)7 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)7 HostDeviceDao (org.ovirt.engine.core.dao.HostDeviceDao)7 Arrays (java.util.Arrays)6 Collections (java.util.Collections)6 Objects (java.util.Objects)6 Inject (javax.inject.Inject)6 StringUtils (org.apache.commons.lang.StringUtils)6 VmDeviceGeneralType (org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType)6 VmDeviceDao (org.ovirt.engine.core.dao.VmDeviceDao)6