Search in sources :

Example 1 with UpdateVmPolicyVDSParams

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);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) UpdateVmPolicyVDSParams(org.ovirt.engine.core.common.vdscommands.UpdateVmPolicyVDSParams) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Before(org.junit.Before)

Example 2 with UpdateVmPolicyVDSParams

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());
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) UpdateVmPolicyVDSParams(org.ovirt.engine.core.common.vdscommands.UpdateVmPolicyVDSParams) Map(java.util.Map) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 UpdateVmPolicyVDSParams (org.ovirt.engine.core.common.vdscommands.UpdateVmPolicyVDSParams)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 Map (java.util.Map)1 Before (org.junit.Before)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 StorageQos (org.ovirt.engine.core.common.businessentities.qos.StorageQos)1 VDSCommandType (org.ovirt.engine.core.common.vdscommands.VDSCommandType)1