Search in sources :

Example 86 with DiskVmElement

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

the class DisksTree method getRootItem.

@Override
protected TreeItem getRootItem(DiskImage disk) {
    HorizontalPanel panel = new HorizontalPanel();
    panel.setSpacing(1);
    // $NON-NLS-1$
    panel.setWidth("100%");
    DiskVmElement dve = disk.getDiskVmElements().iterator().next();
    // $NON-NLS-1$
    addItemToPanel(panel, new Image(resources.diskImage()), "25px");
    // $NON-NLS-1$
    addTextBoxToPanel(panel, new StringValueLabel(), disk.getDiskAlias(), "");
    // $NON-NLS-1$
    addItemToPanel(panel, dve.isReadOnly() ? new Image(resources.readOnlyDiskIcon()) : new Image(), "60px");
    // $NON-NLS-1$
    addValueLabelToPanel(panel, new DiskSizeLabel<Long>(), disk.getSizeInGigabytes(), "120px");
    // $NON-NLS-1$
    addValueLabelToPanel(panel, new DiskSizeLabel<Long>(SizeConverter.SizeUnit.BYTES), disk.getActualSizeInBytes(), "120px");
    // $NON-NLS-1$
    addValueLabelToPanel(panel, new EnumLabel<ImageStatus>(), disk.getImageStatus(), "120px");
    // $NON-NLS-1$
    addValueLabelToPanel(panel, new EnumLabel<VolumeType>(), disk.getVolumeType(), "120px");
    // $NON-NLS-1$
    addValueLabelToPanel(panel, new EnumLabel<DiskInterface>(), dve.getDiskInterface(), "120px");
    // $NON-NLS-1$
    addValueLabelToPanel(panel, new EnumLabel<DiskStorageType>(), disk.getDiskStorageType(), "120px");
    // $NON-NLS-1$
    addValueLabelToPanel(panel, new FullDateTimeLabel(), disk.getCreationDate(), "140px");
    TreeItem treeItem = new TreeItem(panel);
    treeItem.setUserObject(disk.getId());
    return treeItem;
}
Also used : TreeItem(com.google.gwt.user.client.ui.TreeItem) ImageStatus(org.ovirt.engine.core.common.businessentities.storage.ImageStatus) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Image(com.google.gwt.user.client.ui.Image) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) StringValueLabel(org.ovirt.engine.ui.common.widget.label.StringValueLabel) FullDateTimeLabel(org.ovirt.engine.ui.webadmin.widget.label.FullDateTimeLabel) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface)

Example 87 with DiskVmElement

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

the class VmValidator method populateDisksWithVmData.

private void populateDisksWithVmData(Collection<? extends Disk> disks, Guid vmId) {
    for (Disk disk : disks) {
        DiskVmElement dve = getDiskVmElementDao().get(new VmDeviceId(disk.getId(), vmId));
        disk.setDiskVmElements(Collections.singletonList(dve));
    }
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 88 with DiskVmElement

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

the class AddDiskCommandTest method mockVmWithDisk.

/**
 * Mock a VM that has a disk.
 *
 * @param storageId
 *            Storage domain id of the disk.
 */
private void mockVmWithDisk(Guid storageId) {
    DiskImage image = new DiskImage();
    image.setId(Guid.newGuid());
    image.setStorageIds(new ArrayList<>(Collections.singletonList(storageId)));
    DiskVmElement dve = new DiskVmElement(image.getId(), vmId);
    image.setDiskVmElements(Collections.singletonList(dve));
    mockVm().getDiskMap().put(image.getId(), image);
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 89 with DiskVmElement

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

the class NewDiskModel method initialize.

@Override
public void initialize() {
    super.initialize();
    setDiskVmElement(new DiskVmElement(new VmDeviceId(null, getIsFloating() ? null : getVm().getId())));
    if (!getIsFloating()) {
        if (getIsBootable().getIsChangable()) {
            getIsBootable().setEntity(true);
        }
        updateSuggestedDiskAliasFromServer();
        getIsPlugged().setIsAvailable(true);
    } else {
        // Read only disk can be created only in the scope of VM.
        getIsReadOnly().setIsAvailable(false);
        getIsPlugged().setEntity(false);
        getIsBootable().setIsAvailable(false);
        getDiskInterface().setIsAvailable(false);
        getPassDiscard().setIsAvailable(false);
        // set using scsi reservation to be invisible
        getIsUsingScsiReservation().setIsAvailable(false);
        getIsUsingScsiReservation().setEntity(false);
    }
    getSizeExtend().setIsAvailable(false);
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 90 with DiskVmElement

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

the class VmDiskListModel method createPlugOrUnplugParams.

private ArrayList<ActionParametersBase> createPlugOrUnplugParams(boolean plug) {
    ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
    VM vm = getEntity();
    for (Object item : getSelectedItems()) {
        Disk disk = (Disk) item;
        disk.setPlugged(plug);
        parametersList.add(new VmDiskOperationParameterBase(new DiskVmElement(disk.getId(), vm.getId())));
    }
    return parametersList;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)

Aggregations

DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)91 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)30 Test (org.junit.Test)26 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)23 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)22 Guid (org.ovirt.engine.core.compat.Guid)17 ArrayList (java.util.ArrayList)16 VM (org.ovirt.engine.core.common.businessentities.VM)12 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)11 HashMap (java.util.HashMap)8 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)8 Map (java.util.Map)7 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)7 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)7 ActionType (org.ovirt.engine.core.common.action.ActionType)6 AttachDetachVmDiskParameters (org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 VmDiskOperationParameterBase (org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)5 Collection (java.util.Collection)4