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