use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class VmHandler method createNextRunSnapshot.
/**
* @param objectWithEditableDeviceFields object with fields annotated with {@link EditableDeviceOnVmStatusField},
* usually a command parameters object
*/
public void createNextRunSnapshot(VM existingVm, VmStatic newVmStatic, Object objectWithEditableDeviceFields, CompensationContext compensationContext) {
// first remove existing snapshot
Snapshot runSnap = snapshotDao.get(existingVm.getId(), Snapshot.SnapshotType.NEXT_RUN);
if (runSnap != null) {
snapshotDao.remove(runSnap.getId());
}
final VM newVm = new VM();
newVm.setStaticData(newVmStatic);
// create new snapshot with new configuration
snapshotsManager.addSnapshot(Guid.newGuid(), "Next Run configuration snapshot", Snapshot.SnapshotStatus.OK, Snapshot.SnapshotType.NEXT_RUN, newVm, true, null, null, null, Collections.emptyList(), vmDeviceUtils.getVmDevicesForNextRun(existingVm, objectWithEditableDeviceFields, existingVm.getDefaultDisplayType()), compensationContext);
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class GetVmConfigurationBySnapshotQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Snapshot snapshot = snapshotDao.get(getParameters().getId(), getUserID(), getParameters().isFiltered());
VM vm = null;
if (snapshot == null) {
log.warn("Snapshot '{}' does not exist", getParameters().getId());
} else {
vm = snapshotVmConfigurationHelper.getVmFromConfiguration(snapshot.getVmConfiguration(), snapshot.getVmId(), snapshot.getId());
}
getQueryReturnValue().setReturnValue(vm);
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class GetVmNextRunConfigurationQuery 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());
// update information that is not saved in the config
vmHandler.updateDisksFromDb(vm);
vmHandler.updateVmGuestAgentVersion(vm);
vmHandler.updateNetworkInterfacesFromDb(vm);
vmHandler.updateVmStatistics(vm);
getQueryReturnValue().setReturnValue(vm);
} else {
// in case no next_run return static configuration
super.executeQueryCommand();
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class TryBackToAllSnapshotsOfVmCommandTest method setUp.
@Before
public void setUp() {
vm = new VM();
vm.setId(cmd.getParameters().getVmId());
when(vmDao.get(cmd.getParameters().getVmId())).thenReturn(vm);
Snapshot snapshot = new Snapshot();
snapshot.setId(cmd.getParameters().getDstSnapshotId());
snapshot.setVmId(cmd.getParameters().getVmId());
when(snapshotDao.get(cmd.getParameters().getDstSnapshotId())).thenReturn(snapshot);
doNothing().when(cmd).updateVmDisksFromDb();
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class GetAllDiskSnapshotsByStorageDomainIdQueryTest method setUpDaoMocks.
private void setUpDaoMocks() {
Guid snapshotId = Guid.newGuid();
Snapshot snapshot = new Snapshot(snapshotId, SnapshotStatus.OK, Guid.newGuid(), null, SnapshotType.REGULAR, snapshotDescription, new Date(), "");
DiskImage disk1 = new DiskImage();
disk1.setVmSnapshotId(snapshotId);
DiskImage disk2 = new DiskImage();
disk2.setVmSnapshotId(snapshotId);
DiskImage disk3 = new DiskImage();
disk3.setActive(true);
List<DiskImage> diskImages = Arrays.asList(disk1, disk2, disk3);
List<Snapshot> snapshots = Collections.singletonList(snapshot);
when(diskImageDao.getAllSnapshotsForStorageDomain(storageDoaminId)).thenReturn(diskImages);
when(snapshotDaoMock.getAllByStorageDomain(storageDoaminId)).thenReturn(snapshots);
}
Aggregations