Search in sources :

Example 1 with BlockSnapshotDeleteCompleter

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshotDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotDeleteCompleter) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Operation(com.emc.storageos.db.client.model.Operation) WBEMClient(javax.wbem.client.WBEMClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

DbClient (com.emc.storageos.db.client.DbClient)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 Operation (com.emc.storageos.db.client.model.Operation)1 Volume (com.emc.storageos.db.client.model.Volume)1 BlockSnapshotDeleteCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotDeleteCompleter)1 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)1 URI (java.net.URI)1 WBEMClient (javax.wbem.client.WBEMClient)1