use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class MemoryUtils method getMemoryDiskIdsFromSnapshots.
public static Set<Guid> getMemoryDiskIdsFromSnapshots(List<Snapshot> snapshots) {
Set<Guid> memoryDiskIds = new HashSet<>();
for (Snapshot snapshot : snapshots) {
if (snapshot.containsMemory()) {
memoryDiskIds.add(snapshot.getMemoryDiskId());
memoryDiskIds.add(snapshot.getMetadataDiskId());
}
}
return memoryDiskIds;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ImportVmCommandTest method testCDANoCollapseNoSnapshots.
@Test
public void testCDANoCollapseNoSnapshots() {
final VM v = createVmWithNoSnapshots();
v.setName("testVm");
cmd.getParameters().setVm(v);
cmd.getParameters().setCopyCollapse(false);
cmd.init();
DiskImage activeDisk = cmd.getParameters().getVm().getImages().get(0);
doNothing().when(cmd).saveImage(activeDisk);
doNothing().when(cmd).saveDiskImageDynamic(activeDisk);
doNothing().when(cmd).saveBaseDisk(activeDisk);
doNothing().when(cmd).saveDiskVmElement(any(), any(), any());
doReturn(new Snapshot()).when(cmd).addActiveSnapshot(any());
cmd.addVmImagesAndSnapshots();
assertEquals("Disk alias not generated", "testVm_Disk1", activeDisk.getDiskAlias());
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class GetVmConfigurationBySnapshotQueryTest method createSnapshot.
private Snapshot createSnapshot(Guid existingSnapshotId) {
Snapshot snapshot = new Snapshot();
snapshot.setId(existingSnapshotId);
snapshot.setVmId(existingVmId);
snapshot.setVmConfiguration(EXISTING_VM_NAME);
return snapshot;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ExportVmCommand method copyAllMemoryImages.
private void copyAllMemoryImages(Guid containerID) {
for (Snapshot snapshot : snapshotsWithMemory) {
// copy the memory dump image
DiskImage dumpImage = (DiskImage) diskDao.get(snapshot.getMemoryDiskId());
ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryDumpImage(containerID, dumpImage));
if (!vdcRetValue.getSucceeded()) {
throw new EngineException(vdcRetValue.getFault().getError(), "Failed during ExportVmCommand");
}
// TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
// copy the memory configuration (of the VM) image
// This volume is always of type 'sparse' and format 'cow' so no need to convert,
// and there're no snapshots for it so no reason to use copy collapse
DiskImage confImage = (DiskImage) diskDao.get(snapshot.getMetadataDiskId());
vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParameters(containerID, confImage));
if (!vdcRetValue.getSucceeded()) {
throw new EngineException(vdcRetValue.getFault().getError(), "Failed during ExportVmCommand");
}
// TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ImportVmCommand method determineDomainsForMemoryImagesAndCreateDummies.
/**
* For each snapshot that has memory volume this method find a suitable storage domain and adds a dummy
* memory disks for future storage space validation
*
* @return true if we managed to assign storage domain for every memory volume, false otherwise
*/
private boolean determineDomainsForMemoryImagesAndCreateDummies(List<DiskImage> disksList) {
for (Snapshot snapshot : getVm().getSnapshots()) {
if (!snapshot.containsMemory() || memoryDiskDomainMap.containsKey(snapshot.getMemoryDiskId())) {
continue;
}
StorageDomain storageDomain = findDomainForMemoryImagesAndCreateDummies(disksList);
if (storageDomain == null) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_NO_SUITABLE_DOMAIN_FOUND);
}
memoryDiskDomainMap.put(snapshot.getMemoryDiskId(), storageDomain.getId());
memoryDiskDomainMap.put(snapshot.getMetadataDiskId(), storageDomain.getId());
}
return true;
}
Aggregations