Search in sources :

Example 6 with DiskImage

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

the class ExportRepoImageModel method setDiskImages.

public void setDiskImages(List<DiskImage> diskImages) {
    ArrayList<EntityModel> entities = new ArrayList<>();
    for (DiskImage i : diskImages) {
        entities.add(new EntityModel(i));
    }
    setEntities(entities);
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 7 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage 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)

Example 8 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage 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 9 with DiskImage

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

the class VmListModel method initRemoveDisksChecboxesPost.

private void initRemoveDisksChecboxesPost(Guid vmId, List<Disk> disks) {
    EntityModel model = vmsRemoveMap.get(vmId);
    if (disks.isEmpty()) {
        updateRemoveDisksCheckBox(model, false, false, ConstantsManager.getInstance().getConstants().removeVmDisksNoDisksMsg());
        return;
    }
    boolean isOnlySharedDisks = true;
    boolean isSnapshotExists = false;
    for (Disk disk : disks) {
        if (!disk.isShareable()) {
            isOnlySharedDisks = false;
            if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
                if (((DiskImage) disk).getSnapshots().size() > 1) {
                    isSnapshotExists = true;
                    break;
                }
            }
        }
    }
    if (isSnapshotExists) {
        updateRemoveDisksCheckBox(model, true, false, ConstantsManager.getInstance().getConstants().removeVmDisksSnapshotsMsg());
        return;
    }
    if (isOnlySharedDisks) {
        updateRemoveDisksCheckBox(model, false, false, ConstantsManager.getInstance().getConstants().removeVmDisksAllSharedMsg());
        return;
    }
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 10 with DiskImage

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

the class VmModelBehaviorBase method initTemplateDisks.

protected void initTemplateDisks(List<DiskImage> disks) {
    disks.sort(new DiskByDiskAliasComparator());
    ArrayList<DiskModel> list = new ArrayList<>();
    for (DiskImage disk : disks) {
        DiskModel diskModel = new DiskModel();
        diskModel.getAlias().setEntity(disk.getDiskAlias());
        diskModel.getVolumeType().setIsAvailable(false);
        switch(disk.getDiskStorageType()) {
            case IMAGE:
                diskModel.setSize(new EntityModel<>((int) disk.getSizeInGigabytes()));
                ListModel volumes = new ListModel();
                volumes.setItems(disk.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Collections.singletonList(VolumeType.Preallocated)) : AsyncDataProvider.getInstance().getVolumeTypeList(), disk.getVolumeType());
                diskModel.setVolumeType(volumes);
                break;
            case CINDER:
                CinderDisk cinderDisk = (CinderDisk) disk;
                diskModel.setSize(new EntityModel<>((int) cinderDisk.getSizeInGigabytes()));
                ListModel volumeTypes = new ListModel();
                volumeTypes.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeType())), cinderDisk.getVolumeType());
                diskModel.setVolumeType(volumeTypes);
                ListModel volumeFormats = new ListModel();
                volumeFormats.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeFormat())), cinderDisk.getVolumeFormat());
                diskModel.setVolumeFormat(volumeFormats);
                break;
        }
        diskModel.setDisk(disk);
        list.add(diskModel);
    }
    getModel().setDisks(list);
    updateIsDisksAvailable();
    initStorageDomains();
}
Also used : ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

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