Search in sources :

Example 16 with DiskModel

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

the class RegisterDiskModel method onExecute.

private void onExecute() {
    if (getProgress() != null) {
        return;
    }
    startProgress();
    for (DiskModel item : getDisks()) {
        DiskImage disk = (DiskImage) item.getDisk();
        if (item.getQuota().getSelectedItem() != null) {
            disk.setQuotaId(item.getQuota().getSelectedItem().getId());
        }
        RegisterDiskParameters registerDiskParams = new RegisterDiskParameters(disk, disk.getStorageIds().get(0));
        registerDiskParams.setRefreshFromStorage(true);
        Frontend.getInstance().runMultipleAction(ActionType.RegisterDisk, Arrays.asList(registerDiskParams));
    }
    stopProgress();
    getCancelCommand().execute();
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) RegisterDiskParameters(org.ovirt.engine.core.common.action.RegisterDiskParameters)

Example 17 with DiskModel

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

the class DisksAllocationModel method updateImageToDestinationDomainMap.

private void updateImageToDestinationDomainMap() {
    if (disks == null) {
        return;
    }
    for (DiskModel diskModel : disks) {
        StorageDomain storageDomain = diskModel.getStorageDomain().getSelectedItem();
        DiskImage diskImage = (DiskImage) diskModel.getDisk();
        diskImage.setStorageIds(new ArrayList<>(Collections.singletonList(storageDomain.getId())));
        diskImage.setDiskAlias(diskModel.getAlias().getEntity());
        DiskProfile diskProfile = diskModel.getDiskProfile().getSelectedItem();
        diskImage.setDiskProfileId(diskProfile != null ? diskProfile.getId() : null);
        if (diskModel.getQuota().getSelectedItem() != null) {
            diskImage.setQuotaId(diskModel.getQuota().getSelectedItem().getId());
        }
        if (diskModel.getVolumeFormat().getIsAvailable()) {
            VolumeFormat volumeFormat = diskModel.getVolumeFormat().getSelectedItem();
            diskImage.setVolumeFormat(volumeFormat);
            diskImage.setVolumeType(AsyncDataProvider.getInstance().getVolumeType(volumeFormat, storageDomain.getStorageType()));
        } else if (diskModel.getVolumeType().getIsAvailable()) {
            VolumeType volumeType = diskModel.getVolumeType().getSelectedItem();
            diskImage.setVolumeType(volumeType);
            diskImage.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(volumeType, storageDomain.getStorageType()));
        }
        imageToDestinationDomainMap.put(diskImage.getId(), diskImage);
    }
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 18 with DiskModel

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

the class DisksAllocationModel method setDisks.

public void setDisks(List<DiskModel> value) {
    disks = value;
    if (disks == null) {
        return;
    }
    sortDisks();
    setDefaultVolumeInformationSelection(disks);
    for (final DiskModel diskModel : disks) {
        diskModel.getStorageDomain().getSelectedItemChangedEvent().removeListener(storageDomainEventListener);
        diskModel.getStorageDomain().getSelectedItemChangedEvent().addListener(storageDomainEventListener);
        diskModel.getStorageDomain().getItemsChangedEvent().addListener((ev, sender, args) -> {
            DiskImage disk = (DiskImage) diskModel.getDisk();
            if (diskModel.getStorageDomain().getItems() != null && disk.getStorageIds() != null && !disk.getStorageIds().isEmpty() && !diskModel.getStorageDomain().getItems().isEmpty()) {
                diskModel.getStorageDomain().setSelectedItem(Linq.firstOrDefault(diskModel.getStorageDomain().getItems(), new Linq.IdsPredicate<>(disk.getStorageIds()), diskModel.getStorageDomain().getItems().iterator().next()));
            }
        });
    }
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 19 with DiskModel

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

the class DisksAllocationModel method updateDisks.

private void updateDisks(Object sender) {
    StorageDomain storageDomain = ((ListModel<StorageDomain>) sender).getSelectedItem();
    if (storageDomain != null) {
        for (DiskModel innerDisk : disks) {
            if (innerDisk.getStorageDomain().equals(sender)) {
                Guid diskQuotaId = null;
                if (innerDisk.getDisk() instanceof DiskImage) {
                    DiskImage img = (DiskImage) innerDisk.getDisk();
                    diskQuotaId = img.getQuotaId();
                }
                updateQuota(storageDomain.getId(), innerDisk.getQuota(), diskQuotaId);
                updateDiskProfile(storageDomain.getId(), innerDisk.getDiskProfile());
                break;
            }
        }
    }
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 20 with DiskModel

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

the class DisksAllocationModel method updateTargetChangeable.

public void updateTargetChangeable(boolean enabled) {
    if (disks != null) {
        for (DiskModel diskModel : disks) {
            diskModel.getStorageDomain().setIsChangeable(enabled);
            diskModel.getDiskProfile().setIsChangeable(enabled);
        }
    }
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel)

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