use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class HotUnplugMemoryCommand method getNextRunConfiguration.
private VmStatic getNextRunConfiguration() {
final Snapshot snapshot = snapshotDao.get(getVmId(), Snapshot.SnapshotType.NEXT_RUN);
if (snapshot == null) {
return null;
}
final VM vm = snapshotVmConfigurationHelper.getVmFromConfiguration(snapshot.getVmConfiguration(), snapshot.getVmId(), snapshot.getId());
return vm.getStaticData();
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class IsBalloonEnabledQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Snapshot snapshot = snapshotDao.get(getParameters().getId(), Snapshot.SnapshotType.NEXT_RUN, getUserID(), getParameters().isFiltered());
if (snapshot != null) {
VM vm = snapshotVmConfigurationHelper.getVmFromConfiguration(snapshot.getVmConfiguration(), snapshot.getVmId(), snapshot.getId());
getQueryReturnValue().setReturnValue(VmDeviceCommonUtils.isVmDeviceExists(vm.getManagedVmDeviceMap(), VmDeviceType.MEMBALLOON));
} else {
getQueryReturnValue().setReturnValue(vmDeviceDao.isMemBalloonEnabled(getParameters().getId()));
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class SnapshotsValidator method isLeaseDomainIdBelongsToSnapshot.
/**
* Checks if that the destination lease domain ID belongs to one of the VM's snapshots.
*/
public ValidationResult isLeaseDomainIdBelongsToSnapshot(Guid vmId, Guid dstLeaseDomainId) {
List<Snapshot> allVmSnapshots = snapshotDao.getAllWithConfiguration(vmId);
boolean leaseStorageDomainValid = allVmSnapshots.stream().filter(snapshot -> snapshot.getVmConfiguration() != null).anyMatch(snapshot -> dstLeaseDomainId.equals(OvfUtils.fetchLeaseDomainId(snapshot.getVmConfiguration())));
return leaseStorageDomainValid ? ValidationResult.VALID : new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_LEASE_DOMAIN_ID_IS_NOT_VALID);
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ImportVmCommandTest method createVmWithNoSnapshots.
protected VM createVmWithNoSnapshots() {
final VM v = new VM();
v.setId(Guid.newGuid());
Snapshot activeSnapshot = new Snapshot();
activeSnapshot.setVmId(v.getId());
DiskImage activeImage = createDiskImage(Guid.newGuid(), Guid.newGuid(), activeSnapshot.getId(), true);
activeSnapshot.setDiskImages(Collections.singletonList(activeImage));
v.setImages(new ArrayList<>(Collections.singletonList(activeImage)));
v.setSnapshots(new ArrayList<>(Collections.singletonList(activeSnapshot)));
v.setDiskMap(Collections.singletonMap(activeImage.getId(), activeImage));
v.setClusterId(Guid.Empty);
return v;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ImportVmCommandTest method testAliasGenerationByAddVmImagesAndSnapshotsWithCollapse.
/* Tests for alias generation in addVmImagesAndSnapshots() */
@Test
public void testAliasGenerationByAddVmImagesAndSnapshotsWithCollapse() {
cmd.getParameters().setCopyCollapse(true);
cmd.init();
DiskImage collapsedDisk = cmd.getParameters().getVm().getImages().get(1);
doNothing().when(cmd).saveImage(collapsedDisk);
doNothing().when(cmd).saveBaseDisk(collapsedDisk);
doNothing().when(cmd).saveDiskImageDynamic(collapsedDisk);
doNothing().when(cmd).saveDiskVmElement(any(), any(), any());
doReturn(new Snapshot()).when(cmd).addActiveSnapshot(any());
cmd.addVmImagesAndSnapshots();
assertEquals("Disk alias not generated", "testVm_Disk1", collapsedDisk.getDiskAlias());
}
Aggregations