use of org.ovirt.engine.core.common.action.VmSlaPolicyParameters in project ovirt-engine by oVirt.
the class VdsEventListener method updateSlaPolicies.
@Override
public void updateSlaPolicies(final List<Guid> vmIds, final Guid vdsId) {
if (vmIds.isEmpty()) {
return;
}
ThreadPoolUtil.execute(() -> {
// Get Disks and CpuQos of VMs from the DB
Map<Guid, List<Disk>> diskMap = diskDao.getAllForVms(vmIds);
Map<Guid, CpuQos> cpuQosMap = cpuQosDao.getCpuQosByVmIds(vmIds);
Map<Guid, List<DiskImage>> diskImageMap = new HashMap<>();
Set<Guid> diskProfileIds = new HashSet<>();
for (Guid vmId : vmIds) {
// Filter - only plugged disk images with disk profile remain
List<DiskImage> diskImages = diskMap.get(vmId).stream().filter(disk -> disk.getPlugged() && disk.getDiskStorageType() == DiskStorageType.IMAGE).map(DiskImage.class::cast).filter(disk -> disk.getDiskProfileId() != null).collect(Collectors.toList());
diskImageMap.put(vmId, diskImages);
for (DiskImage img : diskImages) {
diskProfileIds.add(img.getDiskProfileId());
}
}
// Get StorageQos of used disk profiles
Map<Guid, StorageQos> storageQosMap = storageQosDao.getQosByDiskProfileIds(diskProfileIds);
// Call VmSlaPolicyCommand for each VM
for (Guid vmId : vmIds) {
CpuQos cpuQos = cpuQosMap.get(vmId);
VmSlaPolicyParameters params = new VmSlaPolicyParameters(vmId, cpuQos);
for (DiskImage diskImage : diskImageMap.get(vmId)) {
Guid diskProfileId = diskImage.getDiskProfileId();
StorageQos storageQos = storageQosMap.get(diskProfileId);
if (storageQos != null) {
params.getStorageQos().put(diskImage, storageQos);
}
}
if (!params.isEmpty()) {
backend.runInternalAction(ActionType.VmSlaPolicy, params);
}
}
});
}
use of org.ovirt.engine.core.common.action.VmSlaPolicyParameters in project ovirt-engine by oVirt.
the class VmSlaPolicyUtils method refreshVmsStorageQos.
public void refreshVmsStorageQos(Map<Guid, List<DiskImage>> vmDiskMap, StorageQos newQos) {
// No QoS means default QoS which means unlimited
if (newQos == null) {
newQos = new StorageQos();
}
for (Map.Entry<Guid, List<DiskImage>> entry : vmDiskMap.entrySet()) {
VmSlaPolicyParameters cmdParams = new VmSlaPolicyParameters(entry.getKey());
for (DiskImage img : entry.getValue()) {
cmdParams.getStorageQos().put(img, newQos);
}
ThreadPoolUtil.execute(() -> backend.runInternalAction(ActionType.VmSlaPolicy, cmdParams));
}
}
Aggregations