Search in sources :

Example 1 with DiskModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel 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 2 with DiskModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel 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)

Example 3 with DiskModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.

the class DisksAllocationModel method validateEntity.

@Override
public void validateEntity(IValidation[] validations) {
    super.validateEntity(validations);
    if (getDisks() == null) {
        return;
    }
    boolean isModelValid = true;
    for (DiskModel diskModel : getDisks()) {
        ListModel<StorageDomain> diskStorageDomains = diskModel.getStorageDomain();
        if (!diskStorageDomains.getItems().iterator().hasNext() || diskStorageDomains.getSelectedItem() == null) {
            diskModel.getStorageDomain().getInvalidityReasons().add(constants.storageDomainMustBeSpecifiedInvalidReason());
            diskModel.getStorageDomain().setIsValid(false);
            isModelValid = false;
        }
        diskModel.getAlias().validateEntity(new IValidation[] { new NotEmptyValidation(), new I18NNameValidation() });
        isModelValid = isModelValid && diskModel.getAlias().getIsValid();
    }
    setIsValid(isModelValid);
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)

Example 4 with DiskModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.

the class DisksAllocationModel method updateStorageDomainsAvailability.

private void updateStorageDomainsAvailability() {
    if (disks == null) {
        return;
    }
    for (DiskModel diskModel : disks) {
        diskModel.getSourceStorageDomain().setIsAvailable(isSourceStorageDomainAvailable);
        diskModel.getSourceStorageDomainName().setIsAvailable(isSourceStorageDomainNameAvailable);
        diskModel.getStorageDomain().setIsAvailable(isTargetAvailable);
        diskModel.getVolumeType().setIsAvailable(isVolumeTypeAvailable);
        diskModel.getVolumeType().setIsChangeable(isVolumeTypeChangable);
        diskModel.getVolumeFormat().setIsAvailable(isVolumeFormatAvailable);
        diskModel.getVolumeFormat().setIsChangeable(isVolumeFormatChangeable);
        diskModel.getAlias().setIsChangeable(isAliasChangable);
        boolean isCinder = diskModel.getDisk().getDiskStorageType() == DiskStorageType.CINDER;
        if (isCinder) {
            diskModel.getVolumeFormat().setIsChangeable(false);
            diskModel.getVolumeFormat().setSelectedItem(VolumeFormat.RAW);
        } else if (isThinProvisioning) {
            diskModel.getVolumeFormat().setSelectedItem(VolumeFormat.COW);
        }
    }
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel)

Example 5 with DiskModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.

the class MoveOrCopyDiskModel method getDestinationDomains.

private ArrayList<StorageDomain> getDestinationDomains(ArrayList<StorageDomain> activeStorageDomains, List<StorageDomain> sourceActiveStorageDomains, DiskModel diskModel, boolean isDiskBasedOnTemplate) {
    DiskImage diskImage = (DiskImage) diskModel.getDisk();
    DiskModel templateDisk = null;
    if (isDiskBasedOnTemplate) {
        templateDisk = getTemplateDiskByVmDisk(diskModel);
    }
    ArrayList<StorageDomain> destinationDomains = new ArrayList<>();
    for (StorageDomain sd : activeStorageDomains) {
        // Storage domain destination should not be a domain which the disk is attached to.
        if (!allowedStorageDomain(sourceActiveStorageDomains, diskImage, templateDisk, sd)) {
            continue;
        }
        // All conditions are valid for moving the current disk to this domain.
        destinationDomains.add(sd);
    }
    return destinationDomains;
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

DiskModel (org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel)24 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)13 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)9 ArrayList (java.util.ArrayList)8 DiskProfile (org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)4 Guid (org.ovirt.engine.core.compat.Guid)4 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)4 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)3 AttachDiskModel (org.ovirt.engine.ui.uicommonweb.models.vms.AttachDiskModel)3 I18NNameValidation (org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)3 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)2 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)2 VolumeFormat (org.ovirt.engine.core.common.businessentities.storage.VolumeFormat)2 VolumeType (org.ovirt.engine.core.common.businessentities.storage.VolumeType)2 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2