Search in sources :

Example 11 with DiskModel

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

the class VmDiskAttachPopupWidget method initCinderDisksTable.

private void initCinderDisksTable() {
    cinderDiskTable.enableColumnResizing();
    AbstractTextColumn<EntityModel> aliasColumn = new AbstractTextColumn<EntityModel>() {

        @Override
        public String getValue(EntityModel object) {
            CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
            return disk.getDiskAlias();
        }
    };
    // $NON-NLS-1$
    cinderDiskTable.addColumn(aliasColumn, constants.aliasVmDiskTable(), "100px");
    AbstractTextColumn<EntityModel> descriptionColumn = new AbstractTextColumn<EntityModel>() {

        @Override
        public String getValue(EntityModel object) {
            CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
            return disk.getDiskDescription();
        }
    };
    // $NON-NLS-1$
    cinderDiskTable.addColumn(descriptionColumn, constants.descriptionVmDiskTable(), "100px");
    AbstractDiskSizeColumn<EntityModel> sizeColumn = new AbstractDiskSizeColumn<EntityModel>(SizeConverter.SizeUnit.GiB) {

        @Override
        protected Long getRawValue(EntityModel object) {
            CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
            return disk.getSizeInGigabytes();
        }
    };
    // $NON-NLS-1$
    cinderDiskTable.addColumn(sizeColumn, constants.provisionedSizeVmDiskTable(), "100px");
    // $NON-NLS-1$
    cinderDiskTable.addColumn(getDiskInterfaceSelectionColumn(), constants.interfaceVmDiskPopup(), "115px");
    AbstractTextColumn<EntityModel> cinderVolumeTypeColumn = new AbstractTextColumn<EntityModel>() {

        @Override
        public String getValue(EntityModel object) {
            Disk disk = ((DiskModel) object.getEntity()).getDisk();
            return disk.getCinderVolumeType();
        }
    };
    // $NON-NLS-1$
    cinderDiskTable.addColumn(cinderVolumeTypeColumn, constants.cinderVolumeTypeDisk(), "90px");
    cinderDiskTable.addColumn(getReadOnlyCheckBoxColumn(), new ImageResourceHeader(resources.readOnlyDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.readOnly())), // $NON-NLS-1$
    "30px");
    cinderDiskTable.addColumn(getBootCheckBoxColumn(), new ImageResourceHeader(resources.bootableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.bootableDisk())), // $NON-NLS-1$
    "30px");
    cinderDiskTable.addColumn(new AbstractImageResourceColumn<EntityModel>() {

        @Override
        public ImageResource getValue(EntityModel object) {
            Disk disk = ((DiskModel) object.getEntity()).getDisk();
            return disk.isShareable() ? resources.shareableDiskIcon() : null;
        }

        @Override
        public SafeHtml getTooltip(EntityModel object) {
            Disk disk = ((DiskModel) object.getEntity()).getDisk();
            if (disk.isShareable()) {
                return SafeHtmlUtils.fromSafeConstant(constants.shareable());
            }
            return null;
        }
    }, new ImageResourceHeader(resources.shareableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.shareable())), // $NON-NLS-1$
    "30px");
    // $NON-NLS-1$
    cinderDiskTable.setWidth("100%");
    cinderDiskTable.setEmptyTableWidget(new NoItemsLabel());
}
Also used : NoItemsLabel(org.ovirt.engine.ui.common.widget.label.NoItemsLabel) ImageResourceHeader(org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AttachDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AttachDiskModel) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) ImageResource(com.google.gwt.resources.client.ImageResource) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 12 with DiskModel

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

the class DisksAllocationView method addDiskList.

void addDiskList(DisksAllocationModel model) {
    diskListPanel.clear();
    diskAllocationLabel.setVisible(!model.getDisks().isEmpty());
    int diskIndex = 0;
    String columnWidth = calculateColumnWidthPercentage();
    for (final DiskModel diskModel : model.getDisks()) {
        DisksAllocationItemView disksAllocationItemView = new DisksAllocationItemView(columnWidth);
        disksAllocationItemView.edit(diskModel);
        disksAllocationItemView.setIsAliasChangeable(model.getIsAliasChangable());
        disksAllocationItemView.setElementId(// $NON-NLS-1$
        ElementIdUtils.createElementId(elementId, "disk" + diskIndex++));
        diskListPanel.add(disksAllocationItemView);
    }
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel)

Example 13 with DiskModel

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

the class AbstractDiskRemoveConfirmationPopupView method addItemText.

@Override
protected void addItemText(Object item) {
    DiskModel diskModel = (DiskModel) item;
    Disk disk = diskModel.getDisk();
    boolean isInVm = diskModel.getVm() != null;
    notes.clear();
    addItemLabel(getItemTextFormatted(disk.getDiskAlias()));
    if (disk.isShareable()) {
        notes.add(constants.shareable());
    }
    if (isInVm && disk.getDiskVmElementForVm(diskModel.getVm().getId()) != null && disk.getDiskVmElementForVm(diskModel.getVm().getId()).isBoot()) {
        notes.add(constants.bootable());
    }
    if (isInVm && disk.getNumberOfVms() > 1) {
        notes.add(messages.diskAttachedToOtherVMs(disk.getNumberOfVms() - 1, disk.getVmNames().get(0)));
    } else if (!isInVm && disk.getNumberOfVms() > 0) {
        notes.add(messages.diskAttachedToVMs(disk.getNumberOfVms()));
    }
    if (disk.getContentType() == DiskContentType.MEMORY_METADATA_VOLUME || disk.getContentType() == DiskContentType.MEMORY_DUMP_VOLUME) {
        notes.add(constants.memoryDisk());
    }
    if (!notes.isEmpty()) {
        String notes = constants.htmlTab() + messages.diskNote() + getFormattedNote();
        // $NON-NLS-1$ //$NON-NLS-2$
        addItemLabel(SafeHtmlUtils.fromSafeConstant("<b>" + notes + "</b>"));
    }
    addItemLabel(SafeHtmlUtils.fromSafeConstant(constants.lineBreak()));
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 14 with DiskModel

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

the class MoveOrCopyDiskModel method validate.

public boolean validate() {
    boolean quotaValidated = true;
    if (getQuotaEnforcementType() == QuotaEnforcementTypeEnum.DISABLED || getQuotaEnforcementType() == QuotaEnforcementTypeEnum.SOFT_ENFORCEMENT) {
        quotaValidated = false;
    }
    boolean isValid = true;
    for (DiskModel diskModel : getDisks()) {
        if (quotaValidated) {
            diskModel.getQuota().validateSelectedItem(new IValidation[] { new SelectedQuotaValidation() });
            isValid &= diskModel.getQuota().getIsValid();
        }
        diskModel.getAlias().validateEntity(new IValidation[] { new NotEmptyValidation(), new I18NNameValidation() });
        isValid &= diskModel.getAlias().getIsValid();
    }
    return isValid;
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) SelectedQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.SelectedQuotaValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)

Example 15 with DiskModel

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

the class MoveOrCopyDiskModel method postInitStorageDomains.

protected void postInitStorageDomains() {
    for (DiskModel disk : getDisks()) {
        DiskImage diskImage = (DiskImage) disk.getDisk();
        // Source storage domains
        List<Guid> diskStorageIds = diskImage.getStorageIds();
        List<StorageDomain> sourceStorageDomains = Linq.getStorageDomainsByIds(diskStorageIds, getActiveStorageDomains());
        boolean isDiskBasedOnTemplate = !diskImage.getParentId().equals(Guid.Empty);
        ArrayList<StorageDomain> destStorageDomains = getDestinationDomains(getActiveStorageDomains(), sourceStorageDomains, disk, isDiskBasedOnTemplate);
        // Add prohibition reasons
        if (sourceStorageDomains.isEmpty() || destStorageDomains.isEmpty()) {
            problematicDisks.add(disk.getAlias().getEntity());
            updateChangeability(disk, isDiskBasedOnTemplate, sourceStorageDomains.isEmpty(), destStorageDomains.isEmpty());
        }
        // Sort and add storage domains
        Collections.sort(destStorageDomains, new NameableComparator());
        Collections.sort(sourceStorageDomains, new NameableComparator());
        disk.getStorageDomain().setItems(destStorageDomains);
        disk.getSourceStorageDomain().setItems(sourceStorageDomains);
        addSourceStorageDomainName(disk, sourceStorageDomains);
    }
    sortDisks();
    postCopyOrMoveInit();
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) Guid(org.ovirt.engine.core.compat.Guid) 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