use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class QuotaDaoTest method testGeneralQuotaLimitations.
@Test
public void testGeneralQuotaLimitations() throws Exception {
// Set new Quota definition.
Quota quota = createGeneralQuota();
setQuotaGlobalLimitations(quota);
quota.setQuotaClusters(getQuotaCluster(null));
quota.setQuotaStorages(getQuotaStorage(null));
dao.save(quota);
Quota quotaEntity = dao.getById(quota.getId());
assertNotNull(quotaEntity);
assertEquals(quota, quotaEntity);
assertEquals("rhel6.NFS", quotaEntity.getStoragePoolName());
assertEquals(QuotaEnforcementTypeEnum.DISABLED, quotaEntity.getQuotaEnforcementType());
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class UpdateQuotaCommandTest method setUpQuota.
private Quota setUpQuota(Guid guid) {
Quota quota = new Quota();
quota.setId(guid);
int numQutoaClusters = RandomUtils.instance().nextInt(10);
List<QuotaCluster> quotaClusters = new ArrayList<>(numQutoaClusters);
for (int i = 0; i < numQutoaClusters; ++i) {
quotaClusters.add(new QuotaCluster());
}
quota.setQuotaClusters(quotaClusters);
int numQutoaStorages = RandomUtils.instance().nextInt(10);
List<QuotaStorage> quotaStorages = new ArrayList<>(numQutoaStorages);
for (int i = 0; i < numQutoaClusters; ++i) {
quotaStorages.add(new QuotaStorage());
}
quota.setQuotaStorages(quotaStorages);
return quota;
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class RemoveQuotaCommandTest method mockQuotaDao.
@Before
public void mockQuotaDao() {
quota = mockStorageQuota(quotaGuid);
when(quotaDao.getById(quotaGuid)).thenReturn(quota);
List<Quota> quotaList = new ArrayList<>();
quotaList.add(new Quota());
quotaList.add(new Quota());
when(quotaDao.getQuotaByStoragePoolGuid(storagePoolUUID)).thenReturn(quotaList);
when(quotaDao.isQuotaInUse(any())).thenReturn(false);
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class QuotaDaoImpl method getById.
/**
* Get full {@code Quota} entity.
*/
@Override
public Quota getById(Guid quotaId) {
MapSqlParameterSource parameterSource = createQuotaIdParameterMapper(quotaId);
Quota quotaEntity = getCallsHandler().executeRead("GetQuotaByQuotaGuid", getQuotaFromResultSet(), parameterSource);
if (quotaEntity != null) {
quotaEntity.setQuotaClusters(getQuotaClusterByQuotaGuid(quotaId));
quotaEntity.setQuotaStorages(getQuotaStorageByQuotaGuid(quotaId));
}
return quotaEntity;
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class DataCenterListModel method checkForQuotaInDC.
private void checkForQuotaInDC(StoragePool storage_pool, final ICommandTarget commandTarget) {
IdQueryParameters parameters = new IdQueryParameters(storage_pool.getId());
Frontend.getInstance().runQuery(QueryType.GetQuotaByStoragePoolId, parameters, new AsyncQuery<QueryReturnValue>(returnValue -> {
if (((ArrayList<Quota>) returnValue.getReturnValue()).size() == 0) {
promptNoQuotaInDCMessage();
} else {
onSaveInternal();
}
}));
}
Aggregations