Search in sources :

Example 1 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile 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 DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class MoveOrCopyDiskModel method getParameters.

protected ArrayList<ActionParametersBase> getParameters() {
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (DiskModel diskModel : getDisks()) {
        StorageDomain destStorageDomain = diskModel.getStorageDomain().getSelectedItem();
        StorageDomain sourceStorageDomain = diskModel.getSourceStorageDomain().getSelectedItem();
        Guid sourceStorageDomainGuid = sourceStorageDomain != null ? sourceStorageDomain.getId() : Guid.Empty;
        DiskImage disk = (DiskImage) diskModel.getDisk();
        DiskProfile diskProfile = diskModel.getDiskProfile().getSelectedItem();
        disk.setDiskProfileId(diskProfile != null ? diskProfile.getId() : null);
        disk.setDiskAlias(diskModel.getAlias().getEntity());
        if (diskModel.getQuota().getSelectedItem() != null) {
            disk.setQuotaId(diskModel.getQuota().getSelectedItem().getId());
        }
        if (destStorageDomain == null || sourceStorageDomain == null) {
            continue;
        }
        Guid destStorageDomainGuid = destStorageDomain.getId();
        addMoveOrCopyParameters(parameters, sourceStorageDomainGuid, destStorageDomainGuid, disk);
    }
    return parameters;
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 3 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class DiskProfileBaseModel method flush.

@Override
public void flush() {
    if (getProfile() == null) {
        setProfile(new DiskProfile());
    }
    DiskProfile diskProfile = getProfile();
    diskProfile.setName(getName().getEntity());
    diskProfile.setDescription(getDescription().getEntity());
    StorageDomain storageDomain = getParentListModel().getSelectedItem();
    diskProfile.setStorageDomainId(storageDomain != null ? storageDomain.getId() : null);
    StorageQos storageQos = getQos().getSelectedItem();
    diskProfile.setQosId(storageQos != null && storageQos.getId() != null && !storageQos.getId().equals(Guid.Empty) ? storageQos.getId() : null);
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 4 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class DiskProfileHelper method updateDiskProfileForBackwardCompatibility.

private boolean updateDiskProfileForBackwardCompatibility(DiskImage diskImage, List<DiskProfile> diskProfilesList, Set<Guid> permittedDiskProfilesIds, DbUser user) {
    for (DiskProfile diskProfile : diskProfilesList) {
        if (isDiskProfilePermitted(diskProfile, permittedDiskProfilesIds, user)) {
            permittedDiskProfilesIds.add(diskProfile.getId());
            diskImage.setDiskProfileId(diskProfile.getId());
            return true;
        }
    }
    return false;
}
Also used : DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 5 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class DiskProfileHelper method createDiskProfile.

public DiskProfile createDiskProfile(Guid storageDomainId, String name) {
    DiskProfile profile = new DiskProfile();
    profile.setId(Guid.newGuid());
    profile.setName(name);
    profile.setStorageDomainId(storageDomainId);
    return profile;
}
Also used : DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Aggregations

DiskProfile (org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)19 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)7 Guid (org.ovirt.engine.core.compat.Guid)7 ArrayList (java.util.ArrayList)5 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)5 HashMap (java.util.HashMap)3 List (java.util.List)3 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 DiskModel (org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel)3 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)2 StorageQos (org.ovirt.engine.core.common.businessentities.qos.StorageQos)2 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1