use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class CommunicationInterfaceTest method getCIMClient.
private void getCIMClient(AccessProfile accessProfile, WBEMClient cimClient) throws SMIPluginException {
try {
CIMObjectPath path = CimObjectPathCreator.createInstance(accessProfile.getProtocol(), accessProfile.getIpAddress(), accessProfile.getProviderPort(), accessProfile.getInteropNamespace(), null, null);
UserPrincipal userPr = new UserPrincipal(accessProfile.getUserName(), accessProfile.getIpAddress());
PasswordCredential pwCred = new PasswordCredential(accessProfile.getPassword(), accessProfile.getIpAddress());
Subject subject = new Subject();
subject.getPrincipals().add(userPr);
subject.getPublicCredentials().add(pwCred);
subject.getPrivateCredentials().add(pwCred);
cimClient.initialize(path, subject, new Locale[] { Locale.US });
} catch (WBEMException e) {
final int errorCode = e.getID() + SMIPluginException.ERRORCODE_START_WBEMEXCEPTION;
// _logger.error(fetchWBEMErrorMessage(e), errorCode);
throw new SMIPluginException("CIMOM Initializing Error", errorCode);
}
}
use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class Processor method addInstance.
/**
* Add CIMObject Paths to Map.
*
* @param keyMap
* @param operation
* @param path
* @throws SMIPluginException
*/
@SuppressWarnings("serial")
protected void addInstance(Map<String, Object> keyMap, String key, CIMInstance instance) throws BaseCollectionException {
try {
Object result = keyMap.get(key);
if (keyMap.containsKey(key) && result instanceof List<?>) {
@SuppressWarnings("unchecked") List<CIMInstance> cimInstanceList = (List<CIMInstance>) keyMap.get(key);
cimInstanceList.add(instance);
keyMap.put(key, cimInstanceList);
} else {
keyMap.put(key, instance);
}
} catch (Exception ex) {
throw new BaseCollectionException("Error while adding CIMInstance to Map : " + instance.getObjectPath(), 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 SSNProcessor method processResult.
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws SMIPluginException {
CloseableIterator<CIMInstance> synchronizedInstances = null;
EnumerateResponse<CIMInstance> synchronizedInstanceChunks = null;
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
try {
synchronizedInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
synchronizedInstances = synchronizedInstanceChunks.getResponses();
processSynchronizedInstance(synchronizedInstances, keyMap);
while (!synchronizedInstanceChunks.isEnd()) {
synchronizedInstanceChunks = client.getInstancesWithPath(Constants.SYNC_PATH, synchronizedInstanceChunks.getContext(), Constants.SYNC_BATCH_SIZE);
processSynchronizedInstance(synchronizedInstanceChunks.getResponses(), keyMap);
}
}//
catch (Exception e) {
if (!(e instanceof BaseCollectionException)) {
_logger.error("Processing Snapshots failed : ", e);
}
} finally {
if (null != synchronizedInstances) {
synchronizedInstances.close();
}
if (null != synchronizedInstanceChunks) {
try {
client.closeEnumeration(Constants.SYNC_PATH, synchronizedInstanceChunks.getContext());
} catch (WBEMException e) {
_logger.debug("Exception occurred while closing enumeration", e);
}
}
}
resultObj = null;
}
use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class StorageSystemStatsProcessor method processResult.
/**
* System metrics sequence: string CSVSequence[] = InstanceID, ElementType,
* TotalIOs, KBytesTransferred, ReadIOs, ReadHitIOs, KBytesRead, WriteIOs,
* WriteHitIOs, KBytesWritten;
*/
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws SMIPluginException {
long timeInMillis;
try {
timeInMillis = (Long) keyMap.get(Constants._TimeCollected);
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
String[] arrayStats = ((String[]) outputArguments[0].getValue())[0].split("\n");
List<String> metricSequence = (List<String>) keyMap.get(Constants.STORAGEOS_SYSTEM_MANIFEST);
_logger.debug("System metricNames Sequence {}", metricSequence);
for (String arrayStat : arrayStats) {
if (arrayStat.isEmpty()) {
_logger.debug("Empty arrayStat returned as part of Statistics Response");
continue;
}
Stat systemStat = new Stat();
Iterable<String> splitIterator = Splitter.on(Constants.SEMI_COLON).split(arrayStat);
List<String> systemMetricList = Lists.newLinkedList(splitIterator);
String nativeGuid = getSystemNativeGuidFromMetric(systemMetricList.get(0).toUpperCase(), keyMap);
systemStat.setNativeGuid(nativeGuid);
systemStat.setResourceId(profile.getSystemId());
systemStat.setServiceType(Constants._Block);
systemStat.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
systemStat.setTimeInMillis(timeInMillis);
if (null != metricSequence && !metricSequence.isEmpty()) {
injectSystemStatMetrics(metricSequence, systemStat, systemMetricList);
} else {
_logger.error("failed processing System Metric values as metric sequence is null.");
}
metricsObjList.add(systemStat);
}
_logger.info("injected system statistics in DB.");
} catch (Exception e) {
_logger.error("Failed while extracting Stats for storage Systems: ", e);
}
resultObj = null;
}
use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class VolumeProcessor method addMetricstoMetricsObject.
/**
* Parse NativeGuid, create Volume CIMObjectPaths by using nativeGuids. Get
* the associated Metrics Object for each Volume, update with
* ReadIOs,WriteIOs, guid content.
*
* string CSVSequence[] = InstanceID,
* ElementType, TotalIOs, KBytesTransferred, ReadIOs, KBytesRead, WriteIOs,
* KBytesWritten;
*
* @param keyMap
* @param volume
* @param metricsObjList
* @throws SMIPluginException
*/
private void addMetricstoMetricsObject(Map<String, Object> keyMap, String volume, List<Stat> metricsObjList, long timeinMillis, List<String> metricSequence, DbClient dbClient) throws SMIPluginException {
String nativeGuid = null;
try {
_logger.debug("Volumes :" + volume);
Iterable<String> splitIterator = Splitter.on(Constants.SEMI_COLON).split(volume);
List<String> metricValuesList = Lists.newLinkedList(splitIterator);
// translated Attributes is needed to create CIMObject at runtime
// without querying it from Provider,
// which increases performance a lot, by reducing SMI-S calls
nativeGuid = translatedAttributes(metricValuesList.get(0).toUpperCase(), keyMap);
CIMObjectPath path = null;
if (nativeGuid.contains(_symm)) {
path = createCIMPath(nativeGuid, _symmvolume, _symmsystem, keyMap);
} else if (nativeGuid.contains(_clar)) {
path = createCIMPath(nativeGuid, _clarvolume, _clarsystem, keyMap);
}
// Inject Project, COS, tenant ID
Stat statObj = _zeroRecordGenerator.injectattr(keyMap, nativeGuid, null);
if (statObj != null) {
@SuppressWarnings("unchecked") List<CIMObjectPath> volList = (List<CIMObjectPath>) keyMap.get(Constants._Volumes);
volList.add(path);
statObj.setServiceType(Constants._Block);
statObj.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
statObj.setTimeInMillis(timeinMillis);
_statsColumnInjector.injectColumns(statObj, dbClient);
// Default Capacity in Model is -1. As snapshotCount and
// capacity is cumulative Count of multiple Snapshots, making to
// default 0
// for each retrieved Volume.
int count = 0;
for (String metricName : metricSequence) {
String metricValue = metricValuesList.get(count);
switch(VolumeMetric.lookup(metricName)) {
case InstanceID:
case ElementType:
count++;
break;
case KBytesWritten:
statObj.setBandwidthIn(ControllerUtils.getLongValue(metricValue));
count++;
break;
case KBytesRead:
statObj.setBandwidthOut(ControllerUtils.getLongValue(metricValue));
count++;
break;
case TotalIOs:
statObj.setTotalIOs(ControllerUtils.getLongValue(metricValue));
count++;
break;
case ReadIOs:
statObj.setReadIOs(ControllerUtils.getLongValue(metricValue));
count++;
break;
case WriteIOs:
statObj.setWriteIOs(ControllerUtils.getLongValue(metricValue));
count++;
break;
case KBytesTransferred:
statObj.setKbytesTransferred(ControllerUtils.getLongValue(metricValue));
count++;
break;
case IdleTimeCounter:
if (null != metricValue && 0 < metricValue.trim().length()) {
statObj.setIdleTimeCounter(ControllerUtils.getLongValue(metricValue));
}
count++;
break;
case IOTimeCounter:
if (null != metricValue && 0 < metricValue.trim().length()) {
statObj.setIoTimeCounter(ControllerUtils.getLongValue(metricValue));
}
count++;
break;
case EMCQueueLength:
if (null != metricValue && 0 < metricValue.trim().length()) {
statObj.setQueueLength(ControllerUtils.getLongValue(metricValue));
}
count++;
break;
default:
_logger.warn("Ignoring unknown metric {} during system metric processing:", metricName);
count++;
break;
}
}
metricsObjList.add(statObj);
}
} catch (Exception ex) {
_logger.error("Processing Volume : {} failed : ", volume, ex);
}
}
Aggregations