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);
}
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;
}
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));
}
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);
}
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;
}
Aggregations