use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class AddQuotaCommandTest method mockGeneralStorageQuota.
private Quota mockGeneralStorageQuota() {
Quota generalQuota = new Quota();
generalQuota.setDescription("New Quota to create");
generalQuota.setQuotaName("New Quota Name");
QuotaStorage storageQuota = new QuotaStorage();
storageQuota.setStorageSizeGB(100L);
storageQuota.setStorageSizeGBUsage(0d);
generalQuota.setGlobalQuotaStorage(storageQuota);
QuotaCluster clusterQuota = new QuotaCluster();
clusterQuota.setVirtualCpu(0);
clusterQuota.setVirtualCpuUsage(0);
clusterQuota.setMemSizeMB(0L);
clusterQuota.setMemSizeMBUsage(0L);
generalQuota.setGlobalQuotaCluster(clusterQuota);
generalQuota.setId(Guid.newGuid());
generalQuota.setStoragePoolId(Guid.newGuid());
return generalQuota;
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster 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.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaMapper method map.
private static void map(QuotaClusterLimit template, QuotaCluster quotaCluster, String clusterId, String dataCenterId, String quotaId) {
template.setQuota(new Quota());
template.getQuota().setId(quotaId);
template.getQuota().setDataCenter(new DataCenter());
template.getQuota().getDataCenter().setId(dataCenterId);
if (clusterId != null) {
template.setCluster(new Cluster());
template.getCluster().setId(clusterId);
}
if (quotaCluster.getMemSizeMB() != null) {
// show GB instead of MB (ignore -1)
double value = quotaCluster.getMemSizeMB() == -1 ? quotaCluster.getMemSizeMB().doubleValue() : quotaCluster.getMemSizeMB().doubleValue() / 1024.0;
template.setMemoryLimit(value);
}
if (quotaCluster.getMemSizeMBUsage() != null) {
template.setMemoryUsage(quotaCluster.getMemSizeMBUsage() / 1024.0);
}
if (quotaCluster.getVirtualCpu() != null) {
template.setVcpuLimit(quotaCluster.getVirtualCpu());
}
if (quotaCluster.getVirtualCpuUsage() != null) {
template.setVcpuUsage(quotaCluster.getVirtualCpuUsage());
}
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaValidatorTest method setup.
@Before
public void setup() {
quota = new Quota();
quota.setId(QUOTA_ID);
quotaStorage = new QuotaStorage(Guid.newGuid(), QUOTA_ID, Guid.newGuid(), 100L, 0.0);
quotaCluster = new QuotaCluster(Guid.newGuid(), QUOTA_ID, Guid.newGuid(), 10, 0, 100L, 0L);
doReturn(quota).when(quotaDao).getById(QUOTA_ID);
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster 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