Search in sources :

Example 1 with DiskImage

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

the class DisksViewColumns method getQoutaColumn.

public static AbstractTextColumn<Disk> getQoutaColumn(String sortBy) {
    AbstractTextColumn<Disk> column = new AbstractTextColumn<Disk>() {

        @Override
        public String getValue(Disk object) {
            String value = "";
            if (object.getDiskStorageType() == DiskStorageType.IMAGE) {
                DiskImage diskImage = (DiskImage) object;
                List<String> quotaNamesArr = diskImage.getQuotaNames();
                if (quotaNamesArr != null) {
                    // $NON-NLS-1$
                    value = String.join(", ", quotaNamesArr);
                }
            }
            return value;
        }
    };
    return makeSortable(column, sortBy);
}
Also used : AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with DiskImage

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

the class StorageDomainsColumn method getValue.

@Override
public String getValue(Disk object) {
    if (object.getDiskStorageType() != DiskStorageType.IMAGE && object.getDiskStorageType() != DiskStorageType.CINDER) {
        return constants.empty();
    }
    DiskImage diskImage = (DiskImage) object;
    int numOfStorageDomains = diskImage.getStoragesNames() != null ? diskImage.getStoragesNames().size() : 0;
    if (numOfStorageDomains == 0) {
        return constants.empty();
    } else if (numOfStorageDomains == 1) {
        return diskImage.getStoragesNames().get(0);
    } else {
        return numOfStorageDomains + constants.space() + constants.storageDomainsLabelDisk();
    }
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 3 with DiskImage

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

the class DiskStatusColumn method getTooltip.

@Override
public SafeHtml getTooltip(Disk disk) {
    String tooltipContent;
    if (disk.getDiskStorageType().equals(DiskStorageType.IMAGE) || disk.getDiskStorageType().equals(DiskStorageType.CINDER)) {
        DiskImage diskImage = (DiskImage) disk;
        if (diskImage.getImageStatus().equals(ImageStatus.LOCKED)) {
            tooltipContent = EnumTranslator.getInstance().translate(diskImage.getImageStatus());
            return SafeHtmlUtils.fromString(tooltipContent);
        }
    }
    tooltipContent = disk.getPlugged() ? constants.active() : constants.inactive();
    return SafeHtmlUtils.fromString(tooltipContent);
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 4 with DiskImage

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

the class DisksAllocationModel method setDiskProfilesList.

private void setDiskProfilesList(final ListModel<DiskProfile> diskProfiles, List<DiskProfile> fetchedDiskProfiles) {
    if (fetchedDiskProfiles != null) {
        // normal flow, set items and selected item according to current selected.
        if (diskProfiles == null) {
            for (DiskModel diskModel : getDisks()) {
                diskModel.getDiskProfile().setItems(fetchedDiskProfiles);
                for (DiskProfile diskProfile : fetchedDiskProfiles) {
                    if (diskModel.getDisk().getDiskStorageType() == DiskStorageType.IMAGE && diskProfile.getId().equals(((DiskImage) diskModel.getDisk()).getDiskProfileId())) {
                        diskModel.getDiskProfile().setSelectedItem(diskProfile);
                    }
                }
            }
        // inner model disk profiles
        } else {
            DiskProfile selectedDiskProfile = null;
            if (diskProfiles.getSelectedItem() != null) {
                selectedDiskProfile = diskProfiles.getSelectedItem();
            }
            diskProfiles.setItems(fetchedDiskProfiles);
            if (selectedDiskProfile != null && fetchedDiskProfiles.size() > 1) {
                for (DiskProfile diskProfile : fetchedDiskProfiles) {
                    if (diskProfile.getId().equals(selectedDiskProfile.getId())) {
                        diskProfiles.setSelectedItem(diskProfile);
                        break;
                    }
                }
            }
        }
    }
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 5 with DiskImage

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

the class DisksAllocationModel method setDefaultVolumeInformationSelection.

protected void setDefaultVolumeInformationSelection(List<DiskModel> diskModels) {
    final Map<Guid, DiskModel> diskModelsMap = new HashMap<>();
    for (DiskModel diskModel : diskModels) {
        diskModelsMap.put(((DiskImage) diskModel.getDisk()).getImageId(), diskModel);
    }
    AsyncDataProvider.getInstance().getAncestorImagesByImagesIds(new AsyncQuery<>(imagesAncestors -> {
        for (Map.Entry<Guid, DiskImage> entry : imagesAncestors.entrySet()) {
            DiskModel diskModel = diskModelsMap.get(entry.getKey());
            diskModel.getVolumeType().setSelectedItem(entry.getValue().getVolumeType());
            diskModel.getVolumeFormat().setSelectedItem(entry.getValue().getVolumeFormat());
            updateStorageDomainsAvailability();
        }
    }), new ArrayList<>(diskModelsMap.keySet()));
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) HashMap(java.util.HashMap) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Quota(org.ovirt.engine.core.common.businessentities.Quota) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) Comparator(java.util.Comparator) Collections(java.util.Collections) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid)

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