Search in sources :

Example 16 with QuotaStorage

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

the class QuotaDaoTest method testQuotaStorageByQuotaGuidWithGeneralDefaultWithDefault.

/**
 * Asserts that when {@link QuotaDao#getQuotaStorageByQuotaGuidWithGeneralDefault(Guid)} is called
 * with a specific quota, all the relevant VDSs are returned
 */
@Test
public void testQuotaStorageByQuotaGuidWithGeneralDefaultWithDefault() {
    List<QuotaStorage> quotaStorageList = dao.getQuotaStorageByQuotaGuidWithGeneralDefault(FixturesTool.DEFAULT_QUOTA_GENERAL);
    assertNotNull(quotaStorageList);
    assertEquals("wrong number of quotas returned", 1, quotaStorageList.size());
    for (QuotaStorage group : quotaStorageList) {
        assertEquals("Storage ID should not be null in general mode", Guid.Empty, group.getStorageId());
        assertNull("Storage name should not be null in general mode", group.getStorageName());
    }
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Test(org.junit.Test)

Example 17 with QuotaStorage

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

the class AddQuotaCommandTest method mockGeneralStorageQuota.

private Quota mockGeneralStorageQuota() {
    Quota generalQuota = new Quota();
    generalQuota.setDescription("New Quota to create");
    generalQuota.setQuotaName("New Quota Name");
    QuotaStorage storageQuota = new QuotaStorage();
    storageQuota.setStorageSizeGB(100L);
    storageQuota.setStorageSizeGBUsage(0d);
    generalQuota.setGlobalQuotaStorage(storageQuota);
    QuotaCluster clusterQuota = new QuotaCluster();
    clusterQuota.setVirtualCpu(0);
    clusterQuota.setVirtualCpuUsage(0);
    clusterQuota.setMemSizeMB(0L);
    clusterQuota.setMemSizeMBUsage(0L);
    generalQuota.setGlobalQuotaCluster(clusterQuota);
    generalQuota.setId(Guid.newGuid());
    generalQuota.setStoragePoolId(Guid.newGuid());
    return generalQuota;
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster)

Example 18 with QuotaStorage

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

the class QuotaValidatorTest method setup.

@Before
public void setup() {
    quota = new Quota();
    quota.setId(QUOTA_ID);
    quotaStorage = new QuotaStorage(Guid.newGuid(), QUOTA_ID, Guid.newGuid(), 100L, 0.0);
    quotaCluster = new QuotaCluster(Guid.newGuid(), QUOTA_ID, Guid.newGuid(), 10, 0, 100L, 0L);
    doReturn(quota).when(quotaDao).getById(QUOTA_ID);
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Before(org.junit.Before)

Example 19 with QuotaStorage

use of org.ovirt.engine.core.common.businessentities.QuotaStorage 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 20 with QuotaStorage

use of org.ovirt.engine.core.common.businessentities.QuotaStorage 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

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