use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotDeleteCompleter in project coprhd-controller by CoprHD.
the class SmisBlockDeleteSnapshotJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
BlockSnapshotDeleteCompleter completer = (BlockSnapshotDeleteCompleter) getTaskCompleter();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, completer.getId());
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
NamedURI volumeURI = snapshot.getParent();
Volume volume = dbClient.queryObject(Volume.class, volumeURI);
URI poolURI = volume.getPool();
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Deleting snapshot job was successful.");
snapshot.setInactive(true);
dbClient.persistObject(snapshot);
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to delete snapshot: {}", getTaskCompleter().getId());
}
} catch (Exception e) {
setFatalErrorStatus(e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteSnapshotJob", e);
Operation updateOp = new Operation();
updateOp.setStatus("Encountered an internal error during block delete snapshot job status processing: " + e.getMessage());
dbClient.updateTaskOpStatus(BlockSnapshot.class, getTaskCompleter().getId(), getTaskCompleter().getOpId(), updateOp);
} finally {
super.updateStatus(jobContext);
}
}
Aggregations