use of javax.wbem.WBEMException 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;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisMaskingViewAddVolumeJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
_log.info("Updating status of SmisMaskingViewAddVolumeJob");
try {
if (jobStatus == JobStatus.SUCCESS) {
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
CimConnection cimConnection = jobContext.getCimConnectionFactory().getConnection(storageSystem);
List<URI> volumeUriList = new ArrayList<URI>();
// Now perform RP protection tagging, if required for the
// objects being added.
SmisCommandHelper helper = jobContext.getSmisCommandHelper();
for (VolumeURIHLU volumeUriHlu : _volumeURIHLUs) {
BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, volumeUriHlu.getVolumeURI());
if (bo != null && bo instanceof Volume) {
Volume volume = (Volume) bo;
if (volume != null && volume.checkForRp()) {
List<CIMObjectPath> volumePathList = new ArrayList<CIMObjectPath>();
volumePathList.add(helper.getVolumeMember(storageSystem, volume));
helper.setRecoverPointTag(storageSystem, volumePathList, true);
}
}
volumeUriList.add(volumeUriHlu.getVolumeURI());
}
// for proper roll back , that is volume removal, if exception is thrown during update
if (_newCreatedGroup != null) {
helper.setHostIOLimits(cimConnection.getCimClient(), _newCreatedGroup, _volumeURIHLUs);
}
String[] volumeNames = ExportMaskUtils.getBlockObjectAlternateNames(volumeUriList, dbClient);
CIMObjectPath[] volumes = _cimPath.getVolumePaths(storageSystem, volumeNames);
_log.info("{} volumes processed for HLU updation", volumes.length);
// Now set the HLU on the volume URIs, if they haven't been set// by user.
ExportMaskOperationsHelper.setHLUFromProtocolControllersOnAddVolume(dbClient, cimConnection, _exportMaskURI, _volumeURIHLUs, volumes, getTaskCompleter());
}
} catch (WBEMException e) {
_log.error(String.format("updateHostIOLimits failed - new created group: %s", _newCreatedGroup.toString()), e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
getTaskCompleter().error(dbClient, serviceError);
} catch (Exception e) {
_log.error("Caught an exception while trying to updateStatus for SmisMaskingViewAddVolumeJob", e);
setPostProcessingErrorStatus("Encountered an internal error during add volume to masking view job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SRDFUtils method getStorageSynchronizationFromVolume.
/**
* Finds remote storage synchronized element for the given volume's cimObjectPath
*
* @param provider
* @param volumePath
* @param rdfGroup {@link RemoteDirectorGroup}
* @return
*/
private CIMObjectPath getStorageSynchronizationFromVolume(StorageSystem provider, CIMObjectPath volumePath, RemoteDirectorGroup rdfGroup) {
CloseableIterator<CIMObjectPath> references = null;
try {
references = helper.getReference(provider, volumePath, CIM_STORAGE_SYNCHRONIZED, null);
StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, rdfGroup.getSourceStorageSystemUri());
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, rdfGroup.getRemoteStorageSystemUri());
log.debug("Source serial number {}", sourceSystem.getSerialNumber());
log.debug("target system serial number {}", targetSystem.getSerialNumber());
while (references.hasNext()) {
CIMObjectPath storageSynchronized = references.next();
log.debug("storage Synchronized {}", storageSynchronized);
if (storageSynchronized.toString().contains(sourceSystem.getSerialNumber()) && storageSynchronized.toString().contains(targetSystem.getSerialNumber())) {
return storageSynchronized;
}
}
} catch (WBEMException e) {
throw new RuntimeException("Failed to acquire storage synchronization", e);
} finally {
if (references != null) {
references.close();
}
}
throw new RuntimeException("Failed to acquire storage synchronization");
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SRDFOperations method updateSourceAndTargetPairings.
/**
* Checks with the SMI-S provider to ensure that ViPR's source and target volumes are paired up
* correctly and fixes any inconsistencies.
*
* @param sourceURIs The source volumes
* @param targetURIs The target volumes
*/
public void updateSourceAndTargetPairings(List<URI> sourceURIs, List<URI> targetURIs) {
final String KEY = "%s:%s";
List<Volume> sources = dbClient.queryObject(Volume.class, sourceURIs);
List<Volume> targets = dbClient.queryObject(Volume.class, targetURIs);
// Convenience maps
Map<String, Volume> volumesMap = new HashMap<>();
for (Volume v : Iterables.concat(sources, targets)) {
String key = format(KEY, v.getStorageController(), v.getNativeId());
volumesMap.put(key, v);
}
final Map<String, String> tgtURI2tgtDevId = new HashMap<>();
for (Volume target : targets) {
tgtURI2tgtDevId.put(target.getId().toString(), target.getNativeId());
}
Volume firstSource = sources.get(0);
StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, firstSource.getStorageController());
Volume firstTarget = targets.get(0);
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
Collection<CIMObjectPath> syncPairs = null;
try {
// Note that we may have existing sync pairs in the consistency group.
syncPairs = getConsistencyGroupSyncPairs(sourceSystem, firstSource, targetSystem, firstTarget);
} catch (WBEMException e) {
log.error("Failed to update SRDF pairings", e);
return;
}
for (CIMObjectPath syncPair : syncPairs) {
log.info("Checking {}", syncPair);
// Get the deviceID for the system (source) element from SMI-S provider
String srcEl = syncPair.getKeyValue(CP_SYSTEM_ELEMENT).toString();
CIMObjectPath srcElPath = new CIMObjectPath(srcEl);
String trustedSrcDevId = srcElPath.getKeyValue(CP_DEVICE_ID).toString();
// Get the deviceID for the synced (target) element from SMI-S provider
String tgtEl = syncPair.getKeyValue(CP_SYNCED_ELEMENT).toString();
CIMObjectPath tgtElPath = new CIMObjectPath(tgtEl);
String trustedTgtDevId = tgtElPath.getKeyValue(CP_DEVICE_ID).toString();
// Get ViPR's side which requires validating...
String srcKey = format(KEY, sourceSystem.getId(), trustedSrcDevId);
Volume srcVolume = volumesMap.get(srcKey);
if (srcVolume == null) {
// Skip existing source volumes that were part of the consistency group.
log.info("Skipping as {} is an existing consistency group member", srcKey);
continue;
}
StringSet srdfTargets = srcVolume.getSrdfTargets();
Collection<String> uncheckedTgtDevIds = transform(srdfTargets, new Function<String, String>() {
@Override
public String apply(String targetURI) {
return tgtURI2tgtDevId.get(targetURI);
}
});
if (!uncheckedTgtDevIds.contains(trustedTgtDevId)) {
log.info("Found pairing inconsistency!");
String msg = format("Source %s is paired with Target %s", trustedSrcDevId, trustedTgtDevId);
log.info(msg);
// The target found in the sync pair will need updating in ViPR (has wrong SRDF parent)
Volume invalidTgt = volumesMap.get(format(KEY, targetSystem.getId(), trustedTgtDevId));
// This SRDF parent will need its SRDF target list updating (remove the target)
Volume invalidSrc = dbClient.queryObject(Volume.class, invalidTgt.getSrdfParent().getURI());
// The source found in the sync pair will need its SRDF target list updating (add the real target)
Volume trustedSrc = volumesMap.get(format(KEY, sourceSystem.getId(), trustedSrcDevId));
invalidTgt.setSrdfParent(new NamedURI(trustedSrc.getId(), trustedSrc.getLabel()));
trustedSrc.getSrdfTargets().add(invalidTgt.getId().toString());
invalidSrc.getSrdfTargets().remove(invalidTgt.getId().toString());
// Update the volume labels (and labels on associated Vplex volume if any)
updateVolumeLabels(trustedSrc, invalidTgt);
// Rename the volume on the vmax array itself and update the deviceLabel
helper.renameVolume(dbClient, targetSystem, invalidTgt, invalidTgt.getLabel());
dbClient.updateAndReindexObject(asList(invalidTgt, trustedSrc, invalidSrc));
}
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SRDFOperations method removeFromDeviceGroups.
@SuppressWarnings("rawtypes")
private boolean removeFromDeviceGroups(final StorageSystem system, final StorageSystem forProvider, final Volume volume, final BlockConsistencyGroup cg) {
log.info("removeFromDeviceGroups:");
log.info("Volume: {} / {}", volume.getDeviceLabel(), volume.getNativeId());
log.info("Array: {}", system.getSerialNumber());
log.info("Provider: {}", forProvider.getSmisProviderIP());
boolean removedFromAllGroups = true;
try {
String cgLabel = (cg.getAlternateLabel() != null) ? cg.getAlternateLabel() : cg.getLabel();
log.info("Volume nativeId: {}, CG name: {}", volume.getNativeId(), cgLabel);
CIMObjectPath deviceGroupPath = getDeviceGroup(system, forProvider, volume, cgLabel);
CIMObjectPath volumePath = cimPath.getBlockObjectPath(system, volume);
CIMObjectPath repSvcPath = cimPath.getControllerReplicationSvcPath(system);
if (deviceGroupPath != null) {
log.info(format("Found Volume %s to be a member of group %s", volume.getNativeId(), deviceGroupPath));
CIMArgument[] inArgs = helper.getRemoveMembersInputArguments(deviceGroupPath, new CIMObjectPath[] { volumePath });
CIMArgument[] outArgs = new CIMArgument[5];
helper.invokeMethod(forProvider, repSvcPath, REMOVE_MEMBERS, inArgs, outArgs);
if (!getVolumesPartOfReplicationGroup(deviceGroupPath, forProvider, system).isEmpty()) {
log.warn(format("Group %s still has Volumes part of it.", deviceGroupPath));
removedFromAllGroups = false;
}
// From 8.0 providers, DeleteOnEmptyElement property is not supported on Group creations.
// hence, we need to check and delete the RG when it becomes empty.
CIMInstance deviceGroupInstance = helper.checkExists(forProvider, deviceGroupPath, false, false);
if (deviceGroupInstance != null) {
if (getVolumesPartOfRG(deviceGroupPath, forProvider, system).isEmpty()) {
// delete RG
log.info("No more volumes left on Group {}, Deleting it.", deviceGroupPath.toString());
inArgs = helper.getDeleteReplicationGroupInputArguments(system, deviceGroupInstance.getPropertyValue(CP_ELEMENT_NAME).toString());
helper.invokeMethod(forProvider, repSvcPath, SmisConstants.DELETE_GROUP, inArgs, outArgs);
}
}
} else {
// volume is not found to be part of SRDF RG. return false indicating this method didn't process anything.
removedFromAllGroups = false;
}
} catch (WBEMException e) {
log.debug("Failed to remove volume {} from its replication group, probably already removed", volume.getId(), e);
} catch (Exception e) {
log.debug("Failed to remove volume {} from its replication group, probabaly already removed", volume.getId(), e);
}
return removedFromAllGroups;
}
Aggregations