use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.
the class UpdateHostNicVfsConfigCommand method executeCommand.
@Override
protected void executeCommand() {
boolean result = true;
HostNicVfsConfig oldVfsConfig = getVfsConfig();
boolean allNetworksAllowedChanged = isAllNetworksAllowed() != oldVfsConfig.isAllNetworksAllowed();
super.executeCommand();
// Check if 'allNetworksAllowed' has changed
if (allNetworksAllowedChanged) {
oldVfsConfig.setAllNetworksAllowed(isAllNetworksAllowed());
if (isAllNetworksAllowed()) {
oldVfsConfig.setNetworks(Collections.emptySet());
oldVfsConfig.setNetworkLabels(Collections.emptySet());
}
}
boolean shouldRefreshHost = false;
if (wasNumOfVfsChanged()) {
shouldRefreshHost = true;
String deviceName = networkDeviceHelper.getPciDeviceNameByNic(getNic());
try {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.HostDevChangeNumVfs, new HostDevChangeNumVfsVDSParameters(getVdsId(), deviceName, getNumOfVfs()));
result = returnValue.getSucceeded();
} catch (EngineException e) {
throw new EngineException(EngineError.UPDATE_NUM_VFS_FAILURE);
}
}
if (result) {
setSucceeded(saveChangesToDb(shouldRefreshHost, oldVfsConfig, allNetworksAllowedChanged));
}
}
use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.
the class UpdateHostNicVfsConfigCommand method getVfsConfig.
@Override
public HostNicVfsConfig getVfsConfig() {
HostNicVfsConfig tmpVfsConfig = super.getVfsConfig();
if (hostNicVfsConfig == null) {
networkDeviceHelper.updateHostNicVfsConfigWithNumVfsData(tmpVfsConfig);
}
hostNicVfsConfig = tmpVfsConfig;
return hostNicVfsConfig;
}
use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.
the class VfSchedulerImpl method validatePassthroughVnics.
@Override
public List<String> validatePassthroughVnics(Guid vmId, Guid hostId, List<VmNetworkInterface> allVmNics) {
List<VmNetworkInterface> pluggedPassthroughVnics = getPluggedPassthroughVnics(allVmNics);
if (pluggedPassthroughVnics.isEmpty()) {
return Collections.emptyList();
}
Map<Guid, Map<Guid, String>> hostToVnicToVfMap = vmToHostToVnicToVfMap.get(vmId);
if (hostToVnicToVfMap == null) {
hostToVnicToVfMap = new HashMap<>();
vmToHostToVnicToVfMap.put(vmId, hostToVnicToVfMap);
}
Map<Guid, List<String>> nicToUsedVfs = new HashMap<>();
Map<Guid, VdsNetworkInterface> fetchedNics = new HashMap<>();
List<String> problematicVnics = new ArrayList<>();
List<HostNicVfsConfig> vfsConfigs = networkDeviceHelper.getHostNicVfsConfigsWithNumVfsDataByHostId(hostId);
Map<Guid, String> vnicToVfMap = new HashMap<>();
hostToVnicToVfMap.put(hostId, vnicToVfMap);
for (final VmNetworkInterface vnic : pluggedPassthroughVnics) {
String freeVf = findFreeVfForVnic(vfsConfigs, nicToUsedVfs, fetchedNics, vnic.getNetworkName() == null ? null : networkDao.getByNameAndDataCenter(vnic.getNetworkName(), hostDao.get(hostId).getStoragePoolId()), vnic.getVmId(), true);
if (freeVf == null) {
problematicVnics.add(vnic.getName());
} else {
vnicToVfMap.put(vnic.getId(), freeVf);
}
}
return problematicVnics;
}
use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.
the class HostNicVfsConfigDaoTest method testRemoveNetwork.
@Test
public void testRemoveNetwork() {
HostNicVfsConfig vfsConfig = dao.get(FixturesTool.HOST_NIC_VFS_CONFIG_NOT_ALL_NETWORKS_ALLOWED_2);
checkNetworks(vfsConfig, 1);
dao.removeNetwork(FixturesTool.HOST_NIC_VFS_CONFIG_NOT_ALL_NETWORKS_ALLOWED_2, vfsConfig.getNetworks().iterator().next());
vfsConfig = dao.get(FixturesTool.HOST_NIC_VFS_CONFIG_NOT_ALL_NETWORKS_ALLOWED_2);
checkNetworks(vfsConfig, 0);
}
use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.
the class HostNicVfsConfigDaoTest method testGetAll.
/**
* Ensures that all hostNicVfsConfig are returned.
*/
@Test
public void testGetAll() {
List<HostNicVfsConfig> result = dao.getAll();
assertNotNull(result);
assertEquals(EXPECTED_GUIDS.size(), result.size());
for (HostNicVfsConfig vfsConfig : result) {
assertTrue(EXPECTED_GUIDS.containsKey(vfsConfig.getId()));
Pair<Integer, Integer> expectedConfig = EXPECTED_GUIDS.get(vfsConfig.getId());
checkNetworksAndLabels(vfsConfig, expectedConfig.getFirst(), expectedConfig.getSecond());
}
}
Aggregations