Search in sources :

Example 1 with HostNicVfsConfig

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

the class VfsConfigAction method onActionExecute.

@Override
protected void onActionExecute() {
    for (HostNicVfsConfig originalVfsConfig : originalVfsConfigs) {
        HostNicVfsConfig updatedVfsConfig = updatedNicToVfsConfig.get(originalVfsConfig.getNicId());
        initUpdateVfsConfigParams(originalVfsConfig, updatedVfsConfig);
        if (!updatedVfsConfig.isAllNetworksAllowed()) {
            initAddedNetworksParams(originalVfsConfig, updatedVfsConfig);
            initRemovedNetworksParams(originalVfsConfig, updatedVfsConfig);
            initAddedLabelsParams(originalVfsConfig, updatedVfsConfig);
            initRemovedLabelsParams(originalVfsConfig, updatedVfsConfig);
        }
    }
    UiAction updateAction = new UiVdcMultipleAction(ActionType.UpdateHostNicVfsConfig, updatedVfsConfigsParams, getModel(), true, false);
    updateAction.then(new UiVdcMultipleAction(ActionType.AddVfsConfigNetwork, addedNetworksParams, getModel())).and(new UiVdcMultipleAction(ActionType.RemoveVfsConfigNetwork, removedNetworksParams, getModel())).and(new UiVdcMultipleAction(ActionType.AddVfsConfigLabel, addedLabelsParams, getModel())).and(new UiVdcMultipleAction(ActionType.RemoveVfsConfigLabel, removedLabelsParams, getModel())).then(getNextAction());
    then(null);
    updateAction.runParallelAction(getActionFlowState());
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) UiVdcMultipleAction(org.ovirt.engine.ui.uicommonweb.action.UiVdcMultipleAction) UiAction(org.ovirt.engine.ui.uicommonweb.action.UiAction) SyncUiAction(org.ovirt.engine.ui.uicommonweb.action.SyncUiAction)

Example 2 with HostNicVfsConfig

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

the class VfSchedulerImpl method findFreeVfForVnic.

/*
     * @param nicToUsedVfs used to calculate all used VFs by given nic.
     * Mapped by nic id. Map<Guid, List<String>> nicToUsedVfs = new HashMap<>();
     * This collection is changed as side-effect of calling this method.
     * @param fetchedNics caching. This collection is changed as side-effect of calling this method.
     * Not to query same nic multiple times from db.
     * Mapped by VdsNetworkInterface.getId() Map<Guid, VdsNetworkInterface> fetchedNics = new HashMap<>();
     */
private String findFreeVfForVnic(List<HostNicVfsConfig> vfsConfigs, Map<Guid, List<String>> nicToUsedVfs, Map<Guid, VdsNetworkInterface> fetchedNics, Network vnicNetwork, Guid vmId, boolean shouldCheckDirectlyAttachedVmDevices) {
    for (HostNicVfsConfig vfsConfig : vfsConfigs) {
        if (vfsConfig.getNumOfVfs() != 0 && isNetworkInVfsConfig(vnicNetwork, vfsConfig)) {
            Guid nicId = vfsConfig.getNicId();
            List<String> skipVfs = new ArrayList<>();
            HostDevice freeVf = getFreeVf(nicId, nicToUsedVfs, fetchedNics, skipVfs);
            while (freeVf != null && (isSharingIommuGroup(freeVf) || (shouldCheckDirectlyAttachedVmDevices && shouldBeDirectlyAttached(freeVf.getName(), vmId)))) {
                skipVfs.add(freeVf.getName());
                freeVf = getFreeVf(nicId, nicToUsedVfs, fetchedNics, skipVfs);
            }
            if (freeVf != null) {
                return freeVf.getName();
            }
        }
    }
    return null;
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with HostNicVfsConfig

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

the class BackendHostNicsResource method doPopulate.

@Override
protected HostNic doPopulate(HostNic model, VdsNetworkInterface entity) {
    final HostNic hostNic = super.doPopulate(model, entity);
    final Guid nicId = entity.getId();
    final HostNicVfsConfig hostNicVfsConfig = findVfsConfig(nicId);
    if (hostNicVfsConfig == null) {
        final Map<Guid, Guid> vfMap = retriveVfMap();
        final Guid physicalFunctionNicId = vfMap.get(nicId);
        if (physicalFunctionNicId != null) {
            final HostNic physicalFunction = new HostNic();
            physicalFunction.setId(physicalFunctionNicId.toString());
            hostNic.setPhysicalFunction(physicalFunction);
        }
    } else {
        final Mapper<HostNicVfsConfig, HostNicVirtualFunctionsConfiguration> mapper = getMapper(HostNicVfsConfig.class, HostNicVirtualFunctionsConfiguration.class);
        final HostNicVirtualFunctionsConfiguration vfsConfigModel = mapper.map(hostNicVfsConfig, new HostNicVirtualFunctionsConfiguration());
        hostNic.setVirtualFunctionsConfiguration(vfsConfigModel);
    }
    return hostNic;
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) HostNicVirtualFunctionsConfiguration(org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration) HostNic(org.ovirt.engine.api.model.HostNic) Guid(org.ovirt.engine.core.compat.Guid)

Example 4 with HostNicVfsConfig

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

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

the class VfSchedulerImplTest method createFreeVf.

private HostDevice createFreeVf(HostNicVfsConfig hostNicVfsConfig) {
    HostDevice vf = createVf();
    ArgumentMatcher<List<String>> matchNotContainVf = argVf -> argVf == null || !argVf.contains(vf.getName());
    when(networkDeviceHelper.getFreeVf(eq(getNic(hostNicVfsConfig)), argThat(matchNotContainVf))).thenReturn(vf);
    return vf;
}
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) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)34 Test (org.junit.Test)13 Guid (org.ovirt.engine.core.compat.Guid)8 ArrayList (java.util.ArrayList)7 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)7 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)5 List (java.util.List)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 Arrays (java.util.Arrays)2 Collectors (java.util.stream.Collectors)2 RandomStringUtils (org.apache.commons.lang.RandomStringUtils)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 Assert.assertNull (org.junit.Assert.assertNull)2 Before (org.junit.Before)2