Search in sources :

Example 1 with StorageQos

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);
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 2 with StorageQos

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());
            }
        }
    }
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) QosQueryParameterBase(org.ovirt.engine.core.common.queries.QosQueryParameterBase) DataCenter(org.ovirt.engine.api.model.DataCenter) Qos(org.ovirt.engine.api.model.Qos) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos)

Example 3 with StorageQos

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());
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) Before(org.junit.Before)

Example 4 with StorageQos

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);
            }
        }
    });
}
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 5 with StorageQos

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));
    }
}
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

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