Search in sources :

Example 1 with Cores

use of org.ovirt.engine.api.model.Cores in project ovirt-engine by oVirt.

the class NumaMapper method map.

@Mapping(from = VdsNumaNode.class, to = NumaNode.class)
public static NumaNode map(VdsNumaNode entity, NumaNode template) {
    NumaNode model = template != null ? template : new NumaNode();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    model.setIndex(entity.getIndex());
    model.setMemory(entity.getMemTotal());
    if (entity.getCpuIds() != null && entity.getCpuIds().size() > 0) {
        Cpu cpu = new Cpu();
        Cores cores = new Cores();
        for (int id : entity.getCpuIds()) {
            Core core = new Core();
            core.setIndex(id);
            cores.getCores().add(core);
        }
        cpu.setCores(cores);
        model.setCpu(cpu);
    }
    if (entity.getNumaNodeDistances() != null && entity.getNumaNodeDistances().size() > 0) {
        model.setNodeDistance(StringUtils.join(entity.getNumaNodeDistances().values(), " "));
    }
    return model;
}
Also used : Cores(org.ovirt.engine.api.model.Cores) Cpu(org.ovirt.engine.api.model.Cpu) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) NumaNode(org.ovirt.engine.api.model.NumaNode) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VirtualNumaNode(org.ovirt.engine.api.model.VirtualNumaNode) Core(org.ovirt.engine.api.model.Core)

Example 2 with Cores

use of org.ovirt.engine.api.model.Cores in project ovirt-engine by oVirt.

the class V3CPUInAdapter method adapt.

@Override
public Cpu adapt(V3CPU from) {
    Cpu to = new Cpu();
    if (from.isSetArchitecture()) {
        to.setArchitecture(Architecture.fromValue(from.getArchitecture()));
    }
    if (from.isSetCores()) {
        to.setCores(new Cores());
        to.getCores().getCores().addAll(adaptIn(from.getCores().getCore()));
    }
    if (from.isSetCpuTune()) {
        to.setCpuTune(adaptIn(from.getCpuTune()));
    }
    if (from.isSetLevel()) {
        to.setLevel(from.getLevel());
    }
    if (from.isSetMode()) {
        try {
            to.setMode(CpuMode.fromValue(from.getMode()));
        } catch (InvalidEnumValueException exception) {
            // In version 3 of the API invalid values were accepted, and they meant "disable passthrough". We need
            // to preserve that, but we also need to pass to version 4 a valid value, as otherwise it won't do any
            // update to the attribute. As both "custom" and "host_model" mean exactly the same we can use any of
            // them.
            to.setMode(CpuMode.CUSTOM);
        }
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetSpeed()) {
        to.setSpeed(from.getSpeed());
    }
    if (from.isSetTopology()) {
        to.setTopology(adaptIn(from.getTopology()));
    }
    if (from.isSetId()) {
        to.setType(from.getId());
    }
    return to;
}
Also used : Cores(org.ovirt.engine.api.model.Cores) InvalidEnumValueException(org.ovirt.engine.api.utils.InvalidEnumValueException) Cpu(org.ovirt.engine.api.model.Cpu)

Example 3 with Cores

use of org.ovirt.engine.api.model.Cores 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)

Aggregations

Cores (org.ovirt.engine.api.model.Cores)3 Cpu (org.ovirt.engine.api.model.Cpu)3 Core (org.ovirt.engine.api.model.Core)2 VmNumaNode (org.ovirt.engine.core.common.businessentities.VmNumaNode)2 ArrayList (java.util.ArrayList)1 NumaNode (org.ovirt.engine.api.model.NumaNode)1 NumaNodePin (org.ovirt.engine.api.model.NumaNodePin)1 VirtualNumaNode (org.ovirt.engine.api.model.VirtualNumaNode)1 InvalidEnumValueException (org.ovirt.engine.api.utils.InvalidEnumValueException)1 VdsNumaNode (org.ovirt.engine.core.common.businessentities.VdsNumaNode)1