Search in sources :

Example 11 with StorageQos

use of org.ovirt.engine.core.common.businessentities.qos.StorageQos in project ovirt-engine by oVirt.

the class VmInfoBuilderImpl method buildVmDrives.

@Override
public void buildVmDrives() {
    boolean bootDiskFound = false;
    List<Disk> disks = vmInfoBuildUtils.getSortedDisks(vm);
    Map<Integer, Map<VmDevice, Integer>> vmDeviceVirtioScsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForVirtioScsiDisks(vm);
    Map<Integer, Map<VmDevice, Integer>> vmDeviceSpaprVscsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForSpaprScsiDisks(vm);
    Map<Guid, StorageQos> qosCache = new HashMap<>();
    int pinnedDriveIndex = 0;
    for (Disk disk : disks) {
        Map<String, Object> struct = new HashMap<>();
        // get vm device for this disk from DB
        VmDevice vmDevice = vmInfoBuildUtils.getVmDeviceByDiskId(disk.getId(), vm.getId());
        DiskVmElement dve = disk.getDiskVmElementForVm(vm.getId());
        // skip unmanaged devices (handled separately)
        if (!vmDevice.isManaged()) {
            continue;
        }
        if (vmDevice.isPlugged()) {
            struct.put(VdsProperties.Type, vmDevice.getType().getValue());
            struct.put(VdsProperties.Device, vmDevice.getDevice());
            switch(dve.getDiskInterface()) {
                case IDE:
                    struct.put(VdsProperties.INTERFACE, VdsProperties.Ide);
                    break;
                case VirtIO:
                    struct.put(VdsProperties.INTERFACE, VdsProperties.Virtio);
                    int pinTo = vmInfoBuildUtils.pinToIoThreads(vm, pinnedDriveIndex++);
                    if (pinTo > 0) {
                        vmDevice.getSpecParams().put(VdsProperties.pinToIoThread, pinTo);
                    }
                    break;
                case VirtIO_SCSI:
                    // set device type as 'lun' (instead of 'disk') and set the specified SGIO.
                    if (disk.getDiskStorageType() == DiskStorageType.LUN && disk.isScsiPassthrough()) {
                        struct.put(VdsProperties.Device, VmDeviceType.LUN.getName());
                        struct.put(VdsProperties.Sgio, disk.getSgio().toString().toLowerCase());
                    }
                case SPAPR_VSCSI:
                    struct.put(VdsProperties.INTERFACE, VdsProperties.Scsi);
                    vmInfoBuildUtils.calculateAddressForScsiDisk(vm, disk, vmDevice, vmDeviceSpaprVscsiUnitMap, vmDeviceVirtioScsiUnitMap);
                    break;
                default:
                    logUnsupportedInterfaceType();
                    break;
            }
            // Insure that boot disk is created first
            if (!bootDiskFound && dve.isBoot()) {
                bootDiskFound = true;
                struct.put(VdsProperties.Index, getBootableDiskIndex(disk));
            }
            if (FeatureSupported.passDiscardSupported(vm.getCompatibilityVersion())) {
                struct.put(VdsProperties.DISCARD, dve.isPassDiscard());
            }
            vmInfoBuildUtils.addAddress(vmDevice, struct);
            switch(disk.getDiskStorageType()) {
                case IMAGE:
                    DiskImage diskImage = (DiskImage) disk;
                    struct.put(VdsProperties.DiskType, vmInfoBuildUtils.getDiskType(vm, diskImage));
                    struct.put(VdsProperties.PoolId, diskImage.getStoragePoolId().toString());
                    struct.put(VdsProperties.DomainId, diskImage.getStorageIds().get(0).toString());
                    struct.put(VdsProperties.ImageId, diskImage.getId().toString());
                    struct.put(VdsProperties.VolumeId, diskImage.getImageId().toString());
                    struct.put(VdsProperties.Format, diskImage.getVolumeFormat().toString().toLowerCase());
                    struct.put(VdsProperties.PropagateErrors, disk.getPropagateErrors().toString().toLowerCase());
                    if (!qosCache.containsKey(diskImage.getDiskProfileId())) {
                        qosCache.put(diskImage.getDiskProfileId(), vmInfoBuildUtils.loadStorageQos(diskImage));
                    }
                    vmInfoBuildUtils.handleIoTune(vmDevice, qosCache.get(diskImage.getDiskProfileId()));
                    break;
                case LUN:
                    LunDisk lunDisk = (LunDisk) disk;
                    struct.put(VdsProperties.Guid, lunDisk.getLun().getLUNId());
                    struct.put(VdsProperties.Format, VolumeFormat.RAW.toString().toLowerCase());
                    struct.put(VdsProperties.PropagateErrors, PropagateErrors.Off.toString().toLowerCase());
                    break;
                case CINDER:
                    vmInfoBuildUtils.buildCinderDisk((CinderDisk) disk, struct);
                    break;
            }
            struct.put(VdsProperties.Shareable, (vmDevice.getSnapshotId() != null) ? VdsProperties.Transient : String.valueOf(disk.isShareable()));
            struct.put(VdsProperties.Optional, Boolean.FALSE.toString());
            struct.put(VdsProperties.ReadOnly, String.valueOf(vmDevice.getReadOnly()));
            struct.put(VdsProperties.SpecParams, vmDevice.getSpecParams());
            struct.put(VdsProperties.DeviceId, String.valueOf(vmDevice.getId().getDeviceId()));
            devices.add(struct);
            bootableDevices.add(vmDevice);
        }
    }
    ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new CreateAdditionalControllers(devices));
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) HashMap(java.util.HashMap) CreateAdditionalControllers(org.ovirt.engine.core.vdsbroker.architecture.CreateAdditionalControllers) Guid(org.ovirt.engine.core.compat.Guid) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Map(java.util.Map) HashMap(java.util.HashMap) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 12 with StorageQos

use of org.ovirt.engine.core.common.businessentities.qos.StorageQos in project ovirt-engine by oVirt.

the class DiskProfileBaseModel method postInitQosList.

@Override
protected void postInitQosList(List<StorageQos> qosList) {
    qosList.add(0, EMPTY_QOS);
    getQos().setItems(qosList);
    if (getDefaultQosId() != null) {
        for (StorageQos storageQos : qosList) {
            if (getDefaultQosId().equals(storageQos.getId())) {
                getQos().setSelectedItem(storageQos);
                break;
            }
        }
    }
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos)

Example 13 with StorageQos

use of org.ovirt.engine.core.common.businessentities.qos.StorageQos in project ovirt-engine by oVirt.

the class RemoveStorageQosCommand method executeCommand.

@Override
protected void executeCommand() {
    Map<Guid, List<DiskImage>> vmDisksMap = vmSlaPolicyUtils.getRunningVmDiskImageMapWithQos(getQosId());
    super.executeCommand();
    // After successful command, set everything to unlimited
    if (getSucceeded()) {
        vmSlaPolicyUtils.refreshVmsStorageQos(vmDisksMap, new StorageQos());
    }
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid)

Example 14 with StorageQos

use of org.ovirt.engine.core.common.businessentities.qos.StorageQos in project ovirt-engine by oVirt.

the class VmSlaPolicyCommandTest method testStorageQos.

@Test
public void testStorageQos() {
    StorageQos storageQos = new StorageQos();
    storageQos.setMaxThroughput(100);
    storageQos.setMaxIops(60000);
    parameters.getStorageQos().put(diskImage, storageQos);
    vdsFunction = params -> {
        assertIoTune(params.getIoTuneList().get(0), 100L * 1024L * 1024L, 0, 0, 60000, 0, 0);
        return true;
    };
    assertTrue(command.validate());
    command.executeCommand();
    assertTrue(command.getReturnValue().getSucceeded());
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) Test(org.junit.Test)

Example 15 with StorageQos

use of org.ovirt.engine.core.common.businessentities.qos.StorageQos 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

StorageQos (org.ovirt.engine.core.common.businessentities.qos.StorageQos)17 Map (java.util.Map)4 Test (org.junit.Test)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)4 Guid (org.ovirt.engine.core.compat.Guid)4 HashMap (java.util.HashMap)3 List (java.util.List)3 VmSlaPolicyParameters (org.ovirt.engine.core.common.action.VmSlaPolicyParameters)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 Collectors (java.util.stream.Collectors)1 Observes (javax.enterprise.event.Observes)1 Instance (javax.enterprise.inject.Instance)1 Inject (javax.inject.Inject)1