Search in sources :

Example 1 with QuotaStorageLimits

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

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

the class BackendQuotaStorageLimitsResource method list.

@Override
public QuotaStorageLimits list() {
    Quota quota = getQuota();
    QuotaStorageLimits limits = new QuotaStorageLimits();
    if (quota.getGlobalQuotaStorage() != null) {
        addLimit(quotaId.toString(), limits, quota);
    } else if (quota.getQuotaStorages() != null) {
        for (QuotaStorage quotaStorage : quota.getQuotaStorages()) {
            addLimit(quotaStorage.getStorageId().toString(), limits, quota);
        }
    }
    return limits;
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaStorageLimits(org.ovirt.engine.api.model.QuotaStorageLimits)

Example 3 with QuotaStorageLimits

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

the class V3QuotaStorageLimitsInAdapter method adapt.

@Override
public QuotaStorageLimits adapt(V3QuotaStorageLimits from) {
    QuotaStorageLimits to = new QuotaStorageLimits();
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetActive()) {
        to.setActive(from.getActive());
    }
    if (from.isSetSize()) {
        to.setSize(from.getSize());
    }
    if (from.isSetTotal()) {
        to.setTotal(from.getTotal());
    }
    to.getQuotaStorageLimits().addAll(adaptIn(from.getQuotaStorageLimits()));
    return to;
}
Also used : QuotaStorageLimits(org.ovirt.engine.api.model.QuotaStorageLimits) V3QuotaStorageLimits(org.ovirt.engine.api.v3.types.V3QuotaStorageLimits)

Example 4 with QuotaStorageLimits

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

QuotaStorageLimits (org.ovirt.engine.api.model.QuotaStorageLimits)4 Quota (org.ovirt.engine.core.common.businessentities.Quota)3 Test (org.junit.Test)2 QuotaStorageLimit (org.ovirt.engine.api.model.QuotaStorageLimit)2 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)2 LinkedList (java.util.LinkedList)1 V3QuotaStorageLimits (org.ovirt.engine.api.v3.types.V3QuotaStorageLimits)1