Search in sources :

Example 11 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class Executor method executeOperation.

/**
 * Execute the Operation defined in Domain Logic XML. Use Generator to
 * return Command Objects for an Operation. Then execute them either in a
 * multi-threaded fashion or singleThreaded.
 *
 * @param operation
 * @throws BaseCollectionException
 */
private void executeOperation(Operation operation) throws BaseCollectionException {
    try {
        if (!isSupportedOperation(operation)) {
            _LOGGER.info("Filtered the operation {} as per instructions", operation.getMessage());
            return;
        }
        _LOGGER.info(null == operation.getMessage() ? "START Executing operation" : "START :" + operation.getMessage());
        _commandObjects = _generator.returnCommandObjects(operation, _keyMap);
        // the same time.
        for (Command commandObj : _commandObjects) {
            printArgs(commandObj);
            Object resultObj = null;
            try {
                resultObj = commandObj.execute();
                processResult(operation, resultObj, commandObj);
            } catch (Exception e) {
                _LOGGER.error("Execution failed for :", e);
                // We do not want 'Provider/Firmware Not Supported Error' to get suppressed. check and throw again.
                if (e instanceof SMIPluginException) {
                    int errorCode = ((SMIPluginException) e).getErrorCode();
                    if (errorCode == SMIPluginException.ERRORCODE_PROVIDER_NOT_SUPPORTED || errorCode == SMIPluginException.ERRORCODE_FIRMWARE_NOT_SUPPORTED || errorCode == SMIPluginException.ERRORCODE_OPERATIONFAILED) {
                        throw e;
                    }
                }
            }
        }
    } catch (final Exception e) {
        _LOGGER.error("Operation Execution failed : ", e);
        customizeException(e, operation);
    }
    _LOGGER.debug(null == operation.getMessage() ? "END Executing operation" : "END :" + operation.getMessage());
}
Also used : Command(com.emc.storageos.plugins.common.commandgenerator.Command) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 12 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class Processor method addPath.

/**
 * Add CIMObject Paths to Map.
 *
 * @param keyMap
 * @param operation
 * @param path
 * @throws SMIPluginException
 */
@SuppressWarnings("serial")
protected void addPath(Map<String, Object> keyMap, String key, CIMObjectPath path) throws BaseCollectionException {
    try {
        Object result = keyMap.get(key);
        if (keyMap.containsKey(key) && result instanceof List<?>) {
            @SuppressWarnings("unchecked") List<CIMObjectPath> cimPathList = (List<CIMObjectPath>) keyMap.get(key);
            cimPathList.add(path);
            keyMap.put(key, cimPathList);
        } else {
            keyMap.put(key, path);
        }
    } catch (Exception ex) {
        throw new BaseCollectionException("Error while adding CIMObject Path to Map : " + path, ex) {

            @Override
            public int getErrorCode() {
                // To-Do errorCode
                return -1;
            }
        };
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) List(java.util.List) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 13 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class SMICommunicationInterface method getCIMClient.

/**
 * Creates a new WEBClient for a given IP, based on AccessProfile
 *
 * @param accessProfile
 *            : AccessProfile for the providers
 * @throws WBEMException
 *             : if WBEMException while creating the WBEMClient
 * @throws SMIPluginException
 * @return WBEMClient : initialized instance of WBEMClientCIMXML
 */
private static WBEMClient getCIMClient(AccessProfile accessProfile) throws SMIPluginException {
    WBEMClient cimClient = null;
    try {
        final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
        CimConnection cxn = connectionFactory.getConnection(accessProfile.getIpAddress(), accessProfile.getProviderPort());
        if (cxn == null) {
            throw new SMIPluginException(String.format("Not able to get CimConnection to SMISProvider %s on port %s", accessProfile.getIpAddress(), accessProfile.getProviderPort()), SMIPluginException.ERRORCODE_NO_WBEMCLIENT);
        }
        cimClient = cxn.getCimClient();
        if (null == cimClient) {
            throw new SMIPluginException("Not able to get CIMOM client", SMIPluginException.ERRORCODE_NO_WBEMCLIENT);
        }
    } catch (final IllegalStateException ex) {
        _logger.error("Not able to get CIMOM Client instance for ip {} due to ", accessProfile.getIpAddress(), ex);
        throw new SMIPluginException(SMIPluginException.ERRORCODE_NO_WBEMCLIENT, ex.fillInStackTrace(), ex.getMessage());
    }
    return cimClient;
}
Also used : CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) WBEMClient(javax.wbem.client.WBEMClient)

Example 14 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class SMICommunicationInterface method collectStatisticsInformation.

/**
 * To-Do : Argument Changes, to accomodate ProSphere usage
 */
@Override
public void collectStatisticsInformation(AccessProfile accessProfile) throws BaseCollectionException {
    try {
        _logger.info("Access Profile Details :" + accessProfile.toString());
        _wbemClient = getCIMClient(accessProfile);
        initMap(accessProfile);
        StorageSystem storageSystem = queryStorageSystem(accessProfile);
        String providerVersion = getProviderVersionString(storageSystem);
        if (null != providerVersion) {
            _keyMap.put(Constants.VERSION, providerVersion);
            _keyMap.put(Constants.IS_NEW_SMIS_PROVIDER, isSMIS8XProvider(providerVersion));
        }
        Namespace _ns = null;
        _ns = (Namespace) namespaces.getNsList().get(METERING);
        _logger.info("CIMClient initialized successfully");
        executor.setKeyMap(_keyMap);
        executor.execute(_ns);
        dumpStatRecords();
        injectStats();
    } catch (Exception e) {
        throw new SMIPluginException(e.getMessage());
    } finally {
        releaseResources();
    }
}
Also used : SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) Namespace(com.emc.storageos.plugins.common.domainmodel.Namespace) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 15 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class SMICommunicationInterface method scan.

/**
 * {@inheritDoc}
 */
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    URI providerURI = null;
    StorageProvider providerObj = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        _logger.info("Access Profile Details :" + accessProfile.toString());
        providerURI = accessProfile.getSystemId();
        providerObj = _dbClient.queryObject(StorageProvider.class, providerURI);
        _keyMap = new ConcurrentHashMap<String, Object>();
        _wbemClient = getCIMClient(accessProfile);
        _logger.info("CIMClient initialized successfully");
        _keyMap.put(Constants.PROPS, accessProfile.getProps());
        if (accessProfile.getCache() == null) {
            accessProfile.setCache(new HashMap<String, StorageSystemViewObject>());
        }
        _keyMap.put(Constants._computerSystem, new ArrayList<CIMObjectPath>());
        _keyMap.put(Constants.REGISTEREDPROFILE, CimObjectPathCreator.createInstance(Constants.PROFILECLASS, "interop"));
        _keyMap.put(Constants._cimClient, _wbemClient);
        _keyMap.put(Constants.dbClient, _dbClient);
        _keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
        if (_networkDeviceController != null) {
            _keyMap.put(Constants.networkDeviceController, _networkDeviceController);
        }
        _keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
        _keyMap.put(Constants.ACCESSPROFILE, accessProfile);
        _keyMap.put(Constants.SYSTEMCACHE, accessProfile.getCache());
        executor.setKeyMap(_keyMap);
        executor.execute((Namespace) namespaces.getNsList().get(SCAN));
        // scan succeeds
        detailedStatusMessage = String.format("Scan job completed successfully for " + "SMISProvider: %s", providerURI.toString());
    } catch (Exception e) {
        detailedStatusMessage = String.format("Scan job failed for SMISProvider: %s because %s", providerURI.toString(), e.getMessage());
        throw new SMIPluginException(detailedStatusMessage);
    } finally {
        if (providerObj != null) {
            try {
                // set detailed message
                providerObj.setLastScanStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(providerObj);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
        releaseResources();
    }
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) CIMObjectPath(javax.cim.CIMObjectPath) LocalReplicaObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.LocalReplicaObject) RemoteMirrorObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Aggregations

SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)22 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)12 List (java.util.List)7 CIMObjectPath (javax.cim.CIMObjectPath)7 WBEMException (javax.wbem.WBEMException)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 AccessProfile (com.emc.storageos.plugins.AccessProfile)6 IOException (java.io.IOException)5 URI (java.net.URI)5 CIMInstance (javax.cim.CIMInstance)5 DbClient (com.emc.storageos.db.client.DbClient)4 Stat (com.emc.storageos.db.client.model.Stat)4 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)3 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)3 LocalReplicaObject (com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.LocalReplicaObject)3 RemoteMirrorObject (com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject)3 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)3 Iterator (java.util.Iterator)3 CIMArgument (javax.cim.CIMArgument)3