use of org.ovirt.engine.core.common.vdscommands.UpdateVmPolicyVDSParams in project ovirt-engine by oVirt.
the class VmSlaPolicyCommandTest method setUp.
@Before
public void setUp() {
doAnswer(invocation -> {
VDSCommandType commandType = (VDSCommandType) invocation.getArguments()[0];
assertEquals(VDSCommandType.UpdateVmPolicy, commandType);
UpdateVmPolicyVDSParams params = (UpdateVmPolicyVDSParams) invocation.getArguments()[1];
VDSReturnValue retVal = new VDSReturnValue();
retVal.setSucceeded(vdsFunction.apply(params));
return retVal;
}).when(command).runVdsCommand(any(), any());
vm = new VM();
vm.setId(VM_ID);
vm.setStatus(VMStatus.Up);
when(vmDao.get(VM_ID)).thenReturn(vm);
diskImage = new DiskImage();
diskImage.setStorageIds(new ArrayList<>());
diskImage.getStorageIds().add(DISK_DOMAIN_ID);
diskImage.setStoragePoolId(DISK_POOL_ID);
diskImage.setId(DISK_IMAGE_ID);
diskImage.setImageId(DISK_VOLUME_ID);
}
use of org.ovirt.engine.core.common.vdscommands.UpdateVmPolicyVDSParams in project ovirt-engine by oVirt.
the class VmSlaPolicyCommand method executeCommand.
/**
* Execution shall perform a call to VDSM to set the SLA parameters.
*/
@Override
protected void executeCommand() {
Integer cpuLimit = null;
if (getParameters().getCpuQos() != null) {
cpuLimit = getParameters().getCpuQos().getCpuLimit();
cpuLimit = (cpuLimit != null) ? cpuLimit : 100;
}
UpdateVmPolicyVDSParams params = new UpdateVmPolicyVDSParams(getVm().getRunOnVds(), getVmId(), cpuLimit);
for (Map.Entry<DiskImage, StorageQos> entry : getParameters().getStorageQos().entrySet()) {
DiskImage diskImage = entry.getKey();
Map<String, Long> ioTuneStruct = IoTuneUtils.ioTuneMapFrom(entry.getValue());
params.addIoTuneParams(diskImage, ioTuneStruct);
}
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.UpdateVmPolicy, params);
setSucceeded(vdsReturnValue.getSucceeded());
}
Aggregations