use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class MemoryPolicyUnit method canVmNumaPinnedToVds.
private boolean canVmNumaPinnedToVds(VM vm, List<VmNumaNode> nodes, VDS vds) {
List<VdsNumaNode> pNodes = vdsNumaNodeDao.getAllVdsNumaNodeByVdsId(vds.getId());
if (pNodes == null || pNodes.isEmpty()) {
return false;
}
Map<Integer, VdsNumaNode> indexMap = toMap(pNodes);
for (VmNumaNode vNode : nodes) {
for (Integer pinnedIndex : vNode.getVdsNumaNodeList()) {
if (vNode.getMemTotal() > indexMap.get(pinnedIndex).getNumaNodeStatistics().getMemFree()) {
return false;
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaMapper method map.
@Mapping(from = VirtualNumaNode.class, to = VmNumaNode.class)
public static VmNumaNode map(VirtualNumaNode model, VmNumaNode template) {
VmNumaNode entity = template != null ? template : new VmNumaNode();
if (model.isSetId()) {
entity.setId(GuidUtils.asGuid(model.getId()));
}
if (entity.getId() == null) {
entity.setId(Guid.newGuid());
}
if (model.isSetIndex()) {
entity.setIndex(model.getIndex());
}
Cpu cpu = model.getCpu();
if (cpu != null) {
List<Integer> ids = new ArrayList<>();
Cores cores = cpu.getCores();
if (cores != null) {
for (Core core : cores.getCores()) {
Integer index = core.getIndex();
if (index != null) {
ids.add(index);
}
}
}
entity.setCpuIds(ids);
}
if (model.isSetMemory()) {
entity.setMemTotal(model.getMemory());
}
if (model.isSetNumaNodePins()) {
entity.setVdsNumaNodeList(model.getNumaNodePins().getNumaNodePins().stream().map(NumaNodePin::getIndex).collect(Collectors.toList()));
}
return entity;
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaSettingFactory method buildCpuPinningWithNumaSetting.
public static Map<String, Object> buildCpuPinningWithNumaSetting(List<VmNumaNode> vmNodes, List<VdsNumaNode> vdsNodes) {
Map<Integer, List<Integer>> vdsNumaNodeCpus = vdsNodes.stream().collect(Collectors.toMap(VdsNumaNode::getIndex, VdsNumaNode::getCpuIds));
Map<String, Object> cpuPinDict = new HashMap<>();
for (VmNumaNode node : vmNodes) {
List<Integer> pinnedNodeIndexes = node.getVdsNumaNodeList();
if (!pinnedNodeIndexes.isEmpty()) {
Set<Integer> totalPinnedVdsCpus = new LinkedHashSet<>();
for (Integer pinnedVdsNode : pinnedNodeIndexes) {
totalPinnedVdsCpus.addAll(vdsNumaNodeCpus.getOrDefault(pinnedVdsNode, Collections.emptyList()));
}
for (Integer vCpu : node.getCpuIds()) {
cpuPinDict.put(String.valueOf(vCpu), NumaUtils.buildStringFromListForNuma(totalPinnedVdsCpus));
}
}
}
return cpuPinDict;
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaSettingFactory method buildVmNumatuneSetting.
public static Map<String, Object> buildVmNumatuneSetting(NumaTuneMode numaTuneMode, List<VmNumaNode> vmNumaNodes) {
List<Map<String, String>> memNodeList = new ArrayList<>();
for (VmNumaNode node : vmNumaNodes) {
if (node.getVdsNumaNodeList().isEmpty()) {
continue;
}
Map<String, String> memNode = new HashMap<>(2);
memNode.put(VdsProperties.NUMA_TUNE_VM_NODE_INDEX, String.valueOf(node.getIndex()));
memNode.put(VdsProperties.NUMA_TUNE_NODESET, NumaUtils.buildStringFromListForNuma(node.getVdsNumaNodeList()));
memNodeList.add(memNode);
}
// If no node is pinned, leave pinning implicit
if (memNodeList.isEmpty()) {
return Collections.emptyMap();
}
Map<String, Object> createNumaTune = new HashMap<>(2);
createNumaTune.put(VdsProperties.NUMA_TUNE_MEMNODES, memNodeList);
createNumaTune.put(VdsProperties.NUMA_TUNE_MODE, numaTuneMode.getValue());
return createNumaTune;
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaSupportPopupView method getHostSummaryContent.
@Override
public IsWidget getHostSummaryContent(VDS selectedItem, NumaSupportModel supportModel) {
HostSummaryContentPanel contentPanel = hostSummaryContentProvider.get();
List<VM> vmsWithVNuma = supportModel.getVmsWithvNumaNodeList();
List<VNodeModel> numaNodes = new ArrayList<>();
for (VM vm : vmsWithVNuma) {
for (VmNumaNode vmNumaNode : vm.getvNumaNodeList()) {
numaNodes.add(new VNodeModel(vm, vmNumaNode));
}
}
contentPanel.setModel(supportModel.getNumaNodeList(), numaNodes);
return contentPanel;
}
Aggregations