Search in sources :

Example 61 with Quota

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

the class BackendQuotaClusterLimitsResourceTest method getQuota.

protected org.ovirt.engine.core.common.businessentities.Quota getQuota() {
    org.ovirt.engine.core.common.businessentities.Quota quota = new org.ovirt.engine.core.common.businessentities.Quota();
    quota.setId(QUOTA_ID);
    quota.setStoragePoolId(DATACENTER_ID);
    return quota;
}
Also used : Quota(org.ovirt.engine.core.common.businessentities.Quota) Quota(org.ovirt.engine.core.common.businessentities.Quota)

Example 62 with Quota

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

the class BackendQuotaStorageLimitsResourceTest method testListNonGlobalLimit.

@Test
public void testListNonGlobalLimit() throws Exception {
    Quota quota = getQuota();
    List<QuotaStorage> storageLimits = new LinkedList<>();
    QuotaStorage storageLimit1 = new QuotaStorage();
    storageLimit1.setStorageSizeGB(STORAGE_SIZE_GB);
    storageLimit1.setStorageId(STORAGE_ID_1);
    QuotaStorage storageLimit2 = new QuotaStorage();
    storageLimit2.setStorageSizeGBUsage(STORAGE_SIZE_GB_USAGE);
    storageLimit2.setStorageId(STORAGE_ID_2);
    storageLimits.add(storageLimit1);
    storageLimits.add(storageLimit2);
    quota.setQuotaStorages(storageLimits);
    setUpGetEntityExpectations(quota);
    QuotaStorageLimits list = collection.list();
    assertStorageLimitsFound(list, 2);
    for (QuotaStorageLimit storageLimit : list.getQuotaStorageLimits()) {
        if (storageLimit.getStorageDomain().getId().equals(STORAGE_ID_1.toString())) {
            assertEquals(STORAGE_SIZE_GB, storageLimit.getLimit());
        }
        if (storageLimit.getStorageDomain().getId().equals(STORAGE_ID_2.toString())) {
            assertTrue(storageLimit.getUsage() == STORAGE_SIZE_GB_USAGE);
        }
    }
}
Also used : QuotaStorageLimit(org.ovirt.engine.api.model.QuotaStorageLimit) QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaStorageLimits(org.ovirt.engine.api.model.QuotaStorageLimits) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 63 with Quota

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

the class RegisterTemplateModel method prepareActionParameters.

private List<ActionParametersBase> prepareActionParameters() {
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (ImportTemplateData entityData : getEntities().getItems()) {
        VmTemplate vmTemplate = entityData.getEntity();
        Cluster cluster = entityData.getCluster().getSelectedItem();
        ImportVmTemplateFromConfParameters params = new ImportVmTemplateFromConfParameters();
        params.setExternalVnicProfileMappings(cloneExternalVnicProfiles(cluster));
        params.setContainerId(vmTemplate.getId());
        params.setStorageDomainId(getStorageDomainId());
        params.setImagesExistOnTargetStorageDomain(true);
        params.setClusterId(cluster != null ? cluster.getId() : null);
        if (isQuotaEnabled()) {
            Quota quota = entityData.getClusterQuota().getSelectedItem();
            params.setQuotaId(quota != null ? quota.getId() : null);
            params.setDiskTemplateMap(vmTemplate.getDiskTemplateMap());
            updateDiskQuotas(new ArrayList<Disk>(params.getDiskTemplateMap().values()));
        }
        parameters.add(params);
    }
    return parameters;
}
Also used : ImportVmTemplateFromConfParameters(org.ovirt.engine.core.common.action.ImportVmTemplateFromConfParameters) ImportTemplateData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData) Quota(org.ovirt.engine.core.common.businessentities.Quota) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 64 with Quota

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

the class ChangeQuotaModel method init.

public void init(final ArrayList<DiskImage> disks) {
    ArrayList<QueryType> queryTypeList = new ArrayList<>();
    ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
    Set<Guid> storageDomainIdSet = new HashSet<>();
    for (DiskImage diskImage : disks) {
        for (Guid storageDomainId : diskImage.getStorageIds()) {
            storageDomainIdSet.add(storageDomainId);
        }
    }
    for (Guid storageDomainId : storageDomainIdSet) {
        queryParamsList.add(new IdQueryParameters(storageDomainId));
        queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
    }
    Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
        Map<Guid, List<Quota>> storageDomainIdMap = new HashMap<>();
        for (int i = 0; i < result.getReturnValues().size(); i++) {
            QueryReturnValue retVal = result.getReturnValues().get(i);
            Guid storageId = ((IdQueryParameters) result.getParameters().get(i)).getId();
            storageDomainIdMap.put(storageId, (ArrayList<Quota>) retVal.getReturnValue());
        }
        ArrayList<ChangeQuotaItemModel> list = new ArrayList<>();
        Guid storageDomainId;
        for (DiskImage diskImage : disks) {
            for (int i = 0; i < diskImage.getStorageIds().size(); i++) {
                storageDomainId = diskImage.getStorageIds().get(i);
                ChangeQuotaItemModel itemModel = new ChangeQuotaItemModel();
                itemModel.setEntity(diskImage);
                itemModel.getObject().setEntity(diskImage.getDiskAlias());
                itemModel.getCurrentQuota().setEntity(diskImage.getQuotaNames() != null && diskImage.getQuotaNames().size() >= i + 1 ? diskImage.getQuotaNames().get(i) : null);
                itemModel.setStorageDomainId(storageDomainId);
                itemModel.setStorageDomainName(diskImage.getStoragesNames().get(i));
                itemModel.getQuota().setItems(storageDomainIdMap.get(storageDomainId));
                for (Quota quota : itemModel.getQuota().getItems()) {
                    if (!quota.getId().equals(diskImage.getQuotaId())) {
                        itemModel.getQuota().setSelectedItem(quota);
                        break;
                    }
                }
                list.add(itemModel);
            }
        }
        ChangeQuotaModel.this.setItems(list);
        ChangeQuotaModel.this.stopProgress();
    });
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ArrayList(java.util.ArrayList) List(java.util.List) QueryType(org.ovirt.engine.core.common.queries.QueryType) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) HashSet(java.util.HashSet)

Example 65 with Quota

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

the class QuotaListModel method createQuota.

protected void createQuota(boolean populateDataCenter) {
    final QuotaModel qModel = new QuotaModel();
    qModel.setTitle(ConstantsManager.getInstance().getConstants().newQuotaTitle());
    qModel.setHelpTag(HelpTag.new_quota);
    // $NON-NLS-1$
    qModel.setHashName("new_quota");
    Quota newQuota = new Quota();
    qModel.setEntity(newQuota);
    setWindow(qModel);
    qModel.startProgress();
    if (populateDataCenter) {
        AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(dataCenterList -> {
            if (dataCenterList == null || dataCenterList.size() == 0) {
                return;
            }
            QuotaModel quotaModel = (QuotaModel) getWindow();
            quotaModel.getDataCenter().setItems(dataCenterList);
            quotaModel.getDataCenter().setSelectedItem(dataCenterList.get(0));
        }));
    }
    qModel.getDataCenter().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
        StoragePool selectedDataCenter = qModel.getDataCenter().getSelectedItem();
        if (selectedDataCenter == null) {
            return;
        }
        AsyncDataProvider.getInstance().getClusterList(new AsyncQuery<>(clusterList -> {
            if (clusterList == null || clusterList.size() == 0) {
                qModel.getAllDataCenterClusters().setItems(new ArrayList<QuotaCluster>());
                return;
            }
            ArrayList<QuotaCluster> quotaClusterList = new ArrayList<>();
            QuotaCluster quotaCluster;
            for (Cluster cluster : clusterList) {
                quotaCluster = new QuotaCluster();
                quotaCluster.setClusterId(cluster.getId());
                quotaCluster.setClusterName(cluster.getName());
                quotaCluster.setMemSizeMB(null);
                quotaCluster.setMemSizeMBUsage((long) 0);
                quotaCluster.setVirtualCpu(null);
                quotaCluster.setVirtualCpuUsage(0);
                quotaClusterList.add(quotaCluster);
            }
            qModel.getAllDataCenterClusters().setItems(quotaClusterList);
        }), selectedDataCenter.getId());
        AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>(storageList -> {
            if (storageList == null || storageList.size() == 0) {
                qModel.getAllDataCenterStorages().setItems(new ArrayList<QuotaStorage>());
                qModel.stopProgress();
                return;
            }
            ArrayList<QuotaStorage> quotaStorageList = new ArrayList<>();
            QuotaStorage quotaStorage;
            for (StorageDomain storage : storageList) {
                if (!storage.getStorageDomainType().isDataDomain()) {
                    continue;
                }
                quotaStorage = new QuotaStorage();
                quotaStorage.setStorageId(storage.getId());
                quotaStorage.setStorageName(storage.getStorageName());
                quotaStorage.setStorageSizeGB(null);
                quotaStorage.setStorageSizeGBUsage((double) 0);
                quotaStorageList.add(quotaStorage);
            }
            qModel.getAllDataCenterStorages().setItems(quotaStorageList);
            qModel.stopProgress();
        }), selectedDataCenter.getId());
    });
    // $NON-NLS-1$
    UICommand command = UICommand.createDefaultOkUiCommand("OnCreateQuota", this);
    qModel.getCommands().add(command);
    // $NON-NLS-1$
    qModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Guid(org.ovirt.engine.core.compat.Guid) Inject(com.google.inject.Inject) QuotaCRUDParameters(org.ovirt.engine.core.common.action.QuotaCRUDParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Quota(org.ovirt.engine.core.common.businessentities.Quota) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) IdParameters(org.ovirt.engine.core.common.action.IdParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Aggregations

Quota (org.ovirt.engine.core.common.businessentities.Quota)101 ArrayList (java.util.ArrayList)23 Guid (org.ovirt.engine.core.compat.Guid)22 Test (org.junit.Test)17 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)17 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)16 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)12 HashMap (java.util.HashMap)9 List (java.util.List)9 QueryType (org.ovirt.engine.core.common.queries.QueryType)9 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)8 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)6 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)6 Map (java.util.Map)5 RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5