use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class DiskImagesValidator method diskImagesSnapshotsNotAttachedToOtherVms.
public ValidationResult diskImagesSnapshotsNotAttachedToOtherVms(boolean onlyPlugged) {
LinkedList<String> pluggedDiskSnapshotInfo = new LinkedList<>();
for (DiskImage diskImage : diskImages) {
List<VmDevice> devices = getVmDeviceDao().getVmDevicesByDeviceId(diskImage.getId(), null);
for (VmDevice device : devices) {
if (device.getSnapshotId() != null && (!onlyPlugged || device.isPlugged())) {
VM vm = getVmDao().get(device.getVmId());
Snapshot snapshot = getSnapshotDao().get(device.getSnapshotId());
pluggedDiskSnapshotInfo.add(String.format("%s ,%s, %s", diskImage.getDiskAlias(), snapshot.getDescription(), vm.getName()));
}
}
}
if (!pluggedDiskSnapshotInfo.isEmpty()) {
EngineMessage message = onlyPlugged ? EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_IS_PLUGGED_TO_ANOTHER_VM : EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_IS_ATTACHED_TO_ANOTHER_VM;
return new ValidationResult(message, String.format("$disksInfo %s", String.format(StringUtils.join(pluggedDiskSnapshotInfo, "%n"))));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class VmSnapshotListModel method remove.
private void remove() {
if (getEntity() != null) {
if (getWindow() != null) {
return;
}
Snapshot snapshot = getSelectedItem();
ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().deleteSnapshotTitle());
model.setHelpTag(HelpTag.delete_snapshot);
// $NON-NLS-1$
model.setHashName("delete_snapshot");
model.setMessage(ConstantsManager.getInstance().getMessages().areYouSureYouWantToDeleteSanpshot(DateTimeFormat.getFormat(DATE_FORMAT).format(snapshot.getCreationDate()), snapshot.getDescription()));
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class VmSnapshotListModel method onRemove.
private void onRemove() {
Snapshot snapshot = getSelectedItem();
if (snapshot == null) {
cancel();
return;
}
VM vm = getEntity();
if (vm != null) {
Frontend.getInstance().runAction(ActionType.RemoveSnapshot, new RemoveSnapshotParameters(snapshot.getId(), vm.getId()), null, null);
}
getCanSelectSnapshot().setEntity(false);
cancel();
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class VmSnapshotListModel method onCustomPreview.
private void onCustomPreview() {
VM vm = getEntity();
PreviewSnapshotModel previewSnapshotModel = (PreviewSnapshotModel) getWindow();
Snapshot snapshot = previewSnapshotModel.getSnapshotModel().getEntity();
boolean memory = Boolean.TRUE.equals(previewSnapshotModel.getSnapshotModel().getMemory().getEntity());
List<DiskImage> disks = previewSnapshotModel.getSelectedDisks();
boolean isSnapshotsContainsLeases = previewSnapshotModel.isSnapshotsContainsLeases();
Guid selectedSnapshotLeaseDomainId = previewSnapshotModel.getSelectedLease();
runTryBackToAllSnapshotsOfVm(previewSnapshotModel, vm, snapshot, memory, disks, !(isSnapshotsContainsLeases && selectedSnapshotLeaseDomainId == null), selectedSnapshotLeaseDomainId);
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class VmSnapshotListModel method preview.
private void preview() {
VM vm = getEntity();
if (vm == null) {
return;
}
final Snapshot snapshot = getSelectedItem();
AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(v -> {
ArrayList<DiskImage> snapshotDisks = v.getDiskList();
List<DiskImage> disksExcludedFromSnapshot = imagesSubtract(getVmDisks(), snapshotDisks);
boolean showMemorySnapshotWarning = isMemorySnapshotSupported() && snapshot.containsMemory();
boolean showPartialSnapshotWarning = !disksExcludedFromSnapshot.isEmpty();
if (showMemorySnapshotWarning || showPartialSnapshotWarning) {
SnapshotModel model = new SnapshotModel();
model.setVmDisks(getVmDisks());
model.setDisks(snapshotDisks);
model.setShowMemorySnapshotWarning(showMemorySnapshotWarning);
model.setShowPartialSnapshotWarning(showPartialSnapshotWarning);
if (showMemorySnapshotWarning) {
model.setOldClusterVersionOfSnapshotWithMemory(v);
}
setWindow(model);
model.setTitle(showPartialSnapshotWarning ? ConstantsManager.getInstance().getConstants().previewPartialSnapshotTitle() : ConstantsManager.getInstance().getConstants().previewSnapshotTitle());
model.setHelpTag(showPartialSnapshotWarning ? HelpTag.preview_partial_snapshot : HelpTag.preview_snapshot);
// $NON-NLS-1$ //$NON-NLS-2$
model.setHashName(showPartialSnapshotWarning ? "preview_partial_snapshot" : "preview_snapshot");
// $NON-NLS-1$
addCommands(model, "OnPreview");
} else {
runTryBackToAllSnapshotsOfVm(null, v, snapshot, false, null, true, null);
}
}), snapshot.getId());
}
Aggregations