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());
}
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;
}
};
}
}
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;
}
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();
}
}
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();
}
}
Aggregations