@Override public void cleanupSnapshotsByVolume(Long volumeId) { List<SnapshotInfo> infos = snapshotFactory.getSnapshots(volumeId, DataStoreRole.Primary); for(SnapshotInfo info: infos) { try { if(info != null) { snapshotSrv.deleteSnapshot(info); } } catch(CloudRuntimeException e) { String msg = "Cleanup of Snapshot with uuid " + info.getUuid() + " in primary storage is failed. Ignoring"; s_logger.warn(msg); } } }
@Override public void postSnapshotCreation(SnapshotInfo snapshot) { updateLocationTypeInDb(snapshot); if (snapshot.getLocationType() == Snapshot.LocationType.SECONDARY) { // remove the snapshot on primary storage try { snapshotSvr.deleteSnapshot(snapshot); } catch (Exception e) { s_logger.warn("Failed to clean up snapshot '" + snapshot.getId() + "' on primary storage: " + e.getMessage()); } } }
snapshotSvr.deleteSnapshot(snapshotObj);
boolean r = snapshotSvr.deleteSnapshot(snapshot); if (r) {
@Override public Snapshot archiveSnapshot(Long snapshotId) { SnapshotInfo snapshotOnPrimary = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary); if (snapshotOnPrimary == null || !snapshotOnPrimary.getStatus().equals(ObjectInDataStoreStateMachine.State.Ready)) { throw new CloudRuntimeException("Can only archive snapshots present on primary storage. " + "Cannot find snapshot " + snapshotId + " on primary storage"); } SnapshotInfo snapshotOnSecondary = snapshotSrv.backupSnapshot(snapshotOnPrimary); SnapshotVO snapshotVO = _snapshotDao.findById(snapshotOnSecondary.getId()); snapshotVO.setLocationType(Snapshot.LocationType.SECONDARY); _snapshotDao.persist(snapshotVO); try { snapshotSrv.deleteSnapshot(snapshotOnPrimary); } catch (Exception e) { throw new CloudRuntimeException("Snapshot archived to Secondary Storage but there was an error deleting " + " the snapshot on Primary Storage. Please manually delete the primary snapshot " + snapshotId, e); } return snapshotOnSecondary; }
VolumeVO volumeVO = volumeDao.findById(volumeId); if (((PrimaryDataStoreImpl)snapshotOnPrimaryInfo.getDataStore()).getPoolType() == StoragePoolType.RBD && volumeVO != null) { snapshotSvr.deleteSnapshot(snapshotOnPrimaryInfo);
for (SnapshotDataStoreVO ssSnapshotVO : ssSnapshots) { try { _snapshotService.deleteSnapshot(snapshotFactory.getSnapshot(ssSnapshotVO.getSnapshotId(), DataStoreRole.Image)); } catch (Exception e) { s_logger.debug("Failed to delete snapshot: " + ssSnapshotVO.getId() + " from storage");