Merge pull request #1168 from ustcweizhou/listSnapshots-Exception

CLOUDSTACK-8845: set isRevertable of snapshot to false if the volume is removedSome users encounter an exception when listSnapshots.
We should set the isRevertable of snapshot to false if the original volume is removed, without checking if the snapshot is stored in primary store (the exception was thowned during the checking).

* pr/1168:
  CLOUDSTACK-8845: set isRevertable of snapshot to false if the volume is removed

Signed-off-by: Daan Hoogland <daan@onecht.net>
This commit is contained in:
Daan Hoogland 2015-12-06 19:48:45 +01:00
commit 24113e425e
1 changed files with 6 additions and 7 deletions

View File

@ -442,6 +442,12 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
public StrategyPriority canHandle(Snapshot snapshot, SnapshotOperation op) {
long volumeId = snapshot.getVolumeId();
VolumeVO volumeVO = _volumeDao.findById(volumeId);
if (SnapshotOperation.REVERT.equals(op)) {
if (volumeVO != null && ImageFormat.QCOW2.equals(volumeVO.getFormat()))
return StrategyPriority.DEFAULT;
else
return StrategyPriority.CANT_HANDLE;
}
long storagePoolId;
@ -459,13 +465,6 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
storagePoolId = volumeVO.getPoolId();
}
if (SnapshotOperation.REVERT.equals(op)) {
if (volumeVO != null && ImageFormat.QCOW2.equals(volumeVO.getFormat()))
return StrategyPriority.DEFAULT;
else
return StrategyPriority.CANT_HANDLE;
}
DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();