Search in sources :

Example 1 with QuotaClusterLimit

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

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

the class BackendQuotaClusterLimitResource method createQuotaLimit.

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

Example 3 with QuotaClusterLimit

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

the class BackendQuotaClusterLimitsResource method add.

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

Example 4 with QuotaClusterLimit

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

the class QuotaMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.Quota.class, to = QuotaClusterLimit.class)
public static QuotaClusterLimit map(org.ovirt.engine.core.common.businessentities.Quota entity, QuotaClusterLimit template) {
    QuotaClusterLimit model = template != null ? template : new QuotaClusterLimit();
    Guid guid = GuidUtils.asGuid(model.getId());
    // global
    if (guid.equals(entity.getId())) {
        map(model, entity.getGlobalQuotaCluster(), null, entity.getStoragePoolId().toString(), entity.getId().toString());
    } else {
        // specific
        if (entity.getQuotaClusters() != null) {
            for (QuotaCluster quotaCluster : entity.getQuotaClusters()) {
                if (quotaCluster.getClusterId() != null && quotaCluster.getClusterId().equals(guid)) {
                    map(model, quotaCluster, quotaCluster.getClusterId().toString(), entity.getStoragePoolId().toString(), entity.getId().toString());
                }
            }
        }
    }
    return model;
}
Also used : QuotaClusterLimit(org.ovirt.engine.api.model.QuotaClusterLimit) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Guid(org.ovirt.engine.core.compat.Guid)

Example 5 with QuotaClusterLimit

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

Aggregations

QuotaClusterLimit (org.ovirt.engine.api.model.QuotaClusterLimit)6 Quota (org.ovirt.engine.core.common.businessentities.Quota)3 Test (org.junit.Test)2 QuotaClusterLimits (org.ovirt.engine.api.model.QuotaClusterLimits)2 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)2 LinkedList (java.util.LinkedList)1 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1