Search in sources :

Example 91 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class DiskModel method diskToModel.

public static DiskModel diskToModel(Disk disk) {
    DiskModel diskModel = new DiskModel();
    diskModel.getAlias().setEntity(disk.getDiskAlias());
    if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
        DiskImage diskImage = (DiskImage) disk;
        EntityModel<Integer> sizeEntity = new EntityModel<>();
        sizeEntity.setEntity((int) diskImage.getSizeInGigabytes());
        diskModel.setSize(sizeEntity);
        ListModel<VolumeType> volumeList = new ListModel<>();
        volumeList.setItems(diskImage.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Arrays.asList(new VolumeType[] { VolumeType.Preallocated })) : AsyncDataProvider.getInstance().getVolumeTypeList());
        volumeList.setSelectedItem(diskImage.getVolumeType());
        diskModel.setVolumeType(volumeList);
    }
    diskModel.setDisk(disk);
    return diskModel;
}
Also used : VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 92 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class EditDiskModel method datacenter_SelectedItemChanged.

@Override
protected void datacenter_SelectedItemChanged() {
    super.datacenter_SelectedItemChanged();
    // this needs to be executed after the data center is loaded because the update quota needs both values
    if (getDisk().getDiskStorageType() == DiskStorageType.IMAGE) {
        Guid storageDomainId = ((DiskImage) getDisk()).getStorageIds().get(0);
        AsyncDataProvider.getInstance().getStorageDomainById(new AsyncQuery<>(storageDomain -> getStorageDomain().setSelectedItem(storageDomain)), storageDomainId);
    } else if (getDisk().getDiskStorageType() == DiskStorageType.LUN) {
        LunDisk lunDisk = (LunDisk) getDisk();
        getDiskStorageType().setEntity(DiskStorageType.LUN);
        getSize().setEntity(lunDisk.getLun().getDeviceSize());
        getSizeExtend().setIsAvailable(false);
    }
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) Arrays(java.util.Arrays) ActionUtils(org.ovirt.engine.core.common.ActionUtils) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Guid(org.ovirt.engine.core.compat.Guid) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VM(org.ovirt.engine.core.common.businessentities.VM) NonNegativeLongNumberValidation(org.ovirt.engine.ui.uicommonweb.validation.NonNegativeLongNumberValidation) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase) ScsiGenericIO(org.ovirt.engine.core.common.businessentities.storage.ScsiGenericIO) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Guid(org.ovirt.engine.core.compat.Guid) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 93 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class ImportVmFromExportDomainPopupView method addAllocationColumn.

protected void addAllocationColumn() {
    ArrayList<String> allocationTypes = new ArrayList<>();
    allocationTypes.add(constants.thinAllocation());
    allocationTypes.add(constants.preallocatedAllocation());
    customSelectionCellFormatType = new CustomSelectionCell(allocationTypes);
    customSelectionCellFormatType.setStyle(EMPTY_STYLE);
    AbstractColumn<DiskImage, String> allocationColumn = new AbstractColumn<DiskImage, String>(customSelectionCellFormatType) {

        @Override
        public String getValue(DiskImage disk) {
            ImportDiskData importData = importModel.getDiskImportData(disk.getId());
            if (importData == null) {
                return "";
            }
            return new EnumRenderer<VolumeType>().render(VolumeType.forValue(importData.getSelectedVolumeType().getValue()));
        }

        @Override
        public SafeHtml getTooltip(DiskImage object) {
            return SafeHtmlUtils.fromSafeConstant(constants.importAllocationModifiedCollapse());
        }
    };
    allocationColumn.setFieldUpdater((index, disk, value) -> {
        VolumeType tempVolumeType = VolumeType.Sparse;
        if (value.equals(constants.thinAllocation())) {
            tempVolumeType = VolumeType.Sparse;
        } else if (value.equals(constants.preallocatedAllocation())) {
            tempVolumeType = VolumeType.Preallocated;
        }
        ImportDiskData importData = importModel.getDiskImportData(disk.getId());
        if (importData != null) {
            importData.setSelectedVolumeType(tempVolumeType);
        }
    });
    // $NON-NLS-1$
    diskTable.addColumn(allocationColumn, constants.allocationDisk(), "150px");
}
Also used : VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) ArrayList(java.util.ArrayList) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) ImportDiskData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportDiskData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 94 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage 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");
}
Also used : CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) ImportDiskData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportDiskData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 95 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class ImportVmFromExportDomainPopupView method addStorageDomainsColumn.

private void addStorageDomainsColumn() {
    CustomSelectionCell customSelectionCellStorageDomain = new CustomSelectionCell(new ArrayList<String>());
    customSelectionCellStorageDomain.setStyle(EMPTY_STYLE);
    Column<DiskImage, String> storageDomainsColumn = new Column<DiskImage, String>(customSelectionCellStorageDomain) {

        @Override
        public String getValue(DiskImage disk) {
            ImportDiskData importData = importModel.getDiskImportData(disk.getId());
            ArrayList<String> storageDomainsNameList = new ArrayList<>();
            StorageDomain selectedStorageDomain = null;
            if (importData != null && importData.getStorageDomains() != null) {
                for (StorageDomain storageDomain : importData.getStorageDomains()) {
                    storageDomainsNameList.add(new StorageDomainFreeSpaceRenderer<>().render(storageDomain));
                    if (importData.getSelectedStorageDomain() != null) {
                        if (storageDomain.getId().equals(importData.getSelectedStorageDomain().getId())) {
                            selectedStorageDomain = storageDomain;
                        }
                    }
                }
            }
            ((CustomSelectionCell) getCell()).setOptions(storageDomainsNameList);
            if (!storageDomainsNameList.isEmpty()) {
                if (selectedStorageDomain != null) {
                    return new StorageDomainFreeSpaceRenderer<>().render(selectedStorageDomain);
                } else {
                    return storageDomainsNameList.get(0);
                }
            }
            return "";
        }
    };
    storageDomainsColumn.setFieldUpdater((index, disk, value) -> {
        // $NON-NLS-1$
        String storageDomainName = value.substring(0, value.lastIndexOf(" ("));
        importModel.getDiskImportData(disk.getId()).setSelectedStorageDomainString(storageDomainName);
        diskTable.asEditor().edit(importModel.getImportDiskListModel());
    });
    // $NON-NLS-1$
    diskTable.addColumn(storageDomainsColumn, constants.storageDomainDisk(), "180px");
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AbstractFullDateTimeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ArrayList(java.util.ArrayList) ImportDiskData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportDiskData) StorageDomainFreeSpaceRenderer(org.ovirt.engine.ui.common.widget.renderer.StorageDomainFreeSpaceRenderer) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)635 Guid (org.ovirt.engine.core.compat.Guid)212 ArrayList (java.util.ArrayList)167 Test (org.junit.Test)132 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)80 VM (org.ovirt.engine.core.common.businessentities.VM)77 HashMap (java.util.HashMap)64 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)62 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)62 List (java.util.List)56 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)48 Map (java.util.Map)39 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)38 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)35 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)34 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)31 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)31 EngineException (org.ovirt.engine.core.common.errors.EngineException)29 ActionType (org.ovirt.engine.core.common.action.ActionType)22 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)22