use of org.ovirt.engine.api.model.VcpuPins in project ovirt-engine by oVirt.
the class VmMapper method stringToCpuTune.
/**
* Maps the stringified CPU-pinning to the API format.
*/
static CpuTune stringToCpuTune(String cpuPinning) {
if (cpuPinning == null || cpuPinning.equals("")) {
return null;
}
final CpuTune cpuTune = new CpuTune();
VcpuPins pins = new VcpuPins();
for (String strCpu : cpuPinning.split("_")) {
VcpuPin pin = stringToVCpupin(strCpu);
pins.getVcpuPins().add(pin);
}
cpuTune.setVcpuPins(pins);
return cpuTune;
}
use of org.ovirt.engine.api.model.VcpuPins in project ovirt-engine by oVirt.
the class VmMapper method cpuTuneToString.
static String cpuTuneToString(final CpuTune tune) {
final StringBuilder builder = new StringBuilder();
VcpuPins pins = tune.getVcpuPins();
if (pins != null) {
boolean first = true;
for (final VcpuPin pin : pins.getVcpuPins()) {
if (first) {
first = false;
} else {
builder.append("_");
}
builder.append(pin.getVcpu()).append('#').append(pin.getCpuSet());
}
}
return builder.toString();
}
use of org.ovirt.engine.api.model.VcpuPins in project ovirt-engine by oVirt.
the class V3CpuTuneInAdapter method adapt.
@Override
public CpuTune adapt(V3CpuTune from) {
CpuTune to = new CpuTune();
if (from.isSetVCpuPin()) {
to.setVcpuPins(new VcpuPins());
to.getVcpuPins().getVcpuPins().addAll(adaptIn(from.getVCpuPin()));
}
return to;
}
use of org.ovirt.engine.api.model.VcpuPins in project ovirt-engine by oVirt.
the class VmMapperTest method postPopulate.
@Override
protected Vm postPopulate(Vm from) {
from.setType(MappingTestHelper.shuffle(VmType.class));
from.setStorageErrorResumeBehaviour(MappingTestHelper.shuffle(VmStorageErrorResumeBehaviour.class));
from.setOrigin(OriginType.VMWARE.name().toLowerCase());
from.getDisplay().setType(MappingTestHelper.shuffle(DisplayType.class));
from.getPayloads().getPayloads().get(0).setType(MappingTestHelper.shuffle(VmDeviceType.class));
List<BootDevice> devices = from.getOs().getBoot().getDevices().getDevices();
for (int i = 0; i < devices.size(); i++) {
devices.set(i, MappingTestHelper.shuffle(BootDevice.class));
}
while (from.getCpu().getTopology().getSockets() == 0) {
from.getCpu().getTopology().setSockets(MappingTestHelper.rand(100));
}
while (from.getCpu().getTopology().getCores() == 0) {
from.getCpu().getTopology().setCores(MappingTestHelper.rand(100));
}
CpuTune cpuTune = new CpuTune();
VcpuPin pin = new VcpuPin();
pin.setVcpu(33);
pin.setCpuSet("1-4,6");
VcpuPins pins = new VcpuPins();
pins.getVcpuPins().add(pin);
cpuTune.setVcpuPins(pins);
from.getCpu().setCpuTune(cpuTune);
from.setTimeZone(new TimeZone());
from.getTimeZone().setName("Australia/Darwin");
// VmPlacement - multiple hosts
from.setPlacementPolicy(createPlacementPolicy(Guid.EVERYONE, Guid.SYSTEM));
// Guest Nics configurations
for (NicConfiguration guestNic : from.getInitialization().getNicConfigurations().getNicConfigurations()) {
guestNic.setBootProtocol(MappingTestHelper.shuffle(BootProtocol.class, BootProtocol.AUTOCONF));
}
from.getDisplay().setType(DisplayType.SPICE);
from.getSerialNumber().setPolicy(SerialNumberPolicy.CUSTOM);
from.getDisplay().setFileTransferEnabled(true);
from.getDisplay().setCopyPasteEnabled(true);
from.getMigration().setAutoConverge(InheritableBoolean.TRUE);
from.getMigration().setCompressed(InheritableBoolean.TRUE);
from.getDisplay().setDisconnectAction(DisplayDisconnectAction.LOCK_SCREEN.toString());
return from;
}
Aggregations