version 1.18, 2003/08/22 14:49:49
|
version 1.26, 2005/02/14 21:15:36
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
#include <iostream> | #include <iostream> |
#include <Pegasus/Handler/CIMHandler.h> | #include <Pegasus/Handler/CIMHandler.h> |
#include <Pegasus/Repository/CIMRepository.h> | #include <Pegasus/Repository/CIMRepository.h> |
|
#include <Pegasus/Common/Tracer.h> |
| |
#include "snmpIndicationHandler.h" | #include "snmpIndicationHandler.h" |
| |
|
|
// l10n - note: ignoring indication language | // l10n - note: ignoring indication language |
void snmpIndicationHandler::handleIndication( | void snmpIndicationHandler::handleIndication( |
const OperationContext& context, | const OperationContext& context, |
|
const String nameSpace, |
|
CIMInstance& indication, |
CIMInstance& handler, | CIMInstance& handler, |
CIMInstance& indication, String nameSpace, |
CIMInstance& subscription, |
ContentLanguages & contentLanguages) | ContentLanguages & contentLanguages) |
{ | { |
Array<String> propOIDs; | Array<String> propOIDs; |
|
|
String mapstr1; | String mapstr1; |
String mapstr2; | String mapstr2; |
| |
|
PEG_METHOD_ENTER (TRC_IND_HANDLER, |
|
"snmpIndicationHandler::handleIndication"); |
|
|
|
try |
|
{ |
CIMClass indicationClass = _repository->getClass( | CIMClass indicationClass = _repository->getClass( |
nameSpace, indication.getClassName(), false); |
nameSpace, indication.getClassName(), false, true, |
|
false, CIMPropertyList()); |
| |
Uint32 propertyCount = indication.getPropertyCount(); | Uint32 propertyCount = indication.getPropertyCount(); |
| |
|
|
// and passing this instance as it is to deliverTrap() call | // and passing this instance as it is to deliverTrap() call |
| |
#ifdef HPUX_EMANATE | #ifdef HPUX_EMANATE |
snmpDeliverTrap_emanate emanateTrap; |
static snmpDeliverTrap_emanate emanateTrap; |
#else | #else |
snmpDeliverTrap_stub emanateTrap; |
static snmpDeliverTrap_stub emanateTrap; |
#endif | #endif |
| |
Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost")); | Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost")); |
|
|
PEG_NOT_FOUND)) | PEG_NOT_FOUND)) |
{ | { |
// properties from the handler instance | // properties from the handler instance |
String targetHost, otherTargetHostFormat; |
String targetHost; |
String securityName, engineID; |
String otherTargetHostFormat = String(); |
Uint16 targetHostFormat, snmpVersion; |
String securityName = String(); |
|
String engineID = String(); |
|
Uint16 targetHostFormat = 0; |
|
Uint16 snmpVersion = 0; |
Uint32 portNumber; | Uint32 portNumber; |
| |
String trapOid; | String trapOid; |
|
|
} | } |
else | else |
{ | { |
|
PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, |
|
"Invalid MappingStrings Value " + trapOid); |
|
PEG_METHOD_EXIT(); |
// l10n | // l10n |
// throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value"); | // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value"); |
throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, |
|
|
} | } |
else | else |
{ | { |
|
PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, |
|
"Qualifier MappingStrings can not be found."); |
|
PEG_METHOD_EXIT(); |
//L10N_ TODO DONE | //L10N_ TODO DONE |
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Qualifier MappingStrings can not be found"); | //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Qualifier MappingStrings can not be found"); |
MessageLoaderParms parms("Handler.snmpIndicationHandler.snmpIndicationHandler.QUALIFIER_MAPPINGS_NOT_FOUND", | MessageLoaderParms parms("Handler.snmpIndicationHandler.snmpIndicationHandler.QUALIFIER_MAPPINGS_NOT_FOUND", |
|
|
| |
handler.getProperty(targetHostPos).getValue().get(targetHost); | handler.getProperty(targetHostPos).getValue().get(targetHost); |
handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat); | handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat); |
|
if (otherTargetHostFormatPos != PEG_NOT_FOUND) |
|
{ |
handler.getProperty(otherTargetHostFormatPos).getValue().get | handler.getProperty(otherTargetHostFormatPos).getValue().get |
(otherTargetHostFormat); | (otherTargetHostFormat); |
|
} |
|
if (portNumberPos != PEG_NOT_FOUND) |
|
{ |
handler.getProperty(portNumberPos).getValue().get(portNumber); | handler.getProperty(portNumberPos).getValue().get(portNumber); |
|
} |
|
else |
|
{ |
|
// default port |
|
portNumber = SNMP_TRAP_DEFAULT_PORT; |
|
} |
|
|
handler.getProperty(snmpVersionPos).getValue().get(snmpVersion); | handler.getProperty(snmpVersionPos).getValue().get(snmpVersion); |
|
if (securityNamePos != PEG_NOT_FOUND) |
|
{ |
handler.getProperty(securityNamePos).getValue().get(securityName); | handler.getProperty(securityNamePos).getValue().get(securityName); |
|
} |
|
if (engineIDPos != PEG_NOT_FOUND) |
|
{ |
handler.getProperty(engineIDPos).getValue().get(engineID); | handler.getProperty(engineIDPos).getValue().get(engineID); |
|
} |
| |
emanateTrap.deliverTrap( | emanateTrap.deliverTrap( |
trapOid, | trapOid, |
|
|
} | } |
else | else |
{ | { |
|
PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, |
|
"Invalid IndicationHandlerSNMPMapper instance."); |
|
PEG_METHOD_EXIT(); |
// l10n | // l10n |
| |
// throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, | // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, |
|
|
"Invalid IndicationHandlerSNMPMapper instance")); | "Invalid IndicationHandlerSNMPMapper instance")); |
} | } |
} | } |
|
catch (CIMException & c) |
|
{ |
|
PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, c.getMessage()); |
|
PEG_METHOD_EXIT(); |
|
|
|
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, c.getMessage()); |
|
} |
|
catch (Exception& e) |
|
{ |
|
PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, e.getMessage()); |
|
PEG_METHOD_EXIT(); |
|
|
|
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, e.getMessage()); |
|
} |
|
catch (...) |
|
{ |
|
PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, |
|
"Failed to deliver trap."); |
|
PEG_METHOD_EXIT(); |
|
|
|
throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, |
|
MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.FAILED_TO_DELIVER_TRAP", |
|
"Failed to deliver trap.")); |
|
} |
|
} |
| |
// This is the dynamic entry point into this dynamic module. The name of | // This is the dynamic entry point into this dynamic module. The name of |
// this handler is "snmpIndicationHandler" which is appended to "PegasusCreateHandler_" | // this handler is "snmpIndicationHandler" which is appended to "PegasusCreateHandler_" |