use of org.ovirt.engine.core.common.businessentities.qos.StorageQos in project ovirt-engine by oVirt.
the class DiskProfileBaseModel method flush.
@Override
public void flush() {
if (getProfile() == null) {
setProfile(new DiskProfile());
}
DiskProfile diskProfile = getProfile();
diskProfile.setName(getName().getEntity());
diskProfile.setDescription(getDescription().getEntity());
StorageDomain storageDomain = getParentListModel().getSelectedItem();
diskProfile.setStorageDomainId(storageDomain != null ? storageDomain.getId() : null);
StorageQos storageQos = getQos().getSelectedItem();
diskProfile.setQosId(storageQos != null && storageQos.getId() != null && !storageQos.getId().equals(Guid.Empty) ? storageQos.getId() : null);
}
use of org.ovirt.engine.core.common.businessentities.qos.StorageQos in project ovirt-engine by oVirt.
the class AbstractBackendDiskProfilesResource method handleQosDataCenterLinks.
/**
* used to set qos's href (requires dc id).
*/
private void handleQosDataCenterLinks(Map<Guid, Qos> qosMap) {
if (!qosMap.isEmpty()) {
List<StorageQos> list = getBackendCollection(StorageQos.class, QueryType.GetAllQosByType, new QosQueryParameterBase(null, QosType.STORAGE));
for (StorageQos storageQos : list) {
Qos qos = qosMap.get(storageQos.getId());
if (qos != null) {
qos.setDataCenter(new DataCenter());
qos.getDataCenter().setId(storageQos.getStoragePoolId().toString());
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.qos.StorageQos in project ovirt-engine by oVirt.
the class VmInfoBuildUtilsTest method setUp.
@Before
public void setUp() {
injectorRule.bind(AuditLogDirector.class, auditLogDirector);
diskImage.setDiskProfileId(Guid.newGuid());
qos = new StorageQos();
qos.setId(Guid.newGuid());
vmDevice = new VmDevice();
VnicProfile vnicProfile = new VnicProfile();
vnicProfile.setNetworkFilterId(NETWORK_FILTER_ID);
when(vnicProfileDao.get(VNIC_PROFILE_ID)).thenReturn(vnicProfile);
NetworkFilter networkFilter = new NetworkFilter();
networkFilter.setName(NETWORK_FILTER_NAME);
when(networkFilterDao.getNetworkFilterById(NETWORK_FILTER_ID)).thenReturn(networkFilter);
when(vmNicFilterParameterDao.getAllForVmNic(VM_NIC_ID)).thenReturn(createVmNicFilterParameters());
}
use of org.ovirt.engine.core.common.businessentities.qos.StorageQos 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.businessentities.qos.StorageQos 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