use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class RegisterVmModel method prepareParameters.
private List<ActionParametersBase> prepareParameters() {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (RegisterVmData registerVmData : getEntities().getItems()) {
VM vm = registerVmData.getEntity();
Cluster cluster = registerVmData.getCluster().getSelectedItem();
ImportVmFromConfParameters params = new ImportVmFromConfParameters(cloneExternalVnicProfiles(cluster), registerVmData.getReassignMacs().getEntity());
params.setContainerId(vm.getId());
params.setStorageDomainId(getStorageDomainId());
params.setImagesExistOnTargetStorageDomain(true);
params.setClusterId(cluster != null ? cluster.getId() : null);
params.setAllowPartialImport(registerVmData.getAllowPartialImport().getEntity());
if (isQuotaEnabled()) {
Quota quota = registerVmData.getClusterQuota().getSelectedItem();
params.setQuotaId(quota != null ? quota.getId() : null);
params.setDiskMap(vm.getDiskMap());
updateDiskQuotas(new ArrayList<>(params.getDiskMap().values()));
}
parameters.add(params);
}
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class AbstractDiskModel method updateQuota.
private void updateQuota(StoragePool datacenter) {
if (datacenter.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED) || !getDiskStorageType().getEntity().isInternal()) {
getQuota().setIsAvailable(false);
return;
}
getQuota().setIsAvailable(true);
StorageDomain storageDomain = getStorageDomain().getSelectedItem();
if (storageDomain == null) {
return;
}
final Guid diskQuota = getDisk() != null ? ((DiskImage) getDisk()).getQuotaId() : null;
final Guid vmQuota = getVm() != null ? getVm().getQuotaId() : null;
final Guid defaultQuota = diskQuota != null ? diskQuota : vmQuota;
AsyncDataProvider.getInstance().getAllRelevantQuotasForStorageSorted(new AsyncQuery<>(quotaList -> {
if (quotaList != null && !quotaList.isEmpty()) {
getQuota().setItems(quotaList);
// If list contains default quota, return
if (quotaList.get(0).getId().equals(defaultQuota)) {
return;
}
}
if (diskQuota != null) {
Quota quota = new Quota();
quota.setId(diskQuota);
quota.setQuotaName(getDiskImage().getQuotaName());
if (quotaList == null) {
quotaList = new ArrayList<>();
}
quotaList.add(quota);
getQuota().setItems(quotaList);
getQuota().setSelectedItem(quota);
}
}), storageDomain.getId(), defaultQuota);
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainPopupView method addStorageQuotaColumn.
private void addStorageQuotaColumn() {
if (!importModel.isQuotaEnabled()) {
return;
}
if (quotaColumn != null) {
return;
}
CustomSelectionCell customSelectionCellQuota = new CustomSelectionCell(new ArrayList<String>());
customSelectionCellQuota.setStyle(EMPTY_STYLE);
quotaColumn = new Column<DiskImage, String>(customSelectionCellQuota) {
@Override
public String getValue(DiskImage disk) {
ImportDiskData importData = importModel.getDiskImportData(disk.getId());
ArrayList<String> storageQuotaList = new ArrayList<>();
Quota selectedQuota = null;
if (importData != null && importData.getQuotaList() != null) {
for (Quota quota : importData.getQuotaList()) {
storageQuotaList.add(quota.getQuotaName());
if (importData.getSelectedQuota() != null) {
if (quota.getId().equals(importData.getSelectedQuota().getId())) {
selectedQuota = quota;
}
}
}
}
((CustomSelectionCell) getCell()).setOptions(storageQuotaList);
if (!storageQuotaList.isEmpty()) {
if (selectedQuota != null) {
return selectedQuota.getQuotaName();
} else {
return storageQuotaList.get(0);
}
}
return "";
}
};
quotaColumn.setFieldUpdater((index, disk, value) -> importModel.getDiskImportData(disk.getId()).setSelectedQuotaString(value));
// $NON-NLS-1$
diskTable.addColumn(quotaColumn, constants.quota(), "100px");
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class RegisterEntityInfoPanel method getDiskQuotaColumn.
private Column<Disk, String> getDiskQuotaColumn() {
CustomSelectionCell customSelectionCell = new CustomSelectionCell(new ArrayList<String>());
// $NON-NLS-1$
customSelectionCell.setStyle("input-group col-xs-11");
AbstractColumn<Disk, String> column = new AbstractColumn<Disk, String>(customSelectionCell) {
@Override
public String getValue(Disk disk) {
if (disk.getDiskStorageType() == DiskStorageType.LUN) {
return null;
}
List<Quota> quotas = (List<Quota>) registerEntityModel.getStorageQuota().getItems();
if (quotas == null || quotas.isEmpty()) {
return constants.empty();
}
Map<Guid, Quota> diskQuotaMap = registerEntityModel.getDiskQuotaMap().getEntity();
if (diskQuotaMap.get(disk.getId()) == null) {
diskQuotaMap.put(disk.getId(), quotas.get(0));
((CustomSelectionCell) getCell()).setOptions(registerEntityModel.getQuotaNames(quotas));
}
return diskQuotaMap.get(disk.getId()).getQuotaName();
}
};
column.setFieldUpdater((index, disk, value) -> {
Quota quota = registerEntityModel.getQuotaByName(value, (List<Quota>) registerEntityModel.getStorageQuota().getItems());
registerEntityModel.getDiskQuotaMap().getEntity().put(disk.getId(), quota);
});
return column;
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class RegisterEntityPopupView method getClusterQuotaColumn.
protected Column<D, String> getClusterQuotaColumn() {
CustomSelectionCell customSelectionCell = new CustomSelectionCell(new ArrayList<String>());
// $NON-NLS-1$
customSelectionCell.setStyle("input-group col-xs-11 gwt-ListBox");
Column<D, String> column = new Column<D, String>(customSelectionCell) {
@Override
public String getValue(D object) {
Guid clusterId = object.getCluster().getSelectedItem() != null ? object.getCluster().getSelectedItem().getId() : null;
List<Quota> quotas = registerEntityModel.getClusterQuotasMap().getEntity().get(clusterId);
object.getClusterQuota().setItems(quotas);
((CustomSelectionCell) getCell()).setOptions(registerEntityModel.getQuotaNames(quotas));
return object.getClusterQuota().getSelectedItem() != null ? object.getClusterQuota().getSelectedItem().getQuotaName() : constants.empty();
}
};
column.setFieldUpdater((index, object, value) -> registerEntityModel.selectQuotaByName(value, object.getClusterQuota()));
return column;
}
Aggregations