Search in sources :

Example 86 with DiskImage

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

the class StorageDomainModel method getDisksModels.

public ArrayList<DiskModel> getDisksModels() {
    ArrayList<DiskModel> diskModels = new ArrayList<>();
    for (DiskImage diskImage : getDisks()) {
        DiskModel diskModel = new DiskModel();
        diskModel.setDisk(diskImage);
        ListModel<StorageDomain> storageDomain = new ListModel<>();
        storageDomain.setSelectedItem(getStorageDomain());
        diskModel.setStorageDomain(storageDomain);
        diskModels.add(diskModel);
    }
    return diskModels;
}
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) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 87 with DiskImage

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

the class UploadImageModel method flush.

public boolean flush() {
    if (validate()) {
        diskModel.flush();
        DiskImage diskImage = (DiskImage) getDiskModel().getDisk();
        diskImage.setActualSizeInBytes(getImageSize());
        diskImage.setVolumeFormat(getImageInfoModel().getFormat());
        diskImage.setVolumeType(AsyncDataProvider.getInstance().getVolumeType(diskImage.getVolumeFormat(), getDiskModel().getStorageDomain().getSelectedItem().getStorageType()));
        diskImage.setContentType(getImageInfoModel().getContentType());
        if (getImageInfoModel().getContentType() == DiskContentType.ISO) {
            diskImage.setSize(getImageSize());
        }
        return true;
    } else {
        setIsValid(false);
    }
    return false;
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 88 with DiskImage

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

the class AbstractDiskModel method updateQuota.

private void updateQuota(StoragePool datacenter) {
    if (datacenter.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED) || !getDiskStorageType().getEntity().isInternal()) {
        getQuota().setIsAvailable(false);
        return;
    }
    getQuota().setIsAvailable(true);
    StorageDomain storageDomain = getStorageDomain().getSelectedItem();
    if (storageDomain == null) {
        return;
    }
    final Guid diskQuota = getDisk() != null ? ((DiskImage) getDisk()).getQuotaId() : null;
    final Guid vmQuota = getVm() != null ? getVm().getQuotaId() : null;
    final Guid defaultQuota = diskQuota != null ? diskQuota : vmQuota;
    AsyncDataProvider.getInstance().getAllRelevantQuotasForStorageSorted(new AsyncQuery<>(quotaList -> {
        if (quotaList != null && !quotaList.isEmpty()) {
            getQuota().setItems(quotaList);
            // If list contains default quota, return
            if (quotaList.get(0).getId().equals(defaultQuota)) {
                return;
            }
        }
        if (diskQuota != null) {
            Quota quota = new Quota();
            quota.setId(diskQuota);
            quota.setQuotaName(getDiskImage().getQuotaName());
            if (quotaList == null) {
                quotaList = new ArrayList<>();
            }
            quotaList.add(quota);
            getQuota().setItems(quotaList);
            getQuota().setSelectedItem(quota);
        }
    }), storageDomain.getId(), defaultQuota);
}
Also used : Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Event(org.ovirt.engine.ui.uicompat.Event) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) Version(org.ovirt.engine.core.compat.Version) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Predicate(java.util.function.Predicate) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Collectors(java.util.stream.Collectors) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NotEmptyQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) Frontend(org.ovirt.engine.ui.frontend.Frontend) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Quota(org.ovirt.engine.core.common.businessentities.Quota) VM(org.ovirt.engine.core.common.businessentities.VM) ScsiGenericIO(org.ovirt.engine.core.common.businessentities.storage.ScsiGenericIO) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 89 with DiskImage

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

the class CopyDiskModel method onInitDisks.

@Override
protected void onInitDisks() {
    ArrayList<DiskModel> disks = new ArrayList<>();
    for (DiskImage disk : getDiskImages()) {
        disks.add(DiskModel.diskToModel(disk));
    }
    setDisks(disks);
    initStorageDomains();
}
Also used : MoveOrCopyDiskModel(org.ovirt.engine.ui.uicommonweb.models.storage.MoveOrCopyDiskModel) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 90 with DiskImage

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

the class TemplateDiskListModel method changeQuota.

private void changeQuota() {
    ArrayList<DiskImage> disks = (ArrayList<DiskImage>) getSelectedItems();
    if (disks == null || getWindow() != null) {
        return;
    }
    ChangeQuotaModel model = new ChangeQuotaModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().assignQuotaForDisk());
    model.setHelpTag(HelpTag.change_quota_disks);
    // $NON-NLS-1$
    model.setHashName("change_quota_disks");
    model.startProgress();
    model.init(disks);
    // $NON-NLS-1$
    model.getCommands().add(UICommand.createDefaultOkUiCommand("onChangeQuota", this));
    // $NON-NLS-1$
    model.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Also used : ArrayList(java.util.ArrayList) ChangeQuotaModel(org.ovirt.engine.ui.uicommonweb.models.quota.ChangeQuotaModel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

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