Search in sources :

Example 1 with QuotaStorageLimit

use of org.ovirt.engine.api.model.QuotaStorageLimit in project ovirt-engine by oVirt.

the class BackendQuotaStorageLimitsResourceTest method testListGlobalLimit.

@Test
public void testListGlobalLimit() throws Exception {
    Quota quota = getQuota();
    quota.setGlobalQuotaStorage(getStorageGlobalCpuLimit());
    setUpGetEntityExpectations(quota);
    QuotaStorageLimits storageLimits = collection.list();
    assertStorageLimitsFound(storageLimits, 1);
    QuotaStorageLimit storageLimit = storageLimits.getQuotaStorageLimits().get(0);
    assertEquals(STORAGE_SIZE_GB, storageLimit.getLimit());
}
Also used : QuotaStorageLimit(org.ovirt.engine.api.model.QuotaStorageLimit) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaStorageLimits(org.ovirt.engine.api.model.QuotaStorageLimits) Test(org.junit.Test)

Example 2 with QuotaStorageLimit

use of org.ovirt.engine.api.model.QuotaStorageLimit in project ovirt-engine by oVirt.

the class BackendQuotaStorageLimitResource method createQuotaLimit.

@Override
protected QuotaStorageLimit createQuotaLimit() {
    QuotaStorageLimit limit = new QuotaStorageLimit();
    limit.setId(id);
    return limit;
}
Also used : QuotaStorageLimit(org.ovirt.engine.api.model.QuotaStorageLimit)

Example 3 with QuotaStorageLimit

use of org.ovirt.engine.api.model.QuotaStorageLimit in project ovirt-engine by oVirt.

the class BackendQuotaStorageLimitsResource method addLimit.

private void addLimit(String id, QuotaStorageLimits limits, Quota quota) {
    QuotaStorageLimit limit = new QuotaStorageLimit();
    limit.setId(id);
    limits.getQuotaStorageLimits().add(addLinks(map(quota, limit)));
}
Also used : QuotaStorageLimit(org.ovirt.engine.api.model.QuotaStorageLimit)

Example 4 with QuotaStorageLimit

use of org.ovirt.engine.api.model.QuotaStorageLimit in project ovirt-engine by oVirt.

the class BackendQuotaStorageLimitsResource method add.

public Response add(QuotaStorageLimit incoming) {
    Quota entity = getQuota();
    QuotaCRUDParameters parameters = new QuotaCRUDParameters(map(incoming, entity));
    performAction(ActionType.UpdateQuota, parameters);
    entity = getQuota();
    updateIncomingId(incoming, entity);
    QuotaStorageLimit model = map(entity, incoming);
    model = addLinks(doPopulate(model, entity));
    return Response.ok(model).build();
}
Also used : QuotaCRUDParameters(org.ovirt.engine.core.common.action.QuotaCRUDParameters) QuotaStorageLimit(org.ovirt.engine.api.model.QuotaStorageLimit) Quota(org.ovirt.engine.core.common.businessentities.Quota)

Example 5 with QuotaStorageLimit

use of org.ovirt.engine.api.model.QuotaStorageLimit 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)

Aggregations

QuotaStorageLimit (org.ovirt.engine.api.model.QuotaStorageLimit)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)3 Test (org.junit.Test)2 QuotaStorageLimits (org.ovirt.engine.api.model.QuotaStorageLimits)2 LinkedList (java.util.LinkedList)1 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)1 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)1