Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1403#discussion_r59085610 --- Diff: engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java --- @@ -279,7 +284,52 @@ public boolean deleteSnapshot(Long snapshotId) { @Override public boolean revertSnapshot(SnapshotInfo snapshot) { - throw new CloudRuntimeException("revert Snapshot is not supported"); + if (canHandle(snapshot,SnapshotOperation.REVERT) == StrategyPriority.CANT_HANDLE) { + throw new UnsupportedOperationException("Reverting not supported. Create a template or volume based on the snapshot instead."); + } + + SnapshotVO snapshotVO = _snapshotDao.acquireInLockTable(snapshot.getId()); + + if (snapshotVO == null) { + throw new CloudRuntimeException("Failed to get lock on snapshot:" + snapshot.getId()); + } + + try { + VolumeInfo volumeInfo = snapshot.getBaseVolume(); + StoragePool store = (StoragePool)volumeInfo.getDataStore(); + + if (store != null && store.getStatus() != StoragePoolStatus.Up) { + snapshot.processEvent(Event.OperationFailed); + + throw new CloudRuntimeException("store is not in up state"); + } + + volumeInfo.stateTransit(Volume.Event.RevertSnapshotRequested); + + boolean result = false; + + try { + result = snapshotSvr.revertSnapshot(snapshot); + + if (!result) { + s_logger.debug("Failed to revert snapshot: " + snapshot.getId()); --- End diff -- Why log an error here when the exception will eventually logged?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---