use of com.emc.storageos.volumecontroller.impl.cinder.job.CinderSnapshotDeleteJob in project coprhd-controller by CoprHD.
the class CinderStorageDevice method doDeleteSnapshot.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteSnapshot
* (com.emc.storageos.db.client.model.StorageSystem,
* java.net.URI, com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void doDeleteSnapshot(StorageSystem storageSystem, URI snapshotURI, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Snapshot Start - Array:%s", storageSystem.getSerialNumber()));
log.info(logMsgBuilder.toString());
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotURI);
CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
try {
cinderApi.showSnapshot(snapshot.getId().toString());
} catch (CinderException ce) {
// This means, the snapshot is not present on the back-end device
log.info(String.format("Snapshot %s already deleted: ", snapshot.getNativeId()));
snapshot.setInactive(true);
dbClient.updateObject(snapshot);
taskCompleter.ready(dbClient);
}
// Now - trigger the delete
cinderApi.deleteSnapshot(snapshot.getNativeId().toString());
ControllerServiceImpl.enqueueJob(new QueueJob(new CinderSnapshotDeleteJob(snapshot.getNativeId(), snapshot.getLabel(), storageSystem.getId(), CinderConstants.ComponentType.snapshot.name(), ep, taskCompleter)));
} catch (Exception e) {
log.error("Problem in doDeleteVolume: ", e);
ServiceError error = DeviceControllerErrors.cinder.operationFailed("doDeleteSnapshot", e.getMessage());
taskCompleter.error(dbClient, error);
}
}
Aggregations