use of javax.cim.UnsignedInteger16 in project coprhd-controller by CoprHD.
the class XIVStorageConfigurationCapabilitiesProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
@SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
_profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
try {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
while (it.hasNext()) {
CIMInstance storageConfigurationInstance = it.next();
UnsignedInteger16[] supportedElementTypeArr = (UnsignedInteger16[]) storageConfigurationInstance.getPropertyValue(SUPPORTED_ELEMENT_TYPES);
String supportedElementTypes = Arrays.toString(supportedElementTypeArr);
if (_logger.isDebugEnabled()) {
_logger.debug("Capability:" + supportedElementTypes);
}
if (supportedElementTypes.contains(THIN_VOLUME_SUPPORTED) && supportedElementTypes.contains(THICK_VOLUME_SUPPORTED)) {
system.setSupportedProvisioningType(SupportedProvisioningTypes.THIN_AND_THICK.name());
} else if (supportedElementTypes.contains(THIN_VOLUME_SUPPORTED)) {
system.setSupportedProvisioningType(SupportedProvisioningTypes.THIN.name());
} else if (supportedElementTypes.contains(THICK_VOLUME_SUPPORTED)) {
system.setSupportedProvisioningType(SupportedProvisioningTypes.THICK.name());
} else {
system.setSupportedProvisioningType(SupportedProvisioningTypes.NONE.name());
}
// should have only one instance
break;
}
_dbClient.persistObject(system);
} catch (Exception e) {
_logger.error("Finding out Storage System Capability on Volume Creation failed: ", e);
}
}
use of javax.cim.UnsignedInteger16 in project coprhd-controller by CoprHD.
the class XIVSupportedAsynchronousActionsProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
_log.info("processResult");
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
@SuppressWarnings("unchecked") Iterator<CIMInstance> iterator = (Iterator<CIMInstance>) resultObj;
while (iterator.hasNext()) {
CIMInstance instance = iterator.next();
UnsignedInteger16[] supportedAsyncActions = (UnsignedInteger16[]) instance.getPropertyValue(Constants.SUPPORTED_ASYNCHRONOUS_ACTIONS);
StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
StringSet supportedAsyncActionsSet = new StringSet();
if (supportedAsyncActions != null) {
for (UnsignedInteger16 actionValue : supportedAsyncActions) {
switch(actionValue.intValue()) {
case Constants.CREATE_ELEMENT_REPLICA_ASYNC_ACTION:
supportedAsyncActionsSet.add(StorageSystem.AsyncActions.CreateElementReplica.name());
break;
case Constants.CREATE_GROUP_REPLICA_ASYNC_ACTION:
supportedAsyncActionsSet.add(StorageSystem.AsyncActions.CreateGroupReplica.name());
break;
default:
}
}
}
device.setSupportedAsynchronousActions(supportedAsyncActionsSet);
StringSet replicationTypes = new StringSet();
replicationTypes.add(SupportedReplicationTypes.LOCAL.name());
device.setSupportedReplicationTypes(replicationTypes);
_dbClient.persistObject(device);
}
} catch (Exception e) {
_log.error("Supported asynchronous action processing failed: ", e);
}
}
use of javax.cim.UnsignedInteger16 in project coprhd-controller by CoprHD.
the class XIVSupportedCopyTypesProcessor method addCopyTypesToStoragePool.
private void addCopyTypesToStoragePool(UnsignedInteger16[] copyTypes, StoragePool storagePool, String thinProvisionedPreAllocateSupported, Map<URI, StoragePool> poolsToMatchWithVpool) {
StringSet set = new StringSet();
for (UnsignedInteger16 n : copyTypes) {
switch(n.intValue()) {
case Constants.ASYNC_COPY_TYPE:
set.add(StoragePool.CopyTypes.ASYNC.name());
break;
case Constants.SYNC_COPY_TYPE:
set.add(StoragePool.CopyTypes.SYNC.name());
break;
case Constants.UNSYNC_ASSOC_COPY_TYPE:
set.add(StoragePool.CopyTypes.UNSYNC_ASSOC.name());
break;
case Constants.UNSYNC_UNASSOC_COPY_TYPE:
set.add(StoragePool.CopyTypes.UNSYNC_UNASSOC.name());
break;
default:
_log.warn("Encountered unknown copy type {} for pool {}", n.intValue(), storagePool.getId());
}
}
storagePool.setThinVolumePreAllocationSupported(Boolean.valueOf(thinProvisionedPreAllocateSupported));
// If the modified list already has this pool, skip the check.
if (!poolsToMatchWithVpool.containsKey(storagePool.getId()) && ImplicitPoolMatcher.checkPoolPropertiesChanged(storagePool.getSupportedCopyTypes(), set)) {
poolsToMatchWithVpool.put(storagePool.getId(), storagePool);
}
storagePool.setSupportedCopyTypes(set);
_dbClient.persistObject(storagePool);
}
use of javax.cim.UnsignedInteger16 in project coprhd-controller by CoprHD.
the class VnxExportOperations method modifyClarPrivileges.
/**
* Method invokes the SMI-S operation to modify the initiator parameters such as type and failovermode.
*
* @param storage
* [in] - StorageSystem representing the array
* @param initiators
* [in] - An array Initiator objects, whose representation will
* be removed from the array.
* @throws Exception
*/
@SuppressWarnings("rawtypes")
public void modifyClarPrivileges(StorageSystem storage, List<Initiator> initiators) throws Exception {
if (initiators == null || initiators.isEmpty()) {
_log.debug("No initiators ...");
return;
}
_log.info("Start -- modifyClarPrivileges");
List<String> initiatorStrings = new ArrayList<String>();
final String RP_INITIATOR_PREFIX = "500124";
final int RP_INITIATOR_TYPE = 31;
final int RP_INITIATOR_FAILOVERMODE = 4;
final CIMProperty[] RP_CLAR_PRIVILIEGE_CIM_PROPERTY = new CIMProperty[] { new CIMProperty<UnsignedInteger16>(SmisConstants.CP_EMC_INITIATOR_TYPE, CIMDataType.UINT16_T, new UnsignedInteger16(RP_INITIATOR_TYPE)), new CIMProperty<UnsignedInteger16>(SmisConstants.CP_EMC_FAILOVER_MODE, CIMDataType.UINT16_T, new UnsignedInteger16(RP_INITIATOR_FAILOVERMODE)) };
CloseableIterator<CIMInstance> privilegeInstances = null;
for (Initiator initiator : initiators) {
if (initiator.getProtocol().equalsIgnoreCase(Initiator.Protocol.FC.name())) {
initiatorStrings.add(WwnUtils.convertWWN(initiator.getInitiatorNode(), FORMAT.NOMARKERS).toString().concat(WwnUtils.convertWWN(initiator.getInitiatorPort(), FORMAT.NOMARKERS).toString()));
}
}
if (initiatorStrings.isEmpty()) {
_log.info("There are no initiators in the list whose privileges need to be changed.");
return;
}
try {
privilegeInstances = _helper.getClarPrivileges(storage);
while (privilegeInstances.hasNext()) {
CIMInstance existingInstance = privilegeInstances.next();
String initiatorType = CIMPropertyFactory.getPropertyValue(existingInstance, SmisConstants.CP_EMC_INITIATOR_TYPE);
// We are only interested in the RP initiators, so check if the initiators are RP initiators
if (existingInstance.toString().contains(storage.getSerialNumber()) && existingInstance.toString().contains(RP_INITIATOR_PREFIX)) {
for (String initiatorString : initiatorStrings) {
if (existingInstance.toString().contains(initiatorString) && (initiatorType != null && Integer.parseInt(initiatorType) != RP_INITIATOR_TYPE)) {
CIMInstance toUpdate = new CIMInstance(existingInstance.getObjectPath(), RP_CLAR_PRIVILIEGE_CIM_PROPERTY);
_log.info("Modifying -- " + existingInstance.toString());
_helper.modifyInstance(storage, toUpdate, SmisConstants.PS_EMC_CLAR_PRIVILEGE);
break;
}
}
}
}
_log.info("end -- modifyClarPrivileges");
} catch (Exception e1) {
_log.error("Unexpected error: modifyClarPrivileges failed");
throw e1;
} finally {
if (null != privilegeInstances) {
privilegeInstances.close();
}
}
}
use of javax.cim.UnsignedInteger16 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;
}
Aggregations