Search in sources :

Example 1 with VmSlaPolicyParameters

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);
            }
        }
    });
}
Also used : ConnectHostToStoragePoolServersParameters(org.ovirt.engine.core.common.action.ConnectHostToStoragePoolServersParameters) Arrays(java.util.Arrays) IrsProxyManager(org.ovirt.engine.core.vdsbroker.irsbroker.IrsProxyManager) EngineException(org.ovirt.engine.core.common.errors.EngineException) EventType(org.ovirt.engine.core.common.eventqueue.EventType) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) MomPolicyUpdate(org.ovirt.engine.core.common.qualifiers.MomPolicyUpdate) VdsDao(org.ovirt.engine.core.dao.VdsDao) Map(java.util.Map) Event(org.ovirt.engine.core.common.eventqueue.Event) SetStoragePoolStatusParameters(org.ovirt.engine.core.common.action.SetStoragePoolStatusParameters) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) Instance(javax.enterprise.inject.Instance) StoragePoolStatusHandler(org.ovirt.engine.core.bll.storage.pool.StoragePoolStatusHandler) Set(java.util.Set) HostDeviceManager(org.ovirt.engine.core.bll.hostdev.HostDeviceManager) MomPolicyVDSParameters(org.ovirt.engine.core.common.vdscommands.MomPolicyVDSParameters) VmSlaPolicyParameters(org.ovirt.engine.core.common.action.VmSlaPolicyParameters) SchedulingManager(org.ovirt.engine.core.bll.scheduling.SchedulingManager) Injector(org.ovirt.engine.core.di.Injector) ReconstructMasterParameters(org.ovirt.engine.core.common.action.ReconstructMasterParameters) DisconnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters) ResourceManager(org.ovirt.engine.core.vdsbroker.ResourceManager) Guid(org.ovirt.engine.core.compat.Guid) Callable(java.util.concurrent.Callable) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) SyncStorageDomainsLunsParameters(org.ovirt.engine.core.common.action.SyncStorageDomainsLunsParameters) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Pair(org.ovirt.engine.core.common.utils.Pair) SetNonOperationalVdsParameters(org.ovirt.engine.core.common.action.SetNonOperationalVdsParameters) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) IrsProxy(org.ovirt.engine.core.vdsbroker.irsbroker.IrsProxy) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) EngineContext(org.ovirt.engine.core.bll.context.EngineContext) LockManager(org.ovirt.engine.core.utils.lock.LockManager) EngineError(org.ovirt.engine.core.common.errors.EngineError) TransactionScopeOption(org.ovirt.engine.core.compat.TransactionScopeOption) DiskDao(org.ovirt.engine.core.dao.DiskDao) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) VDSBrokerFrontend(org.ovirt.engine.core.common.interfaces.VDSBrokerFrontend) MaintenanceNumberOfVdssParameters(org.ovirt.engine.core.common.action.MaintenanceNumberOfVdssParameters) GlusterBrickDao(org.ovirt.engine.core.dao.gluster.GlusterBrickDao) LoggerFactory(org.slf4j.LoggerFactory) NonOperationalReason(org.ovirt.engine.core.common.businessentities.NonOperationalReason) CpuQosDao(org.ovirt.engine.core.dao.qos.CpuQosDao) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) BackendInternal(org.ovirt.engine.core.bll.interfaces.BackendInternal) VmJobsMonitoring(org.ovirt.engine.core.vdsbroker.monitoring.VmJobsMonitoring) Observes(javax.enterprise.event.Observes) StoragePoolDao(org.ovirt.engine.core.dao.StoragePoolDao) ThreadPoolUtil(org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) CpuQos(org.ovirt.engine.core.common.businessentities.qos.CpuQos) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) EventQueue(org.ovirt.engine.core.common.eventqueue.EventQueue) Collectors(java.util.stream.Collectors) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) VDSNetworkException(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) HostStoragePoolParametersBase(org.ovirt.engine.core.common.action.HostStoragePoolParametersBase) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) IVdsEventListener(org.ovirt.engine.core.common.businessentities.IVdsEventListener) AuditLogType(org.ovirt.engine.core.common.AuditLogType) ProcessDownVmParameters(org.ovirt.engine.core.common.action.ProcessDownVmParameters) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) MigrateVmToServerParameters(org.ovirt.engine.core.common.action.MigrateVmToServerParameters) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) CommandCoordinatorUtil(org.ovirt.engine.core.bll.tasks.CommandCoordinatorUtil) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ExecutionHandler(org.ovirt.engine.core.bll.job.ExecutionHandler) LinkedList(java.util.LinkedList) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) IVdsAsyncCommand(org.ovirt.engine.core.common.businessentities.IVdsAsyncCommand) StorageDomainStaticDao(org.ovirt.engine.core.dao.StorageDomainStaticDao) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) Logger(org.slf4j.Logger) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) AddUnmanagedVmsParameters(org.ovirt.engine.core.common.action.AddUnmanagedVmsParameters) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) StorageQosDao(org.ovirt.engine.core.dao.qos.StorageQosDao) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) VmSlaPolicyParameters(org.ovirt.engine.core.common.action.VmSlaPolicyParameters) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) CpuQos(org.ovirt.engine.core.common.businessentities.qos.CpuQos) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) HashSet(java.util.HashSet)

Example 2 with VmSlaPolicyParameters

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));
    }
}
Also used : VmSlaPolicyParameters(org.ovirt.engine.core.common.action.VmSlaPolicyParameters) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) Map(java.util.Map) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 VmSlaPolicyParameters (org.ovirt.engine.core.common.action.VmSlaPolicyParameters)2 StorageQos (org.ovirt.engine.core.common.businessentities.qos.StorageQos)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 Guid (org.ovirt.engine.core.compat.Guid)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 Singleton (javax.inject.Singleton)1