Search in sources :

Example 1 with QuotaClusterLimits

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

the class BackendQuotaClusterLimitsResourceTest method testListGlobalLimit.

@Test
public void testListGlobalLimit() throws Exception {
    Quota quota = getQuota();
    quota.setGlobalQuotaCluster(getClusterGlobalCpuLimit());
    setUpGetEntityExpectations(quota);
    QuotaClusterLimits clusterLimits = collection.list();
    assertClusterLimitsFound(clusterLimits, 1);
    QuotaClusterLimit clusterLimit = clusterLimits.getQuotaClusterLimits().get(0);
    assertEquals(20, clusterLimit.getVcpuLimit().intValue());
}
Also used : QuotaClusterLimits(org.ovirt.engine.api.model.QuotaClusterLimits) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaClusterLimit(org.ovirt.engine.api.model.QuotaClusterLimit) Test(org.junit.Test)

Example 2 with QuotaClusterLimits

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

the class BackendQuotaClusterLimitsResource method list.

@Override
public QuotaClusterLimits list() {
    Quota quota = getQuota();
    QuotaClusterLimits limits = new QuotaClusterLimits();
    if (quota.getGlobalQuotaCluster() != null) {
        addLimit(quotaId.toString(), limits, quota);
    } else if (quota.getQuotaClusters() != null) {
        for (QuotaCluster quotaCluster : quota.getQuotaClusters()) {
            addLimit(quotaCluster.getClusterId().toString(), limits, quota);
        }
    }
    return limits;
}
Also used : QuotaClusterLimits(org.ovirt.engine.api.model.QuotaClusterLimits) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster)

Example 3 with QuotaClusterLimits

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

the class BackendQuotaClusterLimitsResourceTest method testListNonGlobalLimit.

@Test
public void testListNonGlobalLimit() throws Exception {
    Quota quota = getQuota();
    List<QuotaCluster> clusterLimits = new LinkedList<>();
    QuotaCluster clusterLimit1 = new QuotaCluster();
    clusterLimit1.setVirtualCpu(CPU_NUMBER);
    clusterLimit1.setClusterId(CLUSTER_ID_1);
    QuotaCluster clusterLimit2 = new QuotaCluster();
    clusterLimit2.setVirtualCpuUsage(VIRTUAL_CPU_USAGE);
    clusterLimit2.setClusterId(CLUSTER_ID_2);
    clusterLimits.add(clusterLimit1);
    clusterLimits.add(clusterLimit2);
    quota.setQuotaClusters(clusterLimits);
    setUpGetEntityExpectations(quota);
    QuotaClusterLimits list = collection.list();
    assertClusterLimitsFound(list, 2);
    for (QuotaClusterLimit clusterLimit : list.getQuotaClusterLimits()) {
        if (clusterLimit.getCluster().getId().equals(CLUSTER_ID_1.toString())) {
            assertEquals(CPU_NUMBER, clusterLimit.getVcpuLimit().longValue());
        }
        if (clusterLimit.getCluster().getId().equals(CLUSTER_ID_2.toString())) {
            assertTrue(clusterLimit.getVcpuUsage() == VIRTUAL_CPU_USAGE);
        }
    }
}
Also used : QuotaClusterLimits(org.ovirt.engine.api.model.QuotaClusterLimits) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) QuotaClusterLimit(org.ovirt.engine.api.model.QuotaClusterLimit) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 4 with QuotaClusterLimits

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

the class V3QuotaClusterLimitsInAdapter method adapt.

@Override
public QuotaClusterLimits adapt(V3QuotaClusterLimits from) {
    QuotaClusterLimits to = new QuotaClusterLimits();
    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.getQuotaClusterLimits().addAll(adaptIn(from.getQuotaClusterLimits()));
    return to;
}
Also used : QuotaClusterLimits(org.ovirt.engine.api.model.QuotaClusterLimits) V3QuotaClusterLimits(org.ovirt.engine.api.v3.types.V3QuotaClusterLimits)

Aggregations

QuotaClusterLimits (org.ovirt.engine.api.model.QuotaClusterLimits)4 Quota (org.ovirt.engine.core.common.businessentities.Quota)3 Test (org.junit.Test)2 QuotaClusterLimit (org.ovirt.engine.api.model.QuotaClusterLimit)2 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)2 LinkedList (java.util.LinkedList)1 V3QuotaClusterLimits (org.ovirt.engine.api.v3.types.V3QuotaClusterLimits)1