Search in sources :

Example 16 with QuotaCluster

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;
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster)

Example 17 with QuotaCluster

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;
}
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 18 with QuotaCluster

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());
    }
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) Quota(org.ovirt.engine.api.model.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Cluster(org.ovirt.engine.api.model.Cluster)

Example 19 with QuotaCluster

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);
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Before(org.junit.Before)

Example 20 with QuotaCluster

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

QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)36 Quota (org.ovirt.engine.core.common.businessentities.Quota)17 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)14 Test (org.junit.Test)12 Guid (org.ovirt.engine.core.compat.Guid)8 ArrayList (java.util.ArrayList)5 ActionType (org.ovirt.engine.core.common.action.ActionType)3 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)3 Inject (com.google.inject.Inject)2 HashMap (java.util.HashMap)2 List (java.util.List)2 QuotaClusterLimit (org.ovirt.engine.api.model.QuotaClusterLimit)2 QuotaClusterLimits (org.ovirt.engine.api.model.QuotaClusterLimits)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 IdParameters (org.ovirt.engine.core.common.action.IdParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)2 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)2