Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,12 @@ public Snapshot revertSnapshot(Long snapshotId) {
}
}

DataStoreRole dataStoreRole = getDataStoreRole(snapshot, _snapshotStoreDao, dataStoreMgr);
DataStoreRole dataStoreRole = getDataStoreRole(snapshot);

SnapshotInfo snapshotInfo = snapshotFactory.getSnapshot(snapshotId, dataStoreRole);
Comment thread
sureshanaparti marked this conversation as resolved.

if (snapshotInfo == null) {
throw new CloudRuntimeException("snapshot:" + snapshotId + " not exist in data store");
throw new CloudRuntimeException(String.format("snapshot %s [%s] does not exists in data store", snapshot.getName(), snapshot.getUuid()));
}

SnapshotStrategy snapshotStrategy = _storageStrategyFactory.getSnapshotStrategy(snapshot, SnapshotOperation.REVERT);
Expand Down Expand Up @@ -587,7 +588,7 @@ public boolean deleteSnapshot(long snapshotId) {
return false;
}

DataStoreRole dataStoreRole = getDataStoreRole(snapshotCheck, _snapshotStoreDao, dataStoreMgr);
DataStoreRole dataStoreRole = getDataStoreRole(snapshotCheck);

SnapshotDataStoreVO snapshotStoreRef = _snapshotStoreDao.findBySnapshot(snapshotId, dataStoreRole);

Expand Down Expand Up @@ -1238,15 +1239,11 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
try {
postCreateSnapshot(volume.getId(), snapshotId, payload.getSnapshotPolicyId());

DataStoreRole dataStoreRole = getDataStoreRole(snapshot, _snapshotStoreDao, dataStoreMgr);
DataStoreRole dataStoreRole = getDataStoreRole(snapshot);

SnapshotDataStoreVO snapshotStoreRef = _snapshotStoreDao.findBySnapshot(snapshotId, dataStoreRole);
if (snapshotStoreRef == null) {
// The snapshot was not backed up to secondary. Find the snap on primary
snapshotStoreRef = _snapshotStoreDao.findBySnapshot(snapshotId, DataStoreRole.Primary);
if (snapshotStoreRef == null) {
throw new CloudRuntimeException("Could not find snapshot");
}
throw new CloudRuntimeException(String.format("Could not find snapshot %s [%s] on [%s]", snapshot.getName(), snapshot.getUuid(), snapshot.getLocationType()));
}
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_CREATE, snapshot.getAccountId(), snapshot.getDataCenterId(), snapshotId, snapshot.getName(), null, null,
snapshotStoreRef.getPhysicalSize(), volume.getSize(), snapshot.getClass().getName(), snapshot.getUuid());
Expand Down Expand Up @@ -1332,8 +1329,8 @@ private void updateSnapshotPayload(long storagePoolId, CreateSnapshotPayload pay
}
}

private DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) {
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);
private DataStoreRole getDataStoreRole(Snapshot snapshot) {
SnapshotDataStoreVO snapshotStore = _snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);

if (snapshotStore == null) {
return DataStoreRole.Image;
Expand All @@ -1346,15 +1343,15 @@ private DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao s

if (mapCapabilities != null) {
String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
Boolean supportsStorageSystemSnapshots = new Boolean(value);
Boolean supportsStorageSystemSnapshots = Boolean.valueOf(value);

Comment thread
sureshanaparti marked this conversation as resolved.
if (supportsStorageSystemSnapshots) {
return DataStoreRole.Primary;
}
}

StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePoolId);
if ((storagePoolVO.getPoolType() == StoragePoolType.RBD || storagePoolVO.getPoolType() == StoragePoolType.PowerFlex) && !BackupSnapshotAfterTakingSnapshot.value()) {
if (storagePoolVO.getPoolType() == StoragePoolType.RBD) {
return DataStoreRole.Primary;
}

Expand Down