Search in sources :

Example 21 with WBEMException

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);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 22 with WBEMException

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;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 23 with WBEMException

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;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) WBEMException(javax.wbem.WBEMException) WBEMException(javax.wbem.WBEMException)

Example 24 with WBEMException

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;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) WBEMException(javax.wbem.WBEMException)

Example 25 with WBEMException

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) Host(com.emc.storageos.db.client.model.Host) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) CIMArgument(javax.cim.CIMArgument)

Aggregations

WBEMException (javax.wbem.WBEMException)122 CIMObjectPath (javax.cim.CIMObjectPath)90 CIMInstance (javax.cim.CIMInstance)63 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)60 CIMArgument (javax.cim.CIMArgument)52 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)38 ArrayList (java.util.ArrayList)29 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)27 Volume (com.emc.storageos.db.client.model.Volume)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 WBEMClient (javax.wbem.client.WBEMClient)19 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)16 HashSet (java.util.HashSet)15 URI (java.net.URI)13 HashMap (java.util.HashMap)13 BlockObject (com.emc.storageos.db.client.model.BlockObject)10 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)9 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)8