Search in sources :

Example 21 with VmNumaNode

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;
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

Example 22 with VmNumaNode

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;
}
Also used : Cores(org.ovirt.engine.api.model.Cores) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList) Cpu(org.ovirt.engine.api.model.Cpu) NumaNodePin(org.ovirt.engine.api.model.NumaNodePin) Core(org.ovirt.engine.api.model.Core)

Example 23 with VmNumaNode

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) HashMap(java.util.HashMap) List(java.util.List) ArrayList(java.util.ArrayList)

Example 24 with VmNumaNode

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;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 25 with VmNumaNode

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;
}
Also used : VNodeModel(org.ovirt.engine.ui.uicommonweb.models.hosts.numa.VNodeModel) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList)

Aggregations

VmNumaNode (org.ovirt.engine.core.common.businessentities.VmNumaNode)34 ArrayList (java.util.ArrayList)17 Guid (org.ovirt.engine.core.compat.Guid)9 HashMap (java.util.HashMap)7 List (java.util.List)5 Map (java.util.Map)5 VM (org.ovirt.engine.core.common.businessentities.VM)5 VdsNumaNode (org.ovirt.engine.core.common.businessentities.VdsNumaNode)5 Test (org.junit.Test)4 VmNumaNodeOperationParameters (org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters)4 Arrays (java.util.Arrays)3 Pair (org.ovirt.engine.core.common.utils.Pair)3 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)3 LinkedHashSet (java.util.LinkedHashSet)2 Collectors (java.util.stream.Collectors)2 Named (javax.inject.Named)2 Singleton (javax.inject.Singleton)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1