Search in sources :

Example 96 with DiskImage

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

the class ImportVmFromExportDomainPopupView method initDiskTable.

private void initDiskTable() {
    diskTable = new ListModelObjectCellTable<>();
    diskTable.enableColumnResizing();
    AbstractTextColumn<DiskImage> aliasColumn = new AbstractTextColumn<DiskImage>() {

        @Override
        public String getValue(DiskImage object) {
            return object.getDiskAlias();
        }
    };
    // $NON-NLS-1$
    diskTable.addColumn(aliasColumn, constants.aliasDisk(), "100px");
    AbstractImageResourceColumn<DiskImage> bootableDiskColumn = new AbstractImageResourceColumn<DiskImage>() {

        @Override
        public ImageResource getValue(DiskImage object) {
            return object.getDiskVmElements().iterator().next().isBoot() ? getDefaultImage() : null;
        }

        @Override
        public ImageResource getDefaultImage() {
            return resources.bootableDiskIcon();
        }

        @Override
        public SafeHtml getTooltip(DiskImage object) {
            if (object.getDiskVmElements().iterator().next().isBoot()) {
                return SafeHtmlUtils.fromSafeConstant(constants.bootableDisk());
            }
            return null;
        }
    };
    diskTable.addColumn(bootableDiskColumn, new ImageResourceHeader(DisksViewColumns.bootableDiskColumn.getDefaultImage(), SafeHtmlUtils.fromSafeConstant(constants.bootableDisk())), // $NON-NLS-1$
    "30px");
    AbstractDiskSizeColumn<DiskImage> sizeColumn = new AbstractDiskSizeColumn<DiskImage>() {

        @Override
        protected Long getRawValue(DiskImage object) {
            return object.getSize();
        }
    };
    // $NON-NLS-1$
    diskTable.addColumn(sizeColumn, constants.provisionedSizeDisk(), "130px");
    AbstractDiskSizeColumn<DiskImage> actualSizeColumn = new AbstractDiskSizeColumn<DiskImage>() {

        @Override
        protected Long getRawValue(DiskImage object) {
            return object.getActualSizeInBytes();
        }
    };
    // $NON-NLS-1$
    diskTable.addColumn(actualSizeColumn, constants.sizeDisk(), "130px");
    AbstractTextColumn<DiskImage> dateCreatedColumn = new AbstractFullDateTimeColumn<DiskImage>() {

        @Override
        protected Date getRawValue(DiskImage object) {
            return object.getCreationDate();
        }
    };
    // $NON-NLS-1$
    diskTable.addColumn(dateCreatedColumn, constants.dateCreatedInterface(), "120px");
    diskTable.setSelectionModel(new NoSelectionModel<DiskImage>());
    addAllocationColumn();
    diskTable.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AbstractFullDateTimeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn) ImageResourceHeader(org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 97 with DiskImage

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

the class GetVmsFullInfoFromExternalProviderVDSCommand method executeVdsBrokerCommand.

@Override
protected void executeVdsBrokerCommand() {
    vmListReturn = getBroker().getExternalVmList(getParameters().getUrl(), getParameters().getUsername(), getParameters().getPassword(), getParameters().getNamesOfVms());
    proceedProxyReturnValue();
    List<VM> vms = new ArrayList<>();
    List<VM> notDownVms = new ArrayList<>();
    for (Map<String, Object> map : vmListReturn.vmList) {
        VM vm = VdsBrokerObjectsBuilder.buildVmsDataFromExternalProvider(map);
        if (vm != null) {
            vm.setOrigin(getParameters().getOriginType());
            if (vm.getOrigin() == OriginType.KVM) {
                if (VmDeviceCommonUtils.isVirtIoScsiDiskInterfaceExists(vm.getStaticData())) {
                    VmDeviceCommonUtils.addVirtIoScsiDevice(vm.getStaticData());
                }
                if (!VmDeviceCommonUtils.hasCdDevice(vm.getStaticData())) {
                    VmDeviceCommonUtils.addCdDevice(vm.getStaticData());
                }
                for (DiskImage image : vm.getImages()) {
                    image.getDiskVmElementForVm(vm.getId()).setBoot(true);
                    break;
                }
            } else {
                // set default value in case of non KVM provider type
                // since VirtIO interface doesn't require having an appropriate controller
                // so validation will pass. This will anyway be overridden later by virt-v2v OVF.
                VmDeviceCommonUtils.setDiskInterfaceForVm(vm.getStaticData(), DiskInterface.VirtIO);
            }
            vms.add(vm);
            // identify vms not in Down status
            if (!vm.isDown()) {
                notDownVms.add(vm);
            }
        }
    }
    logNonDownVms(notDownVms);
    setReturnValue(vms);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 98 with DiskImage

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

the class VmSnapshotListViewItem method createDisksItemContainerPanel.

private Container createDisksItemContainerPanel(List<DiskImage> diskImages) {
    Row content = new Row();
    Column column = new Column(ColumnSize.MD_12);
    content.add(column);
    for (DiskImage image : diskImages) {
        DListElement dl = Document.get().createDLElement();
        dl.addClassName(DL_HORIZONTAL);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.statusDisk()), SafeHtmlUtils.fromString(getImageStatus(image.getImageStatus())), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.aliasDisk()), SafeHtmlUtils.fromString(image.getDiskAlias()), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.provisionedSizeDisk()), SafeHtmlUtils.fromString(String.valueOf(sizeRenderer.render(image.getSize()))), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.sizeDisk()), SafeHtmlUtils.fromString(String.valueOf(sizeRenderer.render(image.getActualSizeInBytes()))), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.allocationDisk()), SafeHtmlUtils.fromString(String.valueOf(VolumeType.forValue(image.getVolumeType().getValue()))), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.interfaceDisk()), SafeHtmlUtils.fromString(getInterface(image)), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.creationDateDisk()), SafeHtmlUtils.fromString(dateRenderer.render(image.getCreationDate())), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.diskSnapshotIDDisk()), SafeHtmlUtils.fromString(String.valueOf(image.getImageId())), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.typeDisk()), SafeHtmlUtils.fromString(String.valueOf(image.getDiskStorageType())), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.descriptionDisk()), SafeHtmlUtils.fromString(StringHelper.isNotNullOrEmpty(image.getDiskDescription()) ? image.getDiskDescription() : constants.notAvailableLabel()), dl);
        column.getElement().appendChild(dl);
    }
    if (diskImages.isEmpty()) {
        column.getElement().setInnerHTML(constants.noItemsToDisplay());
    }
    return createItemContainerPanel(content);
}
Also used : Column(org.gwtbootstrap3.client.ui.Column) Row(org.gwtbootstrap3.client.ui.Row) DListElement(com.google.gwt.dom.client.DListElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 99 with DiskImage

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

the class VmSnapshotCreatePopupWidget method updateMemoryWarning.

private void updateMemoryWarning(SnapshotModel model) {
    Collection<DiskImage> diskImages = model.getSnapshotDisks().getItems();
    List<DiskImage> selectedDiskImages = model.getSnapshotDisks().getSelectedItems();
    boolean partialDisksSelection = selectedDiskImages != null && diskImages.size() != selectedDiskImages.size();
    boolean includeMemory = model.getMemory().getEntity();
    SafeHtml warningImage = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.logWarningImage()).getHTML());
    HTML partialSnapshotWithMemoryWarningWidget = new HTML(templates.iconWithText(warningImage, constants.snapshotCreationWithMemoryAndPartialDisksWarning()));
    HTML memoryWarningWidget = new HTML(templates.iconWithText(warningImage, constants.snapshotCreationWithMemoryNotLiveWarning()));
    warningPanel.clear();
    // Show warning in case of saving memory to snapshot and excluding some disks.
    if (includeMemory && partialDisksSelection) {
        warningPanel.add(partialSnapshotWithMemoryWarningWidget);
    }
    // Show warning in case of saving memory since it is not really 'live'
    if (includeMemory) {
        warningPanel.add(memoryWarningWidget);
    }
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) HTML(com.google.gwt.user.client.ui.HTML) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 100 with DiskImage

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

the class DiskListModel method updateCopyAndMoveCommandAvailability.

private void updateCopyAndMoveCommandAvailability(List<Disk> disks) {
    boolean isCopyAllowed = true;
    boolean isMoveAllowed = true;
    if (disks == null || disks.isEmpty() || disks.get(0).getDiskStorageType() != DiskStorageType.IMAGE) {
        disableMoveAndCopyCommands();
        return;
    }
    Guid datacenterId = ((DiskImage) disks.get(0)).getStoragePoolId();
    boolean foundTemplateDisk = false;
    boolean foundVmDisk = false;
    boolean foundUnattachedDisk = false;
    for (Disk disk : disks) {
        if ((!isCopyAllowed && !isMoveAllowed) || disk.getDiskStorageType() != DiskStorageType.IMAGE) {
            disableMoveAndCopyCommands();
            return;
        }
        DiskImage diskImage = (DiskImage) disk;
        if (diskImage.getImageStatus() != ImageStatus.OK || !datacenterId.equals(diskImage.getStoragePoolId()) || diskImage.isOvfStore()) {
            disableMoveAndCopyCommands();
            return;
        }
        VmEntityType vmEntityType = disk.getVmEntityType();
        if (vmEntityType == null) {
            foundUnattachedDisk = true;
        } else if (vmEntityType.isTemplateType()) {
            foundTemplateDisk = true;
        } else if (vmEntityType.isVmType()) {
            foundVmDisk = true;
        }
        if (foundTemplateDisk && (foundUnattachedDisk || foundVmDisk)) {
            isCopyAllowed = false;
        }
        if (vmEntityType != null && vmEntityType.isTemplateType()) {
            isMoveAllowed = false;
        }
    }
    getCopyCommand().setIsExecutionAllowed(isCopyAllowed);
    getMoveCommand().setIsExecutionAllowed(isMoveAllowed);
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType)

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