Alona Kaplan has uploaded a new change for review. Change subject: engine: introduce HostNicVfsConfigHelper ......................................................................
engine: introduce HostNicVfsConfigHelper The helper class contains helper methods that can be used when dealing with HostNicVfsConfig. For example- getHostNicVfsConfigsWithNumVfsDataByHostId, areAllVfsFree and more. Change-Id: I588d619a296cb894f86cce6491337351206e21c2 Signed-off-by: Alona Kaplan <alkap...@redhat.com> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelper.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImpl.java A backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImplTest.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java 5 files changed, 598 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/20/37720/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelper.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelper.java new file mode 100644 index 0000000..a1093af --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelper.java @@ -0,0 +1,72 @@ +package org.ovirt.engine.core.bll.network.host; + +import java.util.List; + +import org.ovirt.engine.core.common.businessentities.HostDevice; +import org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig; +import org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface; +import org.ovirt.engine.core.compat.Guid; + +public interface HostNicVfsConfigHelper { + + /** + * Retrieves the <code>VdsNetworkInterface</code> that the specified <code>pciDevice</code> represents. + * + * @param pciDevice + * @return the <code>VdsNetworkInterface</code> that the specified <code>pciDevice</code> represents. If the device + * is not parent of network interface device or doesn't exist in the VdsInterface table a <code>null</code> + * is returned. + */ + public VdsNetworkInterface getNicByPciDevice(final HostDevice pciDevice); + + /** + * Retrieves whether the specified <code>device</code> is SR-IOV enabled. + * + * @param device + * @return whether the specified <code>device</code> is SR-IOV enabled + */ + public boolean isSriovDevice(HostDevice device); + + /** + * Retrieves whether the specified <code>device</code> represents a physical nic. + * + * @param device + * @return whether the specified <code>device</code> represents a physical nic + */ + public boolean isNetworkDevice(HostDevice device); + + /** + * Adds <code>maxNumOfVfs</code> and <code>numOfVfs</code> info to the <code>hostNicVfsConfig</code> + * + * @param hostNicVfsConfig + */ + public void updateHostNicVfsConfigWithNumVfsData(HostNicVfsConfig hostNicVfsConfig); + + /** + * Retrieves all the HostDevices of the specified host, adds <code>maxNumOfVfs</code> and <code>numOfVfs</code> info + * to each <code>HostDevice</code> + * + * @param hostId + * @return all the HostDevices of the specified host, adds <code>maxNumOfVfs</code> and <code>numOfVfs</code> info + * to each <code>HostDevice</code> + */ + public List<HostNicVfsConfig> getHostNicVfsConfigsWithNumVfsDataByHostId(Guid hostId); + + /** + * Retrieves whether all the VFs on the nic are free to use by a VM + * + * @param nic + * physical SR-IOV enabled nic + * @return whether all the VFs on the nic are free to use by a VM. + * @throws <code>UnsupportedOperationException</code> in case the nic is not SR-IOV enabled + */ + public boolean areAllVfsFree(VdsNetworkInterface nic); + + /** + * Retrieves the pciDevice name of the specified <code>nic</code> + * + * @param nic + * @return the pciDevice name of the specified <code>nic</code> + */ + public String getPciDeviceNameByNic(VdsNetworkInterface nic); +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImpl.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImpl.java new file mode 100644 index 0000000..9ac9995 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImpl.java @@ -0,0 +1,198 @@ +package org.ovirt.engine.core.bll.network.host; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.ovirt.engine.core.common.businessentities.HostDevice; +import org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig; +import org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dao.HostDeviceDao; +import org.ovirt.engine.core.dao.network.HostNicVfsConfigDao; +import org.ovirt.engine.core.dao.network.InterfaceDao; +import org.ovirt.engine.core.utils.NetworkUtils; +import org.ovirt.engine.core.utils.linq.LinqUtils; +import org.ovirt.engine.core.utils.linq.Predicate; + +@Singleton +class HostNicVfsConfigHelperImpl implements HostNicVfsConfigHelper { + + private final InterfaceDao interfaceDao; + private final HostDeviceDao hostDeviceDao; + private final HostNicVfsConfigDao hostNicVfsConfigDao; + + @Inject + HostNicVfsConfigHelperImpl(InterfaceDao interfaceDao, + HostDeviceDao hostDeviceDao, + HostNicVfsConfigDao hostNicVfsConfigDao) { + this.interfaceDao = interfaceDao; + this.hostDeviceDao = hostDeviceDao; + this.hostNicVfsConfigDao = hostNicVfsConfigDao; + } + + @Override + public VdsNetworkInterface getNicByPciDevice(final HostDevice pciDevice) { + final HostDevice netDevice = getNetDeviceByPciDevice(pciDevice); + + if (netDevice == null || !isNetworkDevice(netDevice)) { + return null; + } + + List<VdsNetworkInterface> hostInterfaces = + interfaceDao.getAllInterfacesForVds(netDevice.getHostId()); + + return LinqUtils.firstOrNull(hostInterfaces, new Predicate<VdsNetworkInterface>() { + @Override + public boolean eval(VdsNetworkInterface iface) { + return iface.getName().equals(netDevice.getNetworkInterfaceName()); + } + }); + } + + private HostDevice getNetDeviceByPciDevice(final HostDevice pciDevice) { + return LinqUtils.firstOrNull(getDevicesByHostId(pciDevice.getHostId()), new Predicate<HostDevice>() { + + @Override + public boolean eval(HostDevice device) { + return pciDevice.getDeviceName().equals(device.getParentDeviceName()); + } + }); + } + + @Override + public boolean isSriovDevice(HostDevice device) { + return device.getTotalVirtualFunctions() != null; + } + + @Override + public boolean isNetworkDevice(HostDevice device) { + return device.getNetworkInterfaceName() != null; + } + + @Override + public void updateHostNicVfsConfigWithNumVfsData(HostNicVfsConfig hostNicVfsConfig) { + VdsNetworkInterface nic = getNicById(hostNicVfsConfig.getNicId()); + + updateVfsConfigWithNumOfVfsData(hostNicVfsConfig, + nic, + getDevicesByHostId(nic.getVdsId())); + } + + @Override + public List<HostNicVfsConfig> getHostNicVfsConfigsWithNumVfsDataByHostId(Guid hostId) { + List<HostNicVfsConfig> hostNicVfsConfigList = hostNicVfsConfigDao.getAllVfsConfigByHostId(hostId); + List<HostDevice> deviceList = getDevicesByHostId(hostId); + + for (HostNicVfsConfig hostNicVfsConfig : hostNicVfsConfigList) { + updateVfsConfigWithNumOfVfsData(hostNicVfsConfig, null, deviceList); + } + + return hostNicVfsConfigList; + } + + 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(nic.getName(), pciDevice, deviceList)); + } + + private HostDevice getPciDeviceByNic(final VdsNetworkInterface nic, List<HostDevice> deviceList) { + HostDevice netDevice = LinqUtils.firstOrNull(deviceList, new Predicate<HostDevice>() { + + @Override + public boolean eval(HostDevice device) { + return nic.getName().equals(device.getNetworkInterfaceName()); + } + }); + + if (netDevice != null) { + return hostDeviceDao.getHostDeviceByHostIdAndDeviceName(nic.getVdsId(), + netDevice.getParentDeviceName()); + } + + return null; + } + + private int getMaxNumOfVfs(HostDevice pciDevice) { + return pciDevice.getTotalVirtualFunctions(); + } + + private int getNumOfVfs(final String nicName, HostDevice pciDevice, List<HostDevice> deviceList) { + List<HostDevice> vfs = getVfs(pciDevice, deviceList); + + return vfs.size(); + } + + private VdsNetworkInterface getNicById(Guid nicId) { + return interfaceDao.get(nicId); + } + + private List<HostDevice> getDevicesByHostId(Guid hostId) { + return hostDeviceDao.getHostDevicesByHostId(hostId); + } + + private List<HostDevice> getVfs(final HostDevice pciDevice, List<HostDevice> deviceList) { + return LinqUtils.filter(deviceList, new Predicate<HostDevice>() { + + @Override + public boolean eval(HostDevice device) { + return pciDevice.getDeviceName().equals(device.getParentPhysicalFunction()); + } + }); + } + + @Override + public boolean areAllVfsFree(VdsNetworkInterface nic) { + List<HostDevice> deviceList = getDevicesByHostId(nic.getVdsId()); + HostDevice pciDevice = getPciDeviceByNic(nic, deviceList); + + if (!isSriovDevice(pciDevice)) { + throw new UnsupportedOperationException(); + } + + List<HostDevice> vfs = getVfs(pciDevice, deviceList); + + HostDevice nonFreeVf = LinqUtils.firstOrNull(vfs, new Predicate<HostDevice>() { + + @Override + public boolean eval(HostDevice vf) { + return !isVfFree(vf); + } + }); + + return nonFreeVf == null; + } + + private boolean isVfFree(HostDevice vf) { + // Check if the VF is attached directly to a VM + if (vf.getVmId() != null) { + return false; + } + + // Check that there is no macvtap device on top of the VM- + // nics with macvtap attached are not reported via the getVdsCaps + VdsNetworkInterface vfNic = getNicByPciDevice(vf); + + return vfNic != null && !isNetworkAttached(vfNic) && !isVlanDeviceAttached(vfNic); + } + + private boolean isNetworkAttached(VdsNetworkInterface vfNic) { + return vfNic.getNetworkName() != null; + } + + boolean isVlanDeviceAttached(VdsNetworkInterface vfNic) { + return NetworkUtils.interfaceHasVlan(vfNic, interfaceDao.getAllInterfacesForVds(vfNic.getVdsId())); + } + + public String getPciDeviceNameByNic(VdsNetworkInterface nic) { + return getPciDeviceByNic(nic, getDevicesByHostId(nic.getVdsId())).getDeviceName(); + } +} diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImplTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImplTest.java new file mode 100644 index 0000000..75edbb1 --- /dev/null +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImplTest.java @@ -0,0 +1,314 @@ +package org.ovirt.engine.core.bll.network.host; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.ovirt.engine.core.common.businessentities.HostDevice; +import org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig; +import org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dao.HostDeviceDao; +import org.ovirt.engine.core.dao.network.HostNicVfsConfigDao; +import org.ovirt.engine.core.dao.network.InterfaceDao; + +@RunWith(MockitoJUnitRunner.class) +public class HostNicVfsConfigHelperImplTest { + + private static final String NIC_NAME = "eth1"; + private static final Guid NIC_ID = Guid.newGuid(); + private static final Guid HOST_ID = Guid.newGuid(); + private static final String NET_DEVICE_NAME = "net_device"; + private static final String PCI_DEVICE_NAME = "pci_device"; + private static int TOTAL_NUM_OF_VFS = 7; + + @Mock + private HostDevice netDevice; + + @Mock + private HostDevice pciDevice; + + @Mock + private VdsNetworkInterface nic; + + @Mock + private HostNicVfsConfig hostNicVfsConfig; + + @Mock + private InterfaceDao interfaceDao; + + @Mock + private HostDeviceDao hostDeviceDao; + + @Mock + private HostNicVfsConfigDao hostNicVfsConfigDao; + + private HostNicVfsConfigHelperImpl hostNicVfsConfigHelper; + + @Before + public void setUp() { + hostNicVfsConfigHelper = spy(new HostNicVfsConfigHelperImpl(interfaceDao, hostDeviceDao, hostNicVfsConfigDao)); + + when(netDevice.getHostId()).thenReturn(HOST_ID); + when(netDevice.getDeviceName()).thenReturn(NET_DEVICE_NAME); + when(netDevice.getNetworkInterfaceName()).thenReturn(NIC_NAME); + when(netDevice.getParentDeviceName()).thenReturn(PCI_DEVICE_NAME); + + when(pciDevice.getHostId()).thenReturn(HOST_ID); + when(pciDevice.getDeviceName()).thenReturn(PCI_DEVICE_NAME); + when(hostDeviceDao.getHostDeviceByHostIdAndDeviceName(HOST_ID, PCI_DEVICE_NAME)).thenReturn(pciDevice); + + List<HostDevice> devices = new ArrayList<>(); + devices.add(netDevice); + devices.add(pciDevice); + mockHostDevices(devices); + + when(nic.getId()).thenReturn(NIC_ID); + when(nic.getName()).thenReturn(NIC_NAME); + when(nic.getVdsId()).thenReturn(HOST_ID); + when(interfaceDao.get(NIC_ID)).thenReturn(nic); + when(nic.getName()).thenReturn(NIC_NAME); + + when(hostNicVfsConfig.getNicId()).thenReturn(NIC_ID); + when(hostNicVfsConfigDao.getByNicId(NIC_ID)).thenReturn(hostNicVfsConfig); + } + + @Test + public void getNicByPciDeviceNotParentOfNetDevice() { + assertNull(hostNicVfsConfigHelper.getNicByPciDevice(netDevice)); + } + + @Test + public void getNicByNetDeviceNoNic() { + VdsNetworkInterface newNic = new VdsNetworkInterface(); + newNic.setName(netDevice.getNetworkInterfaceName() + "not"); + mockNics(Collections.singletonList(newNic), false); + + assertNull(hostNicVfsConfigHelper.getNicByPciDevice(pciDevice)); + } + + @Test + public void getNicByNetDeviceValid() { + mockNics(Collections.<VdsNetworkInterface> emptyList(), true); + assertEquals(nic, hostNicVfsConfigHelper.getNicByPciDevice(pciDevice)); + } + + @Test + public void isSriovNetworkDeviceNotSriov() { + commonIsSriovDevice(false); + } + + @Test + public void isSriovNetworkDeviceSriov() { + commonIsSriovDevice(true); + } + + private void commonIsSriovDevice(boolean isSriov) { + when(pciDevice.getTotalVirtualFunctions()).thenReturn(isSriov ? TOTAL_NUM_OF_VFS : null); + + assertEquals(isSriov, hostNicVfsConfigHelper.isSriovDevice(pciDevice)); + } + + @Test + public void isNetworkDevicePossitive() { + assertEquals(false, isNetworkDevice(pciDevice)); + } + + @Test + public void isNetworkDeviceNegtive() { + assertEquals(true, isNetworkDevice(netDevice)); + } + + @Test + public void updateHostNicVfsConfigWithNumVfsData() { + commonUpdateHostNicVfsConfigWithNumVfsData(4); + } + + @Test + public void updateHostNicVfsConfigWithNumVfsDataZeroVfs() { + commonUpdateHostNicVfsConfigWithNumVfsData(0); + } + + private void commonUpdateHostNicVfsConfigWithNumVfsData(int numOfVfs) { + when(pciDevice.getTotalVirtualFunctions()).thenReturn(TOTAL_NUM_OF_VFS); + List<HostDevice> vfs = mockVfsOnNetDevice(numOfVfs); + mockHostDevices(vfs); + + hostNicVfsConfigHelper.updateHostNicVfsConfigWithNumVfsData(hostNicVfsConfig); + + verify(hostNicVfsConfig).setMaxNumOfVfs(TOTAL_NUM_OF_VFS); + verify(hostNicVfsConfig).setNumOfVfs(numOfVfs); + } + + @Test + public void getHostNicVfsConfigsWithNumVfsDataByHostId() { + when(hostNicVfsConfigDao.getAllVfsConfigByHostId(HOST_ID)).thenReturn(Collections.singletonList(hostNicVfsConfig)); + + when(pciDevice.getTotalVirtualFunctions()).thenReturn(TOTAL_NUM_OF_VFS); + List<HostDevice> vfs = mockVfsOnNetDevice(2); + mockHostDevices(vfs); + + List<HostNicVfsConfig> vfsConfigList = + hostNicVfsConfigHelper.getHostNicVfsConfigsWithNumVfsDataByHostId(HOST_ID); + + assertEquals(1, vfsConfigList.size()); + assertEquals(hostNicVfsConfig, vfsConfigList.get(0)); + + verify(hostNicVfsConfig).setMaxNumOfVfs(TOTAL_NUM_OF_VFS); + verify(hostNicVfsConfig).setNumOfVfs(2); + } + + private boolean isNetworkDevice(HostDevice device) { + return hostNicVfsConfigHelper.isNetworkDevice(device); + } + + private List<HostDevice> mockVfsOnNetDevice(int numOfVfs) { + List<HostDevice> vfs = new ArrayList<>(); + + for (int i = 0; i < numOfVfs; ++i) { + HostDevice vfPciDevice = new HostDevice(); + vfPciDevice.setParentPhysicalFunction(pciDevice.getDeviceName()); + vfPciDevice.setDeviceName(String.valueOf(i)); + vfPciDevice.setHostId(HOST_ID); + vfs.add(vfPciDevice); + } + + return vfs; + } + + private void mockHostDevices(List<HostDevice> extraDevices) { + List<HostDevice> devices = new ArrayList<>(); + devices.add(pciDevice); + devices.add(netDevice); + devices.addAll(extraDevices); + + when(hostDeviceDao.getHostDevicesByHostId(HOST_ID)).thenReturn(devices); + } + + @Test + public void areAllVfsFreeNotSriovNic() { + commonIsSriovDevice(false); + try { + hostNicVfsConfigHelper.areAllVfsFree(nic); + } catch (Exception exception) { + assertTrue(exception instanceof UnsupportedOperationException); + } + } + + @Test + public void areAllVfsFreeTrueNoVfs() { + areAllVfsFreeCommon(0, null, null, null, null); + assertTrue(hostNicVfsConfigHelper.areAllVfsFree(nic)); + } + + @Test + public void areAllVfsFreeFalseAttachedToVm() { + areAllVfsFreeCommon(7, true, null, null, null); + assertFalse(hostNicVfsConfigHelper.areAllVfsFree(nic)); + } + + @Test + public void areAllVfsFreeFalseNoNic() { + areAllVfsFreeCommon(6, false, false, null, null); + assertFalse(hostNicVfsConfigHelper.areAllVfsFree(nic)); + } + + @Test + public void areAllVfsFreeFalseHasNetwork() { + areAllVfsFreeCommon(5, false, true, true, null); + assertFalse(hostNicVfsConfigHelper.areAllVfsFree(nic)); + } + + @Test + public void areAllVfsFreeFalseHasVlanDevice() { + areAllVfsFreeCommon(4, false, true, false, true); + assertFalse(hostNicVfsConfigHelper.areAllVfsFree(nic)); + } + + @Test + public void areAllVfsFreeTrue() { + areAllVfsFreeCommon(1, false, true, false, false); + assertTrue(hostNicVfsConfigHelper.areAllVfsFree(nic)); + } + + public void areAllVfsFreeCommon(int numOfVfs, + Boolean vfAttachedToVm, + Boolean vfHasNic, + Boolean networkAttached, + Boolean vlanDeviceAttached) { + List<HostDevice> devices = new ArrayList<>(); + + List<HostDevice> vfs = mockVfsOnNetDevice(numOfVfs); + List<VdsNetworkInterface> nics = new ArrayList<>(); + devices.addAll(vfs); + + for (HostDevice vfPciDevice : vfs) { + HostDevice vfNetDevice = mockNetworkDeviceForPciDevice(vfPciDevice); + devices.add(vfNetDevice); + + if (vfAttachedToVm) { + vfPciDevice.setVmId(Guid.newGuid()); + } else if (vfHasNic) { + VdsNetworkInterface vfNic = mockNicForNetDevice(vfNetDevice); + nics.add(vfNic); + if (networkAttached) { + vfNic.setNetworkName("netName"); + } else { + doReturn(vlanDeviceAttached).when(hostNicVfsConfigHelper).isVlanDeviceAttached(vfNic); + } + } + } + + mockHostDevices(devices); + mockNics(nics, true); + } + + private VdsNetworkInterface mockNicForNetDevice(HostDevice netDeviceParam) { + VdsNetworkInterface nic = new VdsNetworkInterface(); + nic.setVdsId(netDeviceParam.getHostId()); + nic.setName(netDeviceParam.getNetworkInterfaceName()); + + return nic; + } + + private void mockNics(List<VdsNetworkInterface> extraNics, boolean includeDefault) { + List<VdsNetworkInterface> nics = new ArrayList<>(); + + if (includeDefault) { + nics.add(nic); + } + + nics.addAll(extraNics); + + when(interfaceDao.getAllInterfacesForVds(HOST_ID)).thenReturn(nics); + } + + private HostDevice mockNetworkDeviceForPciDevice(HostDevice pciDeviceParam) { + HostDevice mockedNetDevice = new HostDevice(); + mockedNetDevice.setParentDeviceName(pciDeviceParam.getDeviceName()); + mockedNetDevice.setHostId(pciDeviceParam.getHostId()); + mockedNetDevice.setDeviceName(pciDeviceParam.getDeviceName() + "netDevice"); + mockedNetDevice.setNetworkInterfaceName(mockedNetDevice.getDeviceName() + "iface"); + + return mockedNetDevice; + } + + @Test + public void getPciDeviceNameByNic() { + assertEquals(PCI_DEVICE_NAME, hostNicVfsConfigHelper.getPciDeviceNameByNic(nic)); + } +} diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java index 1e01fac..442ba0b 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java @@ -5,8 +5,9 @@ import org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dao.GenericDao; +import org.ovirt.engine.core.dao.MassOperationsDao; -public interface HostNicVfsConfigDao extends GenericDao<HostNicVfsConfig, Guid> { +public interface HostNicVfsConfigDao extends GenericDao<HostNicVfsConfig, Guid>, MassOperationsDao<HostNicVfsConfig, Guid> { /** * Retrieves a list of all the vfsConfig on this host. * Notice: just nics which are SR-IOV enabled have vfsConfig. @@ -21,6 +22,16 @@ List<HostNicVfsConfig> getAllVfsConfigByHostId(Guid hostId); /** + * Retrieves the vfsConfig of the specified nic. + * + * @param nicId + * the id of the nic + * @return the vfsConfig of the specified nic + * + */ + HostNicVfsConfig getByNicId(Guid nicId); + + /** * Attaches a network to the allowed network list of the specified vfs config * * @param vfsConfigId diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java index 48f5bfe..15e5526 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java @@ -10,12 +10,12 @@ import org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; -import org.ovirt.engine.core.dao.DefaultGenericDaoDbFacade; +import org.ovirt.engine.core.dao.MassOperationsGenericDaoDbFacade; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.SingleColumnRowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; -public class HostNicVfsConfigDaoDbFacadeImpl extends DefaultGenericDaoDbFacade<HostNicVfsConfig, Guid> implements HostNicVfsConfigDao { +public class HostNicVfsConfigDaoDbFacadeImpl extends MassOperationsGenericDaoDbFacade<HostNicVfsConfig, Guid> implements HostNicVfsConfigDao { public HostNicVfsConfigDaoDbFacadeImpl() { super("hostNicVfsConfig"); -- To view, visit http://gerrit.ovirt.org/37720 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I588d619a296cb894f86cce6491337351206e21c2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <alkap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches