use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class DiskSnapshotsValidatorTest method diskSnapshotsCanBePreviewed.
@Test
public void diskSnapshotsCanBePreviewed() {
Snapshot activeSnapshot = getActiveSnapshot();
when(snapshotDao.get(any())).thenReturn(activeSnapshot);
assertThat(validator.canDiskSnapshotsBePreviewed(activeSnapshot.getId()), isValid());
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class SnapshotModel method updateVmConfiguration.
public void updateVmConfiguration(final AsyncCallback<Void> onUpdateAsyncCallback) {
Snapshot snapshot = getEntity();
if (snapshot == null) {
return;
}
AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(vm -> {
Snapshot snapshot1 = getEntity();
if (vm != null && snapshot1 != null) {
setVm(vm);
setDisks(vm.getDiskList());
setNics(vm.getInterfaces());
setApps(Arrays.asList(snapshot1.getAppList() != null ? snapshot1.getAppList().split(",") : // $NON-NLS-1$
new String[] {}));
Collections.sort(getDisks(), new DiskByDiskAliasComparator());
Collections.sort(getNics(), new LexoNumericNameableComparator<>());
}
onUpdateAsyncCallback.onSuccess(null);
}), snapshot.getId());
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class SnapshotModel method showWarningForByVmSnapshotsValidation.
private boolean showWarningForByVmSnapshotsValidation(List<Snapshot> snapshots) {
for (Snapshot snapshot : snapshots) {
if (!validateNewSnapshotByStatus(snapshot.getStatus()) || !validateNewSnapshotByType(snapshot.getType())) {
getDescription().setIsAvailable(false);
getMemory().setIsAvailable(false);
return true;
}
}
return false;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class RunVmCommand method removeMemoryFromActiveSnapshot.
private void removeMemoryFromActiveSnapshot() {
// getActiveSnapshot fetches eagerly from the DB, cache it so we can remove the memory volumes
Snapshot activeSnapshot = getActiveSnapshot();
if (!activeSnapshot.containsMemory()) {
return;
}
snapshotDao.removeMemoryFromActiveSnapshot(getVmId());
// If the memory volumes are not used by any other snapshot, we can remove them
if (snapshotDao.getNumOfSnapshotsByDisks(activeSnapshot) == 0) {
removeMemoryDisks(activeSnapshot);
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ProcessDownVmCommand method applyNextRunConfiguration.
/**
* Update VM configuration with NEXT_RUN configuration, if exists.
*/
private void applyNextRunConfiguration() {
// Remove snpashot first, in case other update is in progress, it will block this one with exclusive lock
// and any newer update should be preffered to this one.
Snapshot runSnap = snapshotDao.get(getVmId(), SnapshotType.NEXT_RUN);
if (runSnap != null && getVm().getStatus() != VMStatus.Suspended) {
log.debug("Attempt to apply NEXT_RUN snapshot for VM '{}'", getVmId());
EngineLock updateVmLock = createUpdateVmLock();
if (lockManager.acquireLock(updateVmLock).getFirst()) {
snapshotDao.remove(runSnap.getId());
Date originalCreationDate = getVm().getVmCreationDate();
snapshotsManager.updateVmFromConfiguration(getVm(), runSnap.getVmConfiguration());
// override creation date because the value in the config is the creation date of the config, not the vm
getVm().setVmCreationDate(originalCreationDate);
ActionReturnValue result = runInternalAction(ActionType.UpdateVm, createUpdateVmParameters(), ExecutionHandler.createInternalJobContext(updateVmLock));
if (result.getActionReturnValue() != null && result.getActionReturnValue().equals(ActionType.UpdateVmVersion)) {
// Template-version changed
templateVersionChanged = true;
}
} else {
log.warn("Could not acquire lock for UpdateVmCommand to apply Next Run Config of VM '{}'", getVmId());
}
}
}
Aggregations