use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class BackendQuotaClusterLimitsResourceTest method getQuota.
protected org.ovirt.engine.core.common.businessentities.Quota getQuota() {
org.ovirt.engine.core.common.businessentities.Quota quota = new org.ovirt.engine.core.common.businessentities.Quota();
quota.setId(QUOTA_ID);
quota.setStoragePoolId(DATACENTER_ID);
return quota;
}
use of org.ovirt.engine.core.common.businessentities.Quota 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.Quota in project ovirt-engine by oVirt.
the class RegisterTemplateModel method prepareActionParameters.
private List<ActionParametersBase> prepareActionParameters() {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (ImportTemplateData entityData : getEntities().getItems()) {
VmTemplate vmTemplate = entityData.getEntity();
Cluster cluster = entityData.getCluster().getSelectedItem();
ImportVmTemplateFromConfParameters params = new ImportVmTemplateFromConfParameters();
params.setExternalVnicProfileMappings(cloneExternalVnicProfiles(cluster));
params.setContainerId(vmTemplate.getId());
params.setStorageDomainId(getStorageDomainId());
params.setImagesExistOnTargetStorageDomain(true);
params.setClusterId(cluster != null ? cluster.getId() : null);
if (isQuotaEnabled()) {
Quota quota = entityData.getClusterQuota().getSelectedItem();
params.setQuotaId(quota != null ? quota.getId() : null);
params.setDiskTemplateMap(vmTemplate.getDiskTemplateMap());
updateDiskQuotas(new ArrayList<Disk>(params.getDiskTemplateMap().values()));
}
parameters.add(params);
}
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class ChangeQuotaModel method init.
public void init(final ArrayList<DiskImage> disks) {
ArrayList<QueryType> queryTypeList = new ArrayList<>();
ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
Set<Guid> storageDomainIdSet = new HashSet<>();
for (DiskImage diskImage : disks) {
for (Guid storageDomainId : diskImage.getStorageIds()) {
storageDomainIdSet.add(storageDomainId);
}
}
for (Guid storageDomainId : storageDomainIdSet) {
queryParamsList.add(new IdQueryParameters(storageDomainId));
queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
}
Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
Map<Guid, List<Quota>> storageDomainIdMap = new HashMap<>();
for (int i = 0; i < result.getReturnValues().size(); i++) {
QueryReturnValue retVal = result.getReturnValues().get(i);
Guid storageId = ((IdQueryParameters) result.getParameters().get(i)).getId();
storageDomainIdMap.put(storageId, (ArrayList<Quota>) retVal.getReturnValue());
}
ArrayList<ChangeQuotaItemModel> list = new ArrayList<>();
Guid storageDomainId;
for (DiskImage diskImage : disks) {
for (int i = 0; i < diskImage.getStorageIds().size(); i++) {
storageDomainId = diskImage.getStorageIds().get(i);
ChangeQuotaItemModel itemModel = new ChangeQuotaItemModel();
itemModel.setEntity(diskImage);
itemModel.getObject().setEntity(diskImage.getDiskAlias());
itemModel.getCurrentQuota().setEntity(diskImage.getQuotaNames() != null && diskImage.getQuotaNames().size() >= i + 1 ? diskImage.getQuotaNames().get(i) : null);
itemModel.setStorageDomainId(storageDomainId);
itemModel.setStorageDomainName(diskImage.getStoragesNames().get(i));
itemModel.getQuota().setItems(storageDomainIdMap.get(storageDomainId));
for (Quota quota : itemModel.getQuota().getItems()) {
if (!quota.getId().equals(diskImage.getQuotaId())) {
itemModel.getQuota().setSelectedItem(quota);
break;
}
}
list.add(itemModel);
}
}
ChangeQuotaModel.this.setItems(list);
ChangeQuotaModel.this.stopProgress();
});
}
use of org.ovirt.engine.core.common.businessentities.Quota 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