use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doAddStorageSystem.
@Override
public String doAddStorageSystem(final StorageSystem storage) throws DeviceControllerException {
try {
String system = "";
CIMObjectPath seSystemRegistrationSvc = _helper.getRegistrationService(storage);
CIMArgument[] inArgs = _helper.getAddStorageCIMArguments(storage);
CIMArgument[] outArgs = new CIMArgument[5];
Object result = _helper.invokeMethod(storage, seSystemRegistrationSvc, SmisConstants.EMC_ADD_SYSTEM, inArgs, outArgs);
javax.cim.UnsignedInteger32 status = (javax.cim.UnsignedInteger32) result;
if (status.intValue() == 0 && outArgs[0] != null) {
outArgs[0].getName();
CIMObjectPath objPath = (CIMObjectPath) outArgs[0].getValue();
system = objPath.getKey(Constants._Name).getValue().toString();
}
return system;
} catch (WBEMException ex) {
_log.debug("Failed to add storage system to SMI-S Provider : " + ex.getMessage());
throw new DeviceControllerException(ex);
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisStorageDevicePreProcessor method createStoragePoolSetting.
/**
* Create StoragePool Setting for a given pool. This will be useful before
* Here are the steps to create a new PoolSetting.
* 1. First find the storagePoolCapability for a given storagepool.
* 2. Use the capability to create a new StoragePool Setting.
* 3. Update instance to set the
*
* creating a volume.
*
* @param storageSystem
* @param storagePool
* @param thinVolumePreAllocateSize
* @throws Exception
*/
public CIMInstance createStoragePoolSetting(StorageSystem storageSystem, StoragePool storagePool, long thinVolumePreAllocateSize) throws Exception {
_log.info(String.format("Create StoragePool Setting Start - Array: %s, Pool: %s, %n thinVolumePreAllocateSize: %s", storageSystem.getSerialNumber(), storagePool.getNativeId(), thinVolumePreAllocateSize));
CIMObjectPath poolSvcPath = _cimPath.getStoragePoolPath(storageSystem, storagePool);
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
CIMInstance modifiedSettingInstance = null;
try {
_log.debug("Op1 start: Getting poolCapabilities associated with this pool");
final Iterator<?> it = client.associatorNames(poolSvcPath, SmisConstants.CIM_ELEMENTCAPABILITIES, SmisConstants.SYMM_STORAGEPOOL_CAPABILITIES, null, null);
if (it.hasNext()) {
final CIMObjectPath poolCapabilityPath = (CIMObjectPath) it.next();
_log.debug("Op1 end: received pool capability from provider {}", poolCapabilityPath);
CIMArgument<?>[] outputArgs = new CIMArgument<?>[1];
_log.info("Invoking CIMClient to create to create a new Setting");
client.invokeMethod(poolCapabilityPath, SmisConstants.CP_CREATE_SETTING, _helper.getCreatePoolSettingArguments(), outputArgs);
CIMObjectPath settingPath = _cimPath.getCimObjectPathFromOutputArgs(outputArgs, SmisConstants.CP_NEWSETTING);
modifiedSettingInstance = new CIMInstance(settingPath, _helper.getModifyPoolSettingArguments(thinVolumePreAllocateSize));
client.modifyInstance(modifiedSettingInstance, SmisConstants.PS_THIN_VOLUME_INITIAL_RESERVE);
_log.info("Modified the poolSetting instance to set ThinProvisionedInitialReserve");
}
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
throw e;
} catch (Exception e) {
_log.error("Problem in createStoragePoolSetting: " + storagePool.getNativeId(), e);
throw e;
} finally {
_log.info(String.format("Create StoragePool Setting End - Array:%s, Pool: %s", storageSystem.getSerialNumber(), storagePool.getNativeId()));
}
return modifiedSettingInstance;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class IBMSmisSynchSubTaskJob method pollNewSGMembers.
private JobPollResult pollNewSGMembers(JobContext jobContext, long trackingPeriodInMillis) {
String instanceId = sgName;
try {
_pollResult.setJobName(getJobName());
_pollResult.setJobId(instanceId);
_pollResult.setJobPercentComplete(0);
_status = JobStatus.IN_PROGRESS;
setErrorTrackingStartTime(0L);
sgMemberPaths = jobContext.getXIVSmisCommandHelper().getSGMembers(storageSystem, sgName);
if (sgMemberPaths.size() >= expectedObjCount) {
_pollResult.setJobPercentComplete(100);
_status = JobStatus.SUCCESS;
_logger.info("IBMSmisSynchSubTaskJob: {} succeeded", instanceId);
}
// if resultObjPaths is not empty, we don't know it is full or partial result
// we keep trying, until time out
} catch (WBEMException e) {
if (e.getID() == WBEMException.CIM_ERR_NOT_FOUND) {
_status = JobStatus.FAILED;
_errorDescription = e.getMessage();
_logger.error(String.format("SMI-S object not found. Name: %s, ID: %s, Desc: %s", getJobName(), instanceId, _errorDescription), e);
} else {
processTransientError(instanceId, trackingPeriodInMillis, e.getMessage(), e);
}
} catch (Exception e) {
processTransientError(instanceId, trackingPeriodInMillis, e.getMessage(), e);
} finally {
try {
_logger.info("SmisJob: Post processing job: id {}", instanceId);
// reset from previous possible transient error in post processing status.
_postProcessingStatus = JobStatus.SUCCESS;
updateStatus(jobContext);
if (_postProcessingStatus == JobStatus.ERROR) {
processPostProcessingError(instanceId, trackingPeriodInMillis, _errorDescription, null);
}
} catch (Exception e) {
setFatalErrorStatus(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 IBMSmisSynchSubTaskJob method pollRemovedCGMembers.
private JobPollResult pollRemovedCGMembers(JobContext jobContext, long trackingPeriodInMillis) {
String instanceId = null;
try {
CIMObjectPath objPath = getCimJob();
instanceId = objPath.getKey(IBMSmisConstants.CP_INSTANCE_ID).toString();
_pollResult.setJobName(getJobName());
_pollResult.setJobId(instanceId);
_pollResult.setJobPercentComplete(0);
_status = JobStatus.IN_PROGRESS;
setErrorTrackingStartTime(0L);
cgMembers = jobContext.getXIVSmisCommandHelper().getCGMembers(storageSystem, objPath);
if (cgMembers == null || cgMembers.isEmpty()) {
_pollResult.setJobPercentComplete(100);
_status = JobStatus.SUCCESS;
_logger.info("IBMSmisSynchSubTaskJob: {} succeeded", instanceId);
} else {
Set<String> remainingMembers = Sets.intersection(removedCGMembers, cgMembers);
if (remainingMembers.isEmpty()) {
_pollResult.setJobPercentComplete(100);
_status = JobStatus.SUCCESS;
_logger.info("IBMSmisSynchSubTaskJob: {} succeeded", instanceId);
} else {
// all or some volumes are not delete
_logger.debug("Members: " + Joiner.on(',').join(remainingMembers) + " are still in CG");
}
}
} catch (WBEMException e) {
if (e.getID() == WBEMException.CIM_ERR_NOT_FOUND) {
_status = JobStatus.FAILED;
_errorDescription = e.getMessage();
_logger.error(String.format("SMI-S object not found. Name: %s, ID: %s, Desc: %s", getJobName(), instanceId, _errorDescription), e);
} else {
processTransientError(instanceId, trackingPeriodInMillis, e.getMessage(), e);
}
} catch (Exception e) {
processTransientError(instanceId, trackingPeriodInMillis, e.getMessage(), e);
} finally {
try {
_logger.info("SmisJob: Post processing job: id {}", instanceId);
// reset from previous possible transient error in post processing status.
_postProcessingStatus = JobStatus.SUCCESS;
updateStatus(jobContext);
if (_postProcessingStatus == JobStatus.ERROR) {
processPostProcessingError(instanceId, trackingPeriodInMillis, _errorDescription, null);
}
} catch (Exception e) {
setFatalErrorStatus(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 XIVExportOperations method removeInitiatorsUsingSMIS.
// TOD -test
private void removeInitiatorsUsingSMIS(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIList, List<Initiator> initiatorList, List<URI> targets, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} removeInitiators START...", storage.getLabel());
try {
_log.info("removeInitiators: Export mask id: {}", exportMaskURI);
// 2. If any other volumes are impacted by removing this initiator, fail the operation
if (volumeURIList != null) {
_log.info("removeInitiators: volumes : {}", Joiner.on(',').join(volumeURIList));
}
_log.info("removeInitiators: initiators : {}", Joiner.on(',').join(initiatorList));
_log.info("removeInitiators: targets : {}", Joiner.on(',').join(targets));
if (initiatorList != null && !initiatorList.isEmpty()) {
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
CIMObjectPath controllerPath = _cimPath.getSCSIProtocolControllerPath(storage, exportMask.getNativeId());
if (controllerPath != null) {
Map<String, CIMObjectPath> hwIdPaths = _helper.getInitiatorsFromScsiProtocolController(storage, controllerPath);
CIMObjectPath hwIdManagementSvc = _cimPath.getStorageHardwareIDManagementService(storage);
String[] initiatorNames = _helper.getInitiatorNames(initiatorList);
for (String initiator : initiatorNames) {
CIMObjectPath hwIdPath = hwIdPaths.get(initiator);
if (hwIdPath != null) {
try {
CIMArgument[] deleteHwIdIn = _helper.getDeleteStorageHardwareIDInputArgs(storage, hwIdPath);
_helper.invokeMethod(storage, hwIdManagementSvc, SmisConstants.DELETE_STORAGE_HARDWARE_ID, deleteHwIdIn);
} catch (WBEMException e) {
_log.error("deleteStorageHWIDs -- WBEMException: ", e);
} catch (Exception e) {
_log.error("deleteStorageHWIDs -- Exception: " + e);
}
} else {
_log.info("Initiator {} is not on array", initiator);
}
}
CIMObjectPath idCollectionPath = getIdCollectionBySCSIProtocolController(storage, controllerPath);
if (!hasHwIdInCollection(storage, idCollectionPath)) {
// update host label
Host host = _dbClient.queryObject(Host.class, initiatorList.get(0).getHost());
_helper.unsetTag(host, storage.getSerialNumber());
}
} else {
_log.error("Protocol controller is null");
ServiceError error = DeviceControllerErrors.smis.noProtocolControllerCreated();
taskCompleter.error(_dbClient, error);
return;
}
}
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Unexpected error: removeInitiators failed.", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("removeInitiators", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info("{} removeInitiators END...", storage.getLabel());
}
Aggregations