use of org.ovirt.engine.core.common.businessentities.QuotaStorage in project ovirt-engine by oVirt.
the class QuotaDaoTest method testQuotaStorageByQuotaGuidWithGeneralDefaultWithDefault.
/**
* Asserts that when {@link QuotaDao#getQuotaStorageByQuotaGuidWithGeneralDefault(Guid)} is called
* with a specific quota, all the relevant VDSs are returned
*/
@Test
public void testQuotaStorageByQuotaGuidWithGeneralDefaultWithDefault() {
List<QuotaStorage> quotaStorageList = dao.getQuotaStorageByQuotaGuidWithGeneralDefault(FixturesTool.DEFAULT_QUOTA_GENERAL);
assertNotNull(quotaStorageList);
assertEquals("wrong number of quotas returned", 1, quotaStorageList.size());
for (QuotaStorage group : quotaStorageList) {
assertEquals("Storage ID should not be null in general mode", Guid.Empty, group.getStorageId());
assertNull("Storage name should not be null in general mode", group.getStorageName());
}
}
use of org.ovirt.engine.core.common.businessentities.QuotaStorage 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.QuotaStorage 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.QuotaStorage in project ovirt-engine by oVirt.
the class BackendQuotaStorageLimitsResourceTest method testListNonGlobalLimit.
@Test
public void testListNonGlobalLimit() throws Exception {
Quota quota = getQuota();
List<QuotaStorage> storageLimits = new LinkedList<>();
QuotaStorage storageLimit1 = new QuotaStorage();
storageLimit1.setStorageSizeGB(STORAGE_SIZE_GB);
storageLimit1.setStorageId(STORAGE_ID_1);
QuotaStorage storageLimit2 = new QuotaStorage();
storageLimit2.setStorageSizeGBUsage(STORAGE_SIZE_GB_USAGE);
storageLimit2.setStorageId(STORAGE_ID_2);
storageLimits.add(storageLimit1);
storageLimits.add(storageLimit2);
quota.setQuotaStorages(storageLimits);
setUpGetEntityExpectations(quota);
QuotaStorageLimits list = collection.list();
assertStorageLimitsFound(list, 2);
for (QuotaStorageLimit storageLimit : list.getQuotaStorageLimits()) {
if (storageLimit.getStorageDomain().getId().equals(STORAGE_ID_1.toString())) {
assertEquals(STORAGE_SIZE_GB, storageLimit.getLimit());
}
if (storageLimit.getStorageDomain().getId().equals(STORAGE_ID_2.toString())) {
assertTrue(storageLimit.getUsage() == STORAGE_SIZE_GB_USAGE);
}
}
}
use of org.ovirt.engine.core.common.businessentities.QuotaStorage in project ovirt-engine by oVirt.
the class QuotaListModel method createQuota.
protected void createQuota(boolean populateDataCenter) {
final QuotaModel qModel = new QuotaModel();
qModel.setTitle(ConstantsManager.getInstance().getConstants().newQuotaTitle());
qModel.setHelpTag(HelpTag.new_quota);
// $NON-NLS-1$
qModel.setHashName("new_quota");
Quota newQuota = new Quota();
qModel.setEntity(newQuota);
setWindow(qModel);
qModel.startProgress();
if (populateDataCenter) {
AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(dataCenterList -> {
if (dataCenterList == null || dataCenterList.size() == 0) {
return;
}
QuotaModel quotaModel = (QuotaModel) getWindow();
quotaModel.getDataCenter().setItems(dataCenterList);
quotaModel.getDataCenter().setSelectedItem(dataCenterList.get(0));
}));
}
qModel.getDataCenter().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
StoragePool selectedDataCenter = qModel.getDataCenter().getSelectedItem();
if (selectedDataCenter == null) {
return;
}
AsyncDataProvider.getInstance().getClusterList(new AsyncQuery<>(clusterList -> {
if (clusterList == null || clusterList.size() == 0) {
qModel.getAllDataCenterClusters().setItems(new ArrayList<QuotaCluster>());
return;
}
ArrayList<QuotaCluster> quotaClusterList = new ArrayList<>();
QuotaCluster quotaCluster;
for (Cluster cluster : clusterList) {
quotaCluster = new QuotaCluster();
quotaCluster.setClusterId(cluster.getId());
quotaCluster.setClusterName(cluster.getName());
quotaCluster.setMemSizeMB(null);
quotaCluster.setMemSizeMBUsage((long) 0);
quotaCluster.setVirtualCpu(null);
quotaCluster.setVirtualCpuUsage(0);
quotaClusterList.add(quotaCluster);
}
qModel.getAllDataCenterClusters().setItems(quotaClusterList);
}), selectedDataCenter.getId());
AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>(storageList -> {
if (storageList == null || storageList.size() == 0) {
qModel.getAllDataCenterStorages().setItems(new ArrayList<QuotaStorage>());
qModel.stopProgress();
return;
}
ArrayList<QuotaStorage> quotaStorageList = new ArrayList<>();
QuotaStorage quotaStorage;
for (StorageDomain storage : storageList) {
if (!storage.getStorageDomainType().isDataDomain()) {
continue;
}
quotaStorage = new QuotaStorage();
quotaStorage.setStorageId(storage.getId());
quotaStorage.setStorageName(storage.getStorageName());
quotaStorage.setStorageSizeGB(null);
quotaStorage.setStorageSizeGBUsage((double) 0);
quotaStorageList.add(quotaStorage);
}
qModel.getAllDataCenterStorages().setItems(quotaStorageList);
qModel.stopProgress();
}), selectedDataCenter.getId());
});
// $NON-NLS-1$
UICommand command = UICommand.createDefaultOkUiCommand("OnCreateQuota", this);
qModel.getCommands().add(command);
// $NON-NLS-1$
qModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Aggregations