@JsonIgnore public Guid getSnapshotId() { return isDiskSnapshot() ? getVmSnapshotId() : null; }
private void updatePreviewedDiskSnapshots(final List<Snapshot> snapshots) { getVmDisks().stream().filter(d -> d.getSnapshots().size() > 1) .forEach(d -> getSnapshotsMap().get(d.getSnapshots().get(1).getVmSnapshotId()) .getEntity().getDiskImages().add(d)); updateItems(snapshots); }
private org.ovirt.engine.core.common.businessentities.storage.Disk setUpEntityExpectations(DiskImage entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmSnapshotId()).thenReturn(GUIDS[2]); when(entity.getVolumeFormat()).thenReturn(VolumeFormat.RAW); when(entity.getImageStatus()).thenReturn(ImageStatus.OK); when(entity.getVolumeType()).thenReturn(VolumeType.Sparse); when(entity.isShareable()).thenReturn(false); when(entity.getPropagateErrors()).thenReturn(PropagateErrors.On); when(entity.getDiskStorageType()).thenReturn(DiskStorageType.IMAGE); when(entity.getImageId()).thenReturn(GUIDS[1]); ArrayList<Guid> sdIds = new ArrayList<>(); sdIds.add(Guid.Empty); when(entity.getStorageIds()).thenReturn(sdIds); return setUpStatisticalEntityExpectations(entity); }
private org.ovirt.engine.core.common.businessentities.storage.Disk setUpEntityExpectations(DiskImage entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmSnapshotId()).thenReturn(GUIDS[2]); when(entity.getVolumeFormat()).thenReturn(VolumeFormat.RAW); when(entity.getImageStatus()).thenReturn(ImageStatus.OK); when(entity.getVolumeType()).thenReturn(VolumeType.Sparse); when(entity.isShareable()).thenReturn(false); when(entity.getPropagateErrors()).thenReturn(PropagateErrors.On); when(entity.getDiskStorageType()).thenReturn(DiskStorageType.IMAGE); when(entity.getImageId()).thenReturn(GUIDS[1]); ArrayList<Guid> sdIds = new ArrayList<>(); sdIds.add(Guid.Empty); when(entity.getStorageIds()).thenReturn(sdIds); return setUpStatisticalEntityExpectations(entity); }
static org.ovirt.engine.core.common.businessentities.storage.Disk setUpEntityExpectations(DiskImage entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmSnapshotId()).thenReturn(GUIDS[2]); when(entity.getVolumeFormat()).thenReturn(VolumeFormat.RAW); when(entity.getImageStatus()).thenReturn(ImageStatus.OK); when(entity.getVolumeType()).thenReturn(VolumeType.Sparse); when(entity.isShareable()).thenReturn(false); when(entity.getPropagateErrors()).thenReturn(PropagateErrors.On); when(entity.getDiskStorageType()).thenReturn(DiskStorageType.IMAGE); when(entity.getImageId()).thenReturn(GUIDS[1]); ArrayList<Guid> sdIds = new ArrayList<>(); sdIds.add(Guid.Empty); when(entity.getStorageIds()).thenReturn(sdIds); return setUpStatisticalEntityExpectations(entity); }
static org.ovirt.engine.core.common.businessentities.storage.Disk setUpEntityExpectations(DiskImage entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmSnapshotId()).thenReturn(GUIDS[2]); when(entity.getVolumeFormat()).thenReturn(VolumeFormat.RAW); when(entity.getImageStatus()).thenReturn(ImageStatus.OK); when(entity.getVolumeType()).thenReturn(VolumeType.Sparse); when(entity.isShareable()).thenReturn(false); when(entity.getPropagateErrors()).thenReturn(PropagateErrors.On); when(entity.getDiskStorageType()).thenReturn(DiskStorageType.IMAGE); when(entity.getImageId()).thenReturn(GUIDS[1]); ArrayList<Guid> sdIds = new ArrayList<>(); sdIds.add(Guid.Empty); when(entity.getStorageIds()).thenReturn(sdIds); return setUpStatisticalEntityExpectations(entity); }
@Test public void getDiskSnapshotForVmSnapshotSameSnapshot() { DiskImage result = dao.getDiskSnapshotForVmSnapshot(existingEntity.getId(), existingEntity.getVmSnapshotId()); assertNotNull(result); assertEquals(existingEntity.getId(), result.getId()); assertEquals(existingEntity.getVmSnapshotId(), result.getVmSnapshotId()); }
@Test public void testGetDiskSnapshotForVmSnapshot() { DiskImage result = dao.getDiskSnapshotForVmSnapshot(FixturesTool.IMAGE_GROUP_ID, FixturesTool.EXISTING_SNAPSHOT_ID); assertNotNull(result); assertEquals(FixturesTool.IMAGE_GROUP_ID, result.getId()); assertEquals(FixturesTool.EXISTING_SNAPSHOT_ID, result.getVmSnapshotId()); }
di.setVmSnapshotId(diskImage.getVmSnapshotId()); di.setId(diskImage.getId()); di.setNumberOfVms(diskImage.getNumberOfVms());
@Test public void getDiskSnapshotForVmSnapshotDifferentSnapshot() { DiskImage result1 = dao.getDiskSnapshotForVmSnapshot(existingEntity.getId(), FixturesTool.EXISTING_SNAPSHOT_ID); DiskImage result2 = dao.getDiskSnapshotForVmSnapshot(existingEntity.getId(), FixturesTool.EXISTING_SNAPSHOT_ID2); assertNotNull(result1); assertNotNull(result2); assertEquals(result1.getId(), result2.getId()); assertNotSame(result1.getImageId(), result2.getImageId(), "Images should be different"); assertNotSame(result1.getVmSnapshotId(), result2.getVmSnapshotId(), "Vm snapshots should be different"); }
@Override protected void writeDisk(DiskImage image) { DiskVmElement dve = image.getDiskVmElementForVm(vmBase.getId()); _writer.writeAttributeString(getOvfUri(), "diskId", image.getImageId().toString()); _writer.writeAttributeString(getOvfUri(), "size", String.valueOf(bytesToGigabyte(image.getSize()))); _writer.writeAttributeString(getOvfUri(), "actual_size", String.valueOf(bytesToGigabyte(image.getActualSizeInBytes()))); _writer.writeAttributeString(getOvfUri(), "vm_snapshot_id", (image.getVmSnapshotId() != null) ? image .getVmSnapshotId().toString() : ""); writeDiskParentRef(image); _writer.writeAttributeString(getOvfUri(), "fileRef", OvfParser.createImageFile(image)); _writer.writeAttributeString(getOvfUri(), "format", getVolumeImageFormat(image.getVolumeFormat())); _writer.writeAttributeString(getOvfUri(), "volume-format", image.getVolumeFormat().toString()); _writer.writeAttributeString(getOvfUri(), "volume-type", image.getVolumeType().toString()); _writer.writeAttributeString(getOvfUri(), "disk-interface", dve.getDiskInterface().toString()); _writer.writeAttributeString(getOvfUri(), "read-only", String.valueOf(dve.isReadOnly())); _writer.writeAttributeString(getOvfUri(), "shareable", String.valueOf(image.isShareable())); _writer.writeAttributeString(getOvfUri(), "boot", String.valueOf(dve.isBoot())); _writer.writeAttributeString(getOvfUri(), "pass-discard", String.valueOf(dve.isPassDiscard())); if (image.getDiskAlias() != null) { _writer.writeAttributeString(getOvfUri(), "disk-alias", image.getDiskAlias()); } if (image.getDiskDescription() != null) { _writer.writeAttributeString(getOvfUri(), "disk-description", image.getDiskDescription()); } _writer.writeAttributeString(getOvfUri(), "wipe-after-delete", String.valueOf(image.isWipeAfterDelete())); }