Search in sources :

Example 26 with QuotaStorage

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

the class UpdateQuotaCommandTest method setUpQuota.

private Quota setUpQuota(Guid guid) {
    Quota quota = new Quota();
    quota.setId(guid);
    int numQutoaClusters = RandomUtils.instance().nextInt(10);
    List<QuotaCluster> quotaClusters = new ArrayList<>(numQutoaClusters);
    for (int i = 0; i < numQutoaClusters; ++i) {
        quotaClusters.add(new QuotaCluster());
    }
    quota.setQuotaClusters(quotaClusters);
    int numQutoaStorages = RandomUtils.instance().nextInt(10);
    List<QuotaStorage> quotaStorages = new ArrayList<>(numQutoaStorages);
    for (int i = 0; i < numQutoaClusters; ++i) {
        quotaStorages.add(new QuotaStorage());
    }
    quota.setQuotaStorages(quotaStorages);
    return quota;
}
Also used : 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)

Example 27 with QuotaStorage

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

the class GetQuotaStorageByQuotaIdQueryTest method testExecuteQueryCommand.

@Test
public void testExecuteQueryCommand() {
    // Mock the parameters
    Guid quotaId = Guid.newGuid();
    when(params.getId()).thenReturn(quotaId);
    // Create the return value
    QuotaStorage group = new QuotaStorage();
    group.setQuotaId(quotaId);
    // Mock the Dao
    when(quotaDao.getQuotaStorageByQuotaGuidWithGeneralDefault(quotaId)).thenReturn(Collections.singletonList(group));
    // Execute the query
    getQuery().executeQueryCommand();
    // Assert the result
    @SuppressWarnings("unchecked") List<QuotaStorage> results = getQuery().getQueryReturnValue().getReturnValue();
    assertEquals("Wrong number of results returned", 1, results.size());
    assertEquals("Wrong results returned", group, results.get(0));
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 28 with QuotaStorage

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

the class QuotaCRUDCommand method setQuotaStorage.

private void setQuotaStorage(Quota quota) {
    // Create unlimited global storage quota if no other is specified
    if (quota.isEmptyStorageQuota()) {
        quota.setGlobalQuotaStorage(new QuotaStorage(Guid.newGuid(), quota.getId(), null, -1L, 0.0));
        return;
    }
    if (quota.isGlobalStorageQuota()) {
        quota.getGlobalQuotaStorage().setQuotaId(quota.getId());
        quota.getGlobalQuotaStorage().setQuotaStorageId(Guid.newGuid());
        return;
    }
    for (QuotaStorage quotaStorage : quota.getQuotaStorages()) {
        quotaStorage.setQuotaId(quota.getId());
        quotaStorage.setQuotaStorageId(Guid.newGuid());
    }
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage)

Example 29 with QuotaStorage

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

the class QuotaManagerTest method getQuotaStorage.

private QuotaStorage getQuotaStorage(long storageSize, double storageSizeUsed) {
    QuotaStorage storageQuota = new QuotaStorage();
    storageQuota.setStorageSizeGB(storageSize);
    storageQuota.setStorageSizeGBUsage(storageSizeUsed);
    storageQuota.setStorageId(DESTINATION_GUID);
    return storageQuota;
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage)

Example 30 with QuotaStorage

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

the class QuotaPopupView method initQuotaStorageTable.

private void initQuotaStorageTable() {
    quotaStorageTable = new ListModelObjectCellTable<>();
    storageQuotaTableContainer.add(quotaStorageTable);
    isStorageInQuotaColumn = new Column<QuotaStorage, Boolean>(new CheckboxCell(true, true)) {

        @Override
        public Boolean getValue(QuotaStorage object) {
            if (selectedStorageGuid.contains(object.getStorageId()) || object.getStorageSizeGB() != null) {
                if (!selectedStorageGuid.contains(object.getStorageId())) {
                    selectedStorageGuid.add(object.getStorageId());
                }
                return true;
            }
            return false;
        }
    };
    isStorageInQuotaColumn.setFieldUpdater((index, object, value) -> {
        if (value) {
            selectedStorageGuid.add(object.getStorageId());
            object.setStorageSizeGB(QuotaStorage.UNLIMITED);
        } else {
            selectedStorageGuid.remove(object.getStorageId());
            object.setStorageSizeGB(null);
        }
        if (model.getGlobalStorageQuota().getEntity()) {
            quotaStorageTable.asEditor().edit(model.getQuotaStorages());
        } else {
            quotaStorageTable.asEditor().edit(model.getAllDataCenterStorages());
        }
    });
    quotaStorageTable.addColumn(new AbstractTextColumn<QuotaStorage>() {

        @Override
        public String getValue(QuotaStorage object) {
            if (object.getStorageName() == null || object.getStorageName().length() == 0) {
                return constants.utlQuotaAllStoragesQuotaPopup();
            }
            return object.getStorageName();
        }
    }, constants.storageNameQuota(), // $NON-NLS-1$
    "200px");
    // $NON-NLS-1$
    quotaStorageTable.addColumn(new QuotaUtilizationStatusColumn<QuotaStorage>(), constants.empty(), "1px");
    quotaStorageTable.addColumn(new AbstractTextColumn<QuotaStorage>() {

        @Override
        public String getValue(QuotaStorage object) {
            if (object.getStorageSizeGB() == null) {
                // $NON-NLS-1$
                return "";
            } else if (object.getStorageSizeGB().equals(QuotaStorage.UNLIMITED)) {
                return messages.unlimitedStorageConsumption(object.getStorageSizeGBUsage() == 0 ? // $NON-NLS-1$
                "0" : diskSizeRenderer.render(object.getStorageSizeGBUsage()));
            } else {
                return messages.limitedStorageConsumption(object.getStorageSizeGBUsage() == 0 ? // $NON-NLS-1$
                "0" : diskSizeRenderer.render(object.getStorageSizeGBUsage()), object.getStorageSizeGB());
            }
        }
    }, constants.quota());
    Column<QuotaStorage, String> editColumn = new Column<QuotaStorage, String>(new NullableButtonCell()) {

        @Override
        public String getValue(QuotaStorage object) {
            if (model.getGlobalStorageQuota().getEntity() || (model.getSpecificStorageQuota().getEntity() && selectedStorageGuid.contains(object.getStorageId()))) {
                return constants.editCellQuota();
            }
            return null;
        }
    };
    editColumn.setFieldUpdater((index, object, value) -> model.editQuotaStorage(object));
    // $NON-NLS-1$
    quotaStorageTable.addColumn(editColumn, constants.empty(), "50px");
}
Also used : NullableButtonCell(org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell) QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) QuotaUtilizationStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.QuotaUtilizationStatusColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) CheckboxCell(org.ovirt.engine.ui.common.widget.table.cell.CheckboxCell)

Aggregations

QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)30 Quota (org.ovirt.engine.core.common.businessentities.Quota)16 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)14 Guid (org.ovirt.engine.core.compat.Guid)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 ActionType (org.ovirt.engine.core.common.action.ActionType)3 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)3 Inject (com.google.inject.Inject)2 List (java.util.List)2 Map (java.util.Map)2 QuotaStorageLimits (org.ovirt.engine.api.model.QuotaStorageLimits)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 IdParameters (org.ovirt.engine.core.common.action.IdParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)2 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)2