Search in sources :

Example 36 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockCreateSnapshotJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> syncVolumeIter = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        BlockSnapshotCreateCompleter completer = (BlockSnapshotCreateCompleter) getTaskCompleter();
        List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, completer.getSnapshotURIs());
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        if (jobStatus == JobStatus.SUCCESS) {
            _log.info(String.format("Post-processing successful snap creation task:%s. Expected: snapshot.size() = 1; Actual: snapshots.size() = %d", getTaskCompleter().getOpId(), snapshots.size()));
            // Get the snapshot device ID and set it against the BlockSnapshot object
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            syncVolumeIter = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            if (syncVolumeIter.hasNext()) {
                // Get the sync volume native device id
                CIMObjectPath syncVolumePath = syncVolumeIter.next();
                CIMInstance syncVolume = client.getInstance(syncVolumePath, false, false, null);
                String syncDeviceID = syncVolumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
                String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_ELEMENT_NAME);
                String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_WWN_NAME);
                String alternateName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_NAME);
                // Lookup the associated snapshot based on the volume native device id
                BlockSnapshot snapshot = snapshots.get(0);
                Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
                snapshot.setNativeId(syncDeviceID);
                snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
                snapshot.setDeviceLabel(elementName);
                snapshot.setInactive(false);
                snapshot.setIsSyncActive(_wantSyncActive);
                snapshot.setCreationTime(Calendar.getInstance());
                snapshot.setWWN(wwn.toUpperCase());
                snapshot.setAlternateName(alternateName);
                commonSnapshotUpdate(snapshot, syncVolume, client, storage, volume.getNativeId(), syncDeviceID, true, dbClient);
                _log.info(String.format("For sync volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", syncVolumePath.toString(), snapshot.getId().toString(), syncDeviceID, elementName, volume.getNativeId(), volume.getDeviceLabel()));
                dbClient.persistObject(snapshot);
            }
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create snapshot");
            BlockSnapshot snapshot = snapshots.get(0);
            snapshot.setInactive(true);
            dbClient.persistObject(snapshot);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during block create snapshot job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisBlockCreateSnapshotJob", e);
    } finally {
        if (syncVolumeIter != null) {
            syncVolumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) CIMInstance(javax.cim.CIMInstance) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 37 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockDeleteMirrorJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        BlockMirrorDeleteCompleter completer = (BlockMirrorDeleteCompleter) getTaskCompleter();
        BlockMirror mirror = dbClient.queryObject(BlockMirror.class, completer.getMirrorURI());
        // 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);
            URI poolURI = mirror.getPool();
            // Update capacity of storage pools.
            SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
        }
        if (jobStatus == JobStatus.SUCCESS) {
            _log.info("Mirror delete success");
            Volume volume = dbClient.queryObject(Volume.class, mirror.getSource().getURI());
            dbClient.markForDeletion(mirror);
            _log.info(String.format("Deleted BlockMirror %s on Volume %s", mirror, volume));
        } else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
            String msg = String.format("Failed to delete mirror %s", mirror.getId());
            _log.error(msg);
            getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
        }
    } catch (Exception e) {
        setFatalErrorStatus("Encountered an internal error during block delete mirror job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteMirrorJob", e);
        getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : BlockMirrorDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorDeleteCompleter) DbClient(com.emc.storageos.db.client.DbClient) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient) URI(java.net.URI)

Example 38 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockResumeMirrorJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    log.info("START updateStatus for resuming {}", getTaskCompleter().getId());
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        BlockMirrorResumeCompleter taskCompleter = (BlockMirrorResumeCompleter) getTaskCompleter();
        if (jobStatus == JobStatus.SUCCESS) {
            log.info("Mirror resume success");
            BlockMirror mirror = dbClient.queryObject(BlockMirror.class, taskCompleter.getMirrorURI());
            log.info("Updating sync details for mirror {}", mirror.getId());
            WBEMClient client = getWBEMClient(dbClient, jobContext.getCimConnectionFactory());
            updateSynchronizationAspects(client, mirror);
            dbClient.persistObject(mirror);
            getTaskCompleter().ready(dbClient);
        } else if (jobStatus == JobStatus.ERROR) {
            log.info("Mirror resume failed");
        }
    } catch (Exception e) {
        String errorMsg = "Failed job to resume mirror: " + e.getMessage();
        log.error(errorMsg, e);
        setPostProcessingErrorStatus(errorMsg);
    } finally {
        super.updateStatus(jobContext);
        log.info("FINISH updateStatus for resuming {}", getTaskCompleter().getId());
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) WBEMClient(javax.wbem.client.WBEMClient) BlockMirrorResumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorResumeCompleter)

Example 39 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockSnapshotSessionCGCreateJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    JobStatus jobStatus = getJobStatus();
    CloseableIterator<CIMObjectPath> syncAspectIter = null;
    CloseableIterator<CIMObjectPath> settingsStateIter = null;
    try {
        DbClient dbClient = jobContext.getDbClient();
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        if (jobStatus == JobStatus.SUCCESS) {
            log.info("Post-processing successful snapshot session group creation for task ", getTaskCompleter().getOpId());
            // Get the snapshot sessions.
            Iterator<BlockSnapshotSession> iterator = dbClient.queryIterativeObjects(BlockSnapshotSession.class, getTaskCompleter().getIds(), true);
            List<BlockSnapshotSession> snapSessions = Lists.newArrayList(iterator);
            // Update Settings instance for the session.
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            syncAspectIter = client.associatorNames(getCimJob(), null, SmisConstants.SYMM_SYNCHRONIZATION_ASPECT_FOR_SOURCE_GROUP, null, null);
            if (syncAspectIter.hasNext()) {
                CIMObjectPath syncAspectPath = syncAspectIter.next();
                String instanceId = syncAspectPath.getKeyValue(Constants.INSTANCEID).toString();
                log.info("SynchronizationAspectForSourceGroup instance id is {}", instanceId);
                for (BlockSnapshotSession snapSession : snapSessions) {
                    snapSession.setSessionInstance(instanceId);
                }
                dbClient.updateObject(snapSessions);
            }
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            log.info("Failed to create snapshot session for task ", getTaskCompleter().getOpId());
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error in create snapshot session job status processing: " + e.getMessage());
        log.error("Encountered an internal error in create snapshot session job status processing", e);
    } finally {
        if (syncAspectIter != null) {
            syncAspectIter.close();
        }
        if (settingsStateIter != null) {
            settingsStateIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient)

Example 40 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class SmisBlockSnapshotSessionCreateJob method updateStatus.

/**
 * {@inheritDoc}
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    JobStatus jobStatus = getJobStatus();
    CloseableIterator<CIMObjectPath> syncAspectIter = null;
    CloseableIterator<CIMObjectPath> settingsStateIter = null;
    try {
        DbClient dbClient = jobContext.getDbClient();
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        if (jobStatus == JobStatus.SUCCESS) {
            s_logger.info("Post-processing successful snapshot session creation for task ", getTaskCompleter().getOpId());
            // Get the snapshot session.
            BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, getTaskCompleter().getId());
            // Update Settings instance for the session.
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            syncAspectIter = client.associatorNames(getCimJob(), null, SmisConstants.SYMM_SYNCHRONIZATION_ASPECT_FOR_SOURCE, null, null);
            if (syncAspectIter.hasNext()) {
                CIMObjectPath syncAspectPath = syncAspectIter.next();
                String instanceId = syncAspectPath.getKeyValue(Constants.INSTANCEID).toString();
                s_logger.info("SynchronizationAspect instance id is {}", instanceId);
                snapSession.setSessionInstance(instanceId);
                dbClient.updateObject(snapSession);
            }
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            s_logger.info("Failed to create snapshot session for task ", getTaskCompleter().getOpId());
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error in create snapshot session job status processing: " + e.getMessage());
        s_logger.error("Encountered an internal error in create snapshot session job status processing", e);
    } finally {
        if (syncAspectIter != null) {
            syncAspectIter.close();
        }
        if (settingsStateIter != null) {
            settingsStateIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient)

Aggregations

WBEMClient (javax.wbem.client.WBEMClient)110 CIMObjectPath (javax.cim.CIMObjectPath)75 CIMInstance (javax.cim.CIMInstance)69 WBEMException (javax.wbem.WBEMException)42 ArrayList (java.util.ArrayList)39 URI (java.net.URI)35 DbClient (com.emc.storageos.db.client.DbClient)29 Volume (com.emc.storageos.db.client.model.Volume)29 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)27 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)25 HashSet (java.util.HashSet)25 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)24 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)18 HashMap (java.util.HashMap)17 ExportMask (com.emc.storageos.db.client.model.ExportMask)16 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)16 CIMProperty (javax.cim.CIMProperty)14 UnsignedInteger32 (javax.cim.UnsignedInteger32)14 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)13