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());
}
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;
}
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();
}
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;
}
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);
}
}
}
Aggregations