Search in sources :

Example 31 with HostNicVfsConfig

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

the class RefreshHostDevicesCommand method createHostNicVfsConfigToAddIfNotExist.

private HostNicVfsConfig createHostNicVfsConfigToAddIfNotExist(HostDevice device) {
    VdsNetworkInterface nic = networkDeviceHelper.getNicByPciDevice(device, fetchedMap.values());
    if (nic == null) {
        return null;
    }
    HostNicVfsConfig existingHostNicVfsConfig = hostNicVfsConfigDao.getByNicId(nic.getId());
    if (existingHostNicVfsConfig != null) {
        return null;
    }
    return new HostNicVfsConfig(Guid.newGuid(), nic.getId(), true);
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 32 with HostNicVfsConfig

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

the class RefreshHostDevicesCommand method removeInvalidHostNicVfsConfigsFromDb.

private void removeInvalidHostNicVfsConfigsFromDb() {
    final List<HostNicVfsConfig> hostNicVfsConfigsToRemove = new ArrayList<>();
    List<HostNicVfsConfig> hostNicVfsConfigs = hostNicVfsConfigDao.getAllVfsConfigByHostId(getVdsId());
    for (HostNicVfsConfig hostNicVfsConfig : hostNicVfsConfigs) {
        VdsNetworkInterface nic = interfaceDao.get(hostNicVfsConfig.getNicId());
        HostDevice pciDevice = null;
        if (nic != null) {
            String pciDeviceName = networkDeviceHelper.getPciDeviceNameByNic(nic);
            pciDevice = fetchedMap.get(pciDeviceName);
        }
        if (nic == null || pciDevice == null || !networkDeviceHelper.isSriovDevice(pciDevice)) {
            addToListIfNotNull(hostNicVfsConfig, hostNicVfsConfigsToRemove);
        }
    }
    if (!hostNicVfsConfigsToRemove.isEmpty()) {
        hostNicVfsConfigDao.removeAllInBatch(hostNicVfsConfigsToRemove);
    }
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 33 with HostNicVfsConfig

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

the class BackendHostNicResource method updateVirtualFunctionsConfiguration.

@Override
public Response updateVirtualFunctionsConfiguration(Action action) {
    validateParameters(action, "virtualFunctionsConfiguration.numberOfVirtualFunctions|allNetworksAllowed");
    final HostNicVfsConfig vfsConfig = parent.findVfsConfig(guid);
    if (vfsConfig == null) {
        return notAllowed(localize(Messages.INVALID_OPERATION_ON_NON_SRIOV_NIC), guid.toString());
    }
    UpdateHostNicVfsConfigParameters params = prepareUpdateHostNicVfsConfigParameters(action, vfsConfig);
    return doAction(ActionType.UpdateHostNicVfsConfig, params, action);
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) UpdateHostNicVfsConfigParameters(org.ovirt.engine.core.common.action.UpdateHostNicVfsConfigParameters)

Example 34 with HostNicVfsConfig

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

the class BackendHostNicResource method prepareUpdateHostNicVfsConfigParameters.

private UpdateHostNicVfsConfigParameters prepareUpdateHostNicVfsConfigParameters(Action action, HostNicVfsConfig vfsConfig) {
    final Mapper<HostNicVfsConfig, UpdateHostNicVfsConfigParameters> entityMapper = getMapper(HostNicVfsConfig.class, UpdateHostNicVfsConfigParameters.class);
    UpdateHostNicVfsConfigParameters params = entityMapper.map(vfsConfig, new UpdateHostNicVfsConfigParameters());
    final Mapper<org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration, UpdateHostNicVfsConfigParameters> userInputMapper = getMapper(org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration.class, UpdateHostNicVfsConfigParameters.class);
    userInputMapper.map(action.getVirtualFunctionsConfiguration(), params);
    return params;
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) UpdateHostNicVfsConfigParameters(org.ovirt.engine.core.common.action.UpdateHostNicVfsConfigParameters)

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