Search in sources :

Example 41 with WBEMClient

use of javax.wbem.client.WBEMClient 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 42 with WBEMClient

use of javax.wbem.client.WBEMClient 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)

Example 43 with WBEMClient

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

the class SmisCreateCGCloneJob method updateStatus.

public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMInstance> syncVolumeIter = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        CloneCreateCompleter completer = (CloneCreateCompleter) getTaskCompleter();
        List<Volume> clones = dbClient.queryObject(Volume.class, completer.getIds());
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        if (jobStatus == JobStatus.SUCCESS) {
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            CIMObjectPath replicationGroupPath = client.associatorNames(getCimJob(), null, SmisConstants.SE_REPLICATION_GROUP, null, null).next();
            String replicationGroupID = (String) replicationGroupPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
            // VMAX instanceID, e.g., 000196700567+EMC_SMI_RG1414546375042 (8.0.2 provider)
            final String replicationGroupInstance = replicationGroupID.split(Constants.PATH_DELIMITER_REGEX)[storage.getUsingSmis80() ? 1 : 0];
            syncVolumeIter = client.associatorInstances(replicationGroupPath, null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
            processCGClones(syncVolumeIter, client, dbClient, clones, replicationGroupInstance, isSyncActive);
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create clone");
            for (Volume clone : clones) {
                clone.setInactive(true);
            }
            dbClient.persistObject(clones);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during create CG clone job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisCreateCGCloneJob", e);
    } finally {
        if (syncVolumeIter != null) {
            syncVolumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) Volume(com.emc.storageos.db.client.model.Volume) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 44 with WBEMClient

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

the class SmisCreateMaskingViewJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    _log.info("Updating status of SmisCreateMaskingViewJob");
    try {
        if (jobStatus == JobStatus.SUCCESS) {
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
            CimConnection cimConnection = jobContext.getCimConnectionFactory().getConnection(storageSystem);
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            List<CIMObjectPath> maskingViews = new ArrayList<CIMObjectPath>();
            iterator = client.associatorNames(getCimJob(), null, SYMM_LUNMASKINGVIEW, null, null);
            while (iterator.hasNext()) {
                CIMObjectPath cimObjectPath = iterator.next();
                maskingViews.add(cimObjectPath);
                ExportMask mask = dbClient.queryObject(ExportMask.class, _exportMaskURI);
                // necessary for future reference to the MV.
                if (mask != null) {
                    String deviceId = cimObjectPath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
                    mask.setNativeId(deviceId);
                    dbClient.persistObject(mask);
                    ExportOperationContext.insertContextOperation(getTaskCompleter(), VmaxExportOperationContext.OPERATION_CREATE_MASKING_VIEW, mask.getMaskName());
                }
            }
            // Now perform RP protection tagging, if required, on the storage group
            if (storageSystem.getUsingSmis80()) {
                _log.info("Set RP tag on all volumes within SG for 8.0.3 Providers");
                enableRecoverPointTagOn803(dbClient, client, storageSystem, jobContext);
            } else {
                _log.info("Set RP tag on SG for 4.6.2 Providers");
                enableRecoverPointTag(dbClient, client, _deviceGroupMaskingPath);
            }
            // Now set the HLU on the volume URIs, if they haven't been set by user.
            ExportMaskOperationsHelper.setHLUFromProtocolControllers(dbClient, cimConnection, _exportMaskURI, _volumeURIHLUs, maskingViews, getTaskCompleter());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisCreateMaskingViewJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during masking view create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
        if (iterator != null) {
            iterator.close();
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 45 with WBEMClient

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

the class SmisCreateVmaxCGTargetVolumesJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.SUCCESS) {
            _deviceIds = new ArrayList<String>();
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            iterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            while (iterator.hasNext()) {
                CIMObjectPath volumePath = iterator.next();
                CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(SmisConstants.CP_DEVICE_ID);
                String nativeID = deviceID.getValue();
                if (nativeID == null || nativeID.isEmpty()) {
                    throw new IllegalStateException("Could not determine volume native ID from the SMI-S provider");
                }
                _deviceIds.add(nativeID);
            }
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create volume: {}", getTaskCompleter().getId());
        }
    } catch (Exception e) {
        setPostProcessingFailedStatus(e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisCreateVmaxCGTargetVolumesJob", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("updateStatus", e.getMessage());
        getTaskCompleter().error(dbClient, error);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CIMProperty(javax.cim.CIMProperty) 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