Search in sources :

Example 21 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class SmisBlockCreateCGSnapshotJob method getRelationShipName.

private String getRelationShipName(WBEMClient client, CIMObjectPath replicationGroupPath, String replicationGroupID) {
    CloseableIterator<CIMInstance> iterator = null;
    try {
        _log.info("replicationGroupID : {}", replicationGroupID);
        iterator = client.referenceInstances(replicationGroupPath, SmisConstants.SE_GROUP_SYNCHRONIZED_RG_RG, null, false, null);
        while (iterator.hasNext()) {
            CIMInstance groupSynchronized = iterator.next();
            CIMProperty syncElement = groupSynchronized.getProperty(SmisConstants.CP_SYNCED_ELEMENT);
            _log.info("syncElement : {}", syncElement.getValue().toString());
            if (syncElement.toString().contains(replicationGroupID)) {
                String relationshipName = (String) groupSynchronized.getProperty(SmisConstants.RELATIONSHIP_NAME).getValue();
                _log.info("Relationship name : {}", relationshipName);
                return relationshipName;
            }
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to get the relationship name for Group Synchronized");
    } finally {
        if (iterator != null) {
            iterator.close();
        }
    }
    return null;
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMInstance(javax.cim.CIMInstance)

Example 22 with CIMProperty

use of javax.cim.CIMProperty 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)

Example 23 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class SmisJob method poll.

public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
    CIMProperty<Object> instanceID = null;
    try {
        CIMObjectPath cimJob = getCimJob();
        instanceID = (CIMProperty<Object>) cimJob.getKey("InstanceID");
        _pollResult.setJobName(getJobName());
        _pollResult.setJobId(instanceID.getValue().toString());
        _pollResult.setJobPercentComplete(_percentComplete);
        if (_smisIPAddress == null) {
            StorageSystem storageSystem = jobContext.getDbClient().queryObject(StorageSystem.class, getStorageSystemURI());
            _smisIPAddress = storageSystem.getSmisProviderIP();
        }
        // poll only if job is not in terminal status
        if (_status == JobStatus.IN_PROGRESS || _status == JobStatus.ERROR) {
            String[] jobPathPropertyKeys = { JOB_PROPERTY_KEY_PERCENT_COMPLETE, JOB_PROPERTY_KEY_OPERATIONAL_STS, JOB_PROPERTY_KEY_ERROR_DESC };
            CIMInstance jobPathInstance = null;
            _logger.info("SmisJob: Looking up job: id {}, provider: {} ", instanceID.getValue(), _smisIPAddress);
            WBEMClient wbemClient = getWBEMClient(jobContext.getDbClient(), jobContext.getCimConnectionFactory());
            if (wbemClient == null) {
                String errorMessage = "No CIMOM client found for provider ip: " + _smisIPAddress;
                processTransientError(instanceID.getValue().toString(), trackingPeriodInMillis, errorMessage, null);
            } else {
                jobPathInstance = wbemClient.getInstance(getCimJob(), false, false, jobPathPropertyKeys);
                CIMProperty<UnsignedInteger16> percentComplete = (CIMProperty<UnsignedInteger16>) jobPathInstance.getProperty(JOB_PROPERTY_KEY_PERCENT_COMPLETE);
                _pollResult.setJobPercentComplete(percentComplete.getValue().intValue());
                _percentComplete = _pollResult.getJobPercentComplete();
                // reset transient error tracking time
                setErrorTrackingStartTime(0L);
                if (_pollResult.getJobPercentComplete() == 100) {
                    CIMProperty<UnsignedInteger16[]> operationalStatus = (CIMProperty<UnsignedInteger16[]>) jobPathInstance.getProperty(JOB_PROPERTY_KEY_OPERATIONAL_STS);
                    UnsignedInteger16[] statusValues = operationalStatus.getValue();
                    if (statusValues != null) {
                        for (int j = 0; j < statusValues.length; j++) {
                            _logger.info("Status value[{}]: {}", j, statusValues[j].intValue());
                            if (statusValues[j].intValue() == 2) {
                                _status = JobStatus.SUCCESS;
                                _logger.info("SmisJob: {} succeeded", instanceID.getValue());
                            }
                            if (statusValues[j].intValue() == 6) {
                                _status = JobStatus.FAILED;
                                _logger.info("SmisJob: {} returned exception", instanceID.getValue());
                            }
                        }
                    }
                    if ((_status != JobStatus.SUCCESS) && (_status != JobStatus.IN_PROGRESS)) {
                        // parse ErrorDescription
                        _errorDescription = getErrorDescription(jobPathInstance);
                        _status = JobStatus.FAILED;
                        _logger.error("SmisJob: {} failed; Details: {}", getJobName(), _errorDescription);
                        logErrorsFromJob(wbemClient);
                    }
                } else {
                    // reset status from previous possible transient error status
                    _status = JobStatus.IN_PROGRESS;
                }
            }
        }
    } catch (WBEMException we) {
        if ((we.getID() == WBEMException.CIM_ERR_NOT_FOUND) || (we.getID() == WBEMException.CIM_ERR_FAILED)) {
            _status = JobStatus.FAILED;
            _errorDescription = we.getMessage();
            if (we.getID() == WBEMException.CIM_ERR_NOT_FOUND) {
                _logger.error(String.format("SMI-S job not found. Marking as failed as we cannot determine status. " + "User may retry the operation to be sure: Name: %s, ID: %s, Desc: %s", getJobName(), instanceID.getValue().toString(), _errorDescription), we);
            } else {
                // CIM_ERR_FAILED
                _logger.error(String.format("Job failed but GetErrors() did not report the actual error. " + "User may retry the operation to be sure: Name: %s, ID: %s, Desc: %s", getJobName(), instanceID.getValue().toString(), _errorDescription), we);
            }
        } else {
            processTransientError(instanceID.getValue().toString(), trackingPeriodInMillis, we.getMessage(), we);
        }
    } catch (Exception e) {
        processTransientError(instanceID.getValue().toString(), trackingPeriodInMillis, e.getMessage(), e);
    } finally {
        try {
            _logger.info("SmisJob: Post processing job: id {}, provider: {} ", instanceID.getValue(), _smisIPAddress);
            // reset from previous possible transient error in post processing status.
            _postProcessingStatus = JobStatus.SUCCESS;
            updateStatus(jobContext);
            if (_postProcessingStatus == JobStatus.ERROR) {
                processPostProcessingError(instanceID.getValue().toString(), trackingPeriodInMillis, _errorDescription, null);
            }
        } catch (WBEMException we) {
            if (we.getID() == WBEMException.CIM_ERR_NOT_FOUND) {
                _postProcessingStatus = JobStatus.FAILED;
                _errorDescription = we.getMessage();
                _logger.error(String.format("SMI-S job not found. Marking as failed as we cannot determine status. " + "User may retry the operation to be sure: Name: %s, ID: %s, Desc: %s", getJobName(), instanceID.getValue().toString(), _errorDescription), we);
            } else {
                processPostProcessingError(instanceID.getValue().toString(), trackingPeriodInMillis, we.getMessage(), we);
            }
        } catch (Exception e) {
            setFatalErrorStatus(e.getMessage());
            setPostProcessingFailedStatus(e.getMessage());
            _logger.error("Problem while trying to update status", e);
        } finally {
            if (isJobInTerminalFailedState()) {
                // Have to process job completion since updateStatus may not did this.
                ServiceError error = DeviceControllerErrors.smis.jobFailed(_errorDescription);
                getTaskCompleter().error(jobContext.getDbClient(), error);
            }
        }
    }
    _pollResult.setJobStatus(_status);
    _pollResult.setJobPostProcessingStatus(_postProcessingStatus);
    _pollResult.setErrorDescription(_errorDescription);
    return _pollResult;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) UnsignedInteger16(javax.cim.UnsignedInteger16) WBEMException(javax.wbem.WBEMException) CIMProperty(javax.cim.CIMProperty) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 24 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class SmisSnapShotJob method commonSnapshotUpdate.

/**
 * This method updates provisioned capacity and allocated capacity for snapshots.
 * It also set settingsInstance for VMAX V3 snapshot.
 *
 * @param snapShot A reference to the snapshot to be updated.
 * @param syncVolume A reference to the CIM instance representing the snapshot target volume.
 * @param client A reference to a WBEM client.
 * @param storage A reference to the storage system.
 * @param sourceElementId String of source volume (or source group) ID
 * @param elementName String used as ElementName when creating ReplicationSettingData during single snapshot creation,
 *            or RelationshipName used in CreateGroupReplica for group snapshot. Note elementName should be target device's DeviceID
 *            or target group ID.
 * @param createSession true if a BlockSnapshotSession should be created to represent the settings instance.
 * @param dbClient A reference to a database client.
 */
protected void commonSnapshotUpdate(BlockSnapshot snapShot, CIMInstance syncVolume, WBEMClient client, StorageSystem storage, String sourceElementId, String elementName, boolean createSession, DbClient dbClient) {
    try {
        CIMProperty consumableBlocks = syncVolume.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
        CIMProperty blockSize = syncVolume.getProperty(SmisConstants.CP_BLOCK_SIZE);
        // calculate provisionedCapacity = consumableBlocks * block size
        Long provisionedCapacity = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
        snapShot.setProvisionedCapacity(provisionedCapacity);
        // set Allocated Capacity
        CloseableIterator<CIMInstance> iterator = null;
        iterator = client.referenceInstances(syncVolume.getObjectPath(), SmisConstants.CIM_ALLOCATED_FROM_STORAGEPOOL, null, false, SmisConstants.PS_SPACE_CONSUMED);
        if (iterator.hasNext()) {
            CIMInstance allocatedFromStoragePoolPath = iterator.next();
            CIMProperty spaceConsumed = allocatedFromStoragePoolPath.getProperty(SmisConstants.CP_SPACE_CONSUMED);
            if (null != spaceConsumed) {
                snapShot.setAllocatedCapacity(Long.valueOf(spaceConsumed.getValue().toString()));
            }
        }
        // set settingsInstance for VMAX V3 only
        setSettingsInstance(storage, snapShot, sourceElementId, elementName, createSession, dbClient);
    } catch (Exception e) {
        // Don't want to fail the snapshot creation, if capacity retrieval fails, as auto discovery cycle
        // will take care of updating capacity informations later.
        _log.error("Caught an exception while trying to update Capacity and SettingsInstance for Snapshots", e);
    }
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMInstance(javax.cim.CIMInstance)

Example 25 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class SmisVolumeExpandJob method updateStatus.

/**
 * Called to update the job status when the volume expand job completes.
 *
 * @param jobContext The job context.
 */
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> associatorIterator = null;
    CloseableIterator<CIMInstance> instanceIterator = null;
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        DbClient dbClient = jobContext.getDbClient();
        CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
        WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
        // from pool's reserved capacity map.
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            SmisUtils.updateStoragePoolCapacity(dbClient, client, _storagePoolURI);
            StoragePool pool = dbClient.queryObject(StoragePool.class, _storagePoolURI);
            StringMap reservationMap = pool.getReservedCapacityMap();
            URI volumeId = getTaskCompleter().getId();
            // remove from reservation map
            reservationMap.remove(volumeId.toString());
            dbClient.persistObject(pool);
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), jobStatus.name(), opId));
        if (jobStatus == JobStatus.SUCCESS) {
            VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
            Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
            // set requested capacity
            volume.setCapacity(taskCompleter.getSize());
            // set meta related properties
            volume.setTotalMetaMemberCapacity(taskCompleter.getTotalMetaMembersSize());
            volume.setMetaMemberCount(taskCompleter.getMetaMemberCount());
            volume.setMetaMemberSize(taskCompleter.getMetaMemberSize());
            volume.setIsComposite(taskCompleter.isComposite());
            volume.setCompositionType(taskCompleter.getMetaVolumeType());
            // set provisioned capacity
            associatorIterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            if (associatorIterator.hasNext()) {
                CIMObjectPath volumePath = associatorIterator.next();
                CIMInstance volumeInstance = client.getInstance(volumePath, true, false, null);
                if (volumeInstance != null) {
                    CIMProperty consumableBlocks = volumeInstance.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
                    CIMProperty blockSize = volumeInstance.getProperty(SmisConstants.CP_BLOCK_SIZE);
                    // calculate provisionedCapacity = consumableBlocks * block size
                    Long provisionedCapacity = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
                    volume.setProvisionedCapacity(provisionedCapacity);
                }
                // set allocated capacity
                instanceIterator = client.referenceInstances(volumePath, SmisConstants.CIM_ALLOCATED_FROM_STORAGEPOOL, null, false, SmisConstants.PS_SPACE_CONSUMED);
                if (instanceIterator.hasNext()) {
                    CIMInstance allocatedFromStoragePoolPath = instanceIterator.next();
                    CIMProperty spaceConsumed = allocatedFromStoragePoolPath.getProperty(SmisConstants.CP_SPACE_CONSUMED);
                    if (null != spaceConsumed) {
                        volume.setAllocatedCapacity(Long.valueOf(spaceConsumed.getValue().toString()));
                    }
                }
            }
            logMsgBuilder.append(String.format("%n   Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
            if (volume.getIsComposite()) {
                logMsgBuilder.append(String.format("%n   Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s", volume.getIsComposite(), volume.getTotalMetaMemberCapacity(), volume.getMetaMemberCount(), volume.getMetaMemberSize()));
            }
            _log.info(logMsgBuilder.toString());
            // Reset list of meta member volumes in the volume
            if (volume.getMetaVolumeMembers() != null) {
                volume.getMetaVolumeMembers().clear();
            }
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
            // set the RP tag on the volume if the volume is RP protected
            if (volume.checkForRp()) {
                SmisCommandHelper helper = jobContext.getSmisCommandHelper();
                boolean tagSet = helper.doApplyRecoverPointTag(storageSystem, volume, true);
                if (!tagSet) {
                    _log.error("Encountered an error while trying to enable the RecoverPoint tag.");
                    jobStatus = JobStatus.FAILED;
                }
            }
            dbClient.persistObject(volume);
            // Reset list of meta members native ids in WF data (when meta is created meta members are removed from array)
            WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisVolumeExpandJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during volume expand job status processing : " + e.getMessage());
    } finally {
        _metaVolumeTaskCompleter.setLastStepStatus(jobStatus);
        if (associatorIterator != null) {
            associatorIterator.close();
        }
        if (instanceIterator != null) {
            instanceIterator.close();
        }
        super.updateStatus(jobContext);
    }
}
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) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) 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) CIMProperty(javax.cim.CIMProperty) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

CIMProperty (javax.cim.CIMProperty)74 CIMObjectPath (javax.cim.CIMObjectPath)57 CIMInstance (javax.cim.CIMInstance)37 ArrayList (java.util.ArrayList)26 WBEMException (javax.wbem.WBEMException)25 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)18 CIMArgument (javax.cim.CIMArgument)16 WBEMClient (javax.wbem.client.WBEMClient)14 IOException (java.io.IOException)11 Volume (com.emc.storageos.db.client.model.Volume)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)10 URI (java.net.URI)9 ServiceCodeException (com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)8 UnsignedInteger16 (javax.cim.UnsignedInteger16)8 DbClient (com.emc.storageos.db.client.DbClient)7 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)7 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 HashMap (java.util.HashMap)6 ExportMask (com.emc.storageos.db.client.model.ExportMask)5 Initiator (com.emc.storageos.db.client.model.Initiator)5