Search in sources :

Example 6 with CIMConnectionFactory

use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory 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 7 with CIMConnectionFactory

use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory 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 8 with CIMConnectionFactory

use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory 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)

Example 9 with CIMConnectionFactory

use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.

the class SmisBlockSnapshotSessionLinkTargetGroupJob method processJobSuccess.

private void processJobSuccess(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
        WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
        CIMObjectPath targetRepGrpPath = getAssociatedTargetReplicationGroupPath(client);
        log.info("Processing target replication group: {}", targetRepGrpPath);
        List<CIMObjectPath> replicaPairViews = getAssociatedReplicaPairViews(client, targetRepGrpPath);
        for (CIMObjectPath replicaPairViewPath : replicaPairViews) {
            log.info("Processing replica pair view instance: {}", replicaPairViewPath);
            CIMInstance replicaPairView = client.getInstance(replicaPairViewPath, false, false, PS_REPLICA_PAIR_VIEW);
            // Verify that ReplicaPairView references our groups
            String srcGrpInstance = getInstancePropertyValue(replicaPairView, CP_EMC_RG_SOURCE_INSTANCE_ID);
            String tgtGrpInstance = getInstancePropertyValue(replicaPairView, CP_EMC_RG_TARGET_INSTANCE_ID);
            // ReplicaPairView references src/tgt replication groups as <symm-id>+<group-name>, hence #contains
            if (!srcGrpInstance.contains(sourceGroupName) || !tgtGrpInstance.contains(targetGroupName)) {
                log.warn("ReplicaPairView did not match source/target groups: {}/{}", sourceGroupName, targetGroupName);
                continue;
            }
            String srcIdProp = (String) replicaPairView.getPropertyValue(CP_SV_SOURCE_DEVICE_ID);
            String tgtIdProp = (String) replicaPairView.getPropertyValue(CP_SV_TARGET_DEVICE_ID);
            if (srcNativeIdToSnapshotMap.containsKey(srcIdProp)) {
                URI blockSnapshotURI = srcNativeIdToSnapshotMap.get(srcIdProp);
                BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, blockSnapshotURI);
                BlockObject sourceObj = BlockObject.fetch(dbClient, snapshot.getParent().getURI());
                CIMObjectPath volumePath = getAssociatedTargetVolume(client, replicaPairViewPath, tgtIdProp);
                CIMInstance volume = client.getInstance(volumePath, false, false, null);
                String volumeElementName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_ELEMENT_NAME);
                log.info("volumeElementName: {}", volumeElementName);
                String volumeWWN = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_WWN_NAME);
                log.info("volumeWWN: {}", volumeWWN);
                String volumeAltName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_NAME);
                log.info("volumeAltName: {}", volumeAltName);
                StorageSystem system = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
                snapshot.setNativeId(tgtIdProp);
                snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(system, snapshot));
                snapshot.setDeviceLabel(volumeElementName);
                snapshot.setInactive(false);
                snapshot.setIsSyncActive(Boolean.TRUE);
                snapshot.setCreationTime(Calendar.getInstance());
                snapshot.setWWN(volumeWWN.toUpperCase());
                snapshot.setAlternateName(volumeAltName);
                snapshot.setSettingsInstance(snapSessionInstance);
                snapshot.setReplicationGroupInstance(tgtGrpInstance);
                commonSnapshotUpdate(snapshot, volume, client, system, sourceObj.getNativeId(), tgtIdProp, false, dbClient);
                log.info(String.format("For target volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", volumePath.toString(), snapshot.getId().toString(), tgtIdProp, volumeElementName, sourceObj.getNativeId(), sourceObj.getDeviceLabel()));
                dbClient.updateObject(snapshot);
            }
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Internal error in link snapshot session target group job status processing: " + e.getMessage());
        log.error("Internal error in link snapshot session target group job status processing", e);
        throw e;
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) WBEMClient(javax.wbem.client.WBEMClient) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BlockObject(com.emc.storageos.db.client.model.BlockObject) WBEMException(javax.wbem.WBEMException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 10 with CIMConnectionFactory

use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.

the class SmisCloneVolumeJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    _log.info("START updateStatus for clone volume");
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        CIMConnectionFactory cimConnectionFactory;
        WBEMClient client = null;
        CloneCreateCompleter completer = (CloneCreateCompleter) getTaskCompleter();
        Volume cloneVolume = dbClient.queryObject(Volume.class, completer.getId());
        // from pool's reserved capacity map.
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            cimConnectionFactory = jobContext.getCimConnectionFactory();
            client = getWBEMClient(dbClient, cimConnectionFactory);
            URI poolURI = cloneVolume.getPool();
            SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
            StoragePool pool = dbClient.queryObject(StoragePool.class, poolURI);
            StringMap reservationMap = pool.getReservedCapacityMap();
            // remove from reservation map
            reservationMap.remove(cloneVolume.getId().toString());
            dbClient.persistObject(pool);
        }
        if (jobStatus == JobStatus.SUCCESS) {
            _log.info("Clone creation success");
            iterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            if (iterator.hasNext()) {
                CIMObjectPath cloneVolumePath = iterator.next();
                CIMInstance syncVolume = client.getInstance(cloneVolumePath, false, false, null);
                String deviceId = cloneVolumePath.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);
                cloneVolume.setProvisionedCapacity(getProvisionedCapacityInformation(client, syncVolume));
                cloneVolume.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
                cloneVolume.setWWN(wwn.toUpperCase());
                cloneVolume.setAlternateName(alternateName);
                cloneVolume.setNativeId(deviceId);
                cloneVolume.setDeviceLabel(elementName);
                cloneVolume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(dbClient, cloneVolume));
                cloneVolume.setInactive(false);
                if (cloneVolume.getSyncActive()) {
                    cloneVolume.setReplicaState(ReplicationState.CREATED.name());
                } else {
                    cloneVolume.setReplicaState(ReplicationState.INACTIVE.name());
                }
                dbClient.persistObject(cloneVolume);
            }
        /*
                 * for (URI id : completer.getIds()) {
                 * completer.ready(dbClient);
                 * }
                 */
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            String msg = String.format("Failed job to create full copy from %s to %s", cloneVolume.getAssociatedSourceVolume(), cloneVolume.getId());
            _log.error(msg);
            cloneVolume.setInactive(true);
            dbClient.persistObject(cloneVolume);
        }
    } catch (Exception e) {
        String errorMsg = String.format("Encountered an internal error during block create clone job status " + "processing: %s", e.getMessage());
        setPostProcessingErrorStatus(errorMsg);
        _log.error("Failed to update status for " + getClass().getSimpleName(), e);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
        super.updateStatus(jobContext);
        _log.info("FINISH updateStatus for clone volume");
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) 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)

Aggregations

CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)32 DbClient (com.emc.storageos.db.client.DbClient)28 WBEMClient (javax.wbem.client.WBEMClient)27 CIMObjectPath (javax.cim.CIMObjectPath)18 Volume (com.emc.storageos.db.client.model.Volume)14 CIMInstance (javax.cim.CIMInstance)14 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)13 URI (java.net.URI)11 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)5 BlockObject (com.emc.storageos.db.client.model.BlockObject)5 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 CIMProperty (javax.cim.CIMProperty)5 StoragePool (com.emc.storageos.db.client.model.StoragePool)4 StringMap (com.emc.storageos.db.client.model.StringMap)4 ArrayList (java.util.ArrayList)4 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)3 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)3 SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)3 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)3