void SendIndication(int seqNum, char *UIDbuffer) { CIMInstance indicationInstance (CIMName ("IndicationStressTestClass")); indicationInstance.setPath(path); indicationInstance.addProperty (CIMProperty ("IndicationIdentifier",String(UIDbuffer))); indicationInstance.addProperty (CIMProperty ("CorrelatedIndications", correlatedIndications)); CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("IndicationTime", currentDateTime)); indicationInstance.addProperty (CIMProperty ("IndicationSequenceNumber", CIMValue(Uint64(seqNum)))); // cout << "IndicationStressTestProvider instance = " << ((CIMObject)indicationInstance).toString() << endl; _indication_handler->deliver (indicationInstance); return; }
CIMObjectPath _createHandlerInstance( CIMClient & client, const String & name, const String & targetHost, const String & securityName, const Uint16 targetHostFormat, const Uint16 snmpVersion) { CIMInstance handlerInstance (PEGASUS_CLASSNAME_INDHANDLER_SNMP); handlerInstance.addProperty (CIMProperty (CIMName ("SystemCreationClassName"), System::getSystemCreationClassName ())); handlerInstance.addProperty (CIMProperty (CIMName ("SystemName"), System::getFullyQualifiedHostName ())); handlerInstance.addProperty (CIMProperty (CIMName ("CreationClassName"), PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString ())); handlerInstance.addProperty (CIMProperty (CIMName ("Name"), name)); handlerInstance.addProperty (CIMProperty (CIMName ("TargetHost"), targetHost)); handlerInstance.addProperty (CIMProperty (CIMName ("TargetHostFormat"), CIMValue ((Uint16) targetHostFormat))); handlerInstance.addProperty (CIMProperty (CIMName ("SNMPSecurityName"), securityName)); handlerInstance.addProperty (CIMProperty (CIMName ("SnmpVersion"), CIMValue ((Uint16) snmpVersion))); handlerInstance.addProperty (CIMProperty (CIMName ("PortNumber"), CIMValue ((Uint32) PORT_NUMBER))); return client.createInstance( PEGASUS_NAMESPACENAME_INTEROP, handlerInstance); }
CIMObjectPath _createHandler (CIMClient & client, const String & name, const String & destination) { CIMInstance handler (HANDLER_CLASSNAME); handler.addProperty (CIMProperty (CIMName ("Name"), name)); handler.addProperty (CIMProperty (CIMName ("Destination"), destination)); CIMObjectPath path = client.createInstance (INTEROPNAMESPACE, handler); return path; }
CIMObjectPath _createSubscription (CIMClient & client, const CIMObjectPath & filterPath, const CIMObjectPath & handlerPath) { CIMInstance subscription (SUBSCRIPTION_CLASSNAME); subscription.addProperty (CIMProperty (CIMName ("Filter"), filterPath, 0, FILTER_CLASSNAME)); subscription.addProperty (CIMProperty (CIMName ("Handler"), handlerPath, 0, HANDLER_CLASSNAME)); CIMObjectPath path = client.createInstance (INTEROPNAMESPACE, subscription); return path; }
CIMObjectPath _createSubscriptionInstance( CIMClient & client, const CIMObjectPath & filterPath, const CIMObjectPath & handlerPath) { CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION); subscriptionInstance.addProperty (CIMProperty (CIMName ("Filter"), filterPath, 0, PEGASUS_CLASSNAME_INDFILTER)); subscriptionInstance.addProperty (CIMProperty (CIMName ("Handler"), handlerPath, 0, PEGASUS_CLASSNAME_INDHANDLER_SNMP)); subscriptionInstance.addProperty (CIMProperty (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2))); return client.createInstance( PEGASUS_NAMESPACENAME_INTEROP, subscriptionInstance); }
void _createSubscriptionInstance (CIMClient & client, const CIMObjectPath & filterPath, const CIMObjectPath & handlerPath, const CIMNamespaceName & subscriptionNS) { CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION); subscriptionInstance.addProperty (CIMProperty (CIMName ("Filter"), filterPath, 0, PEGASUS_CLASSNAME_INDFILTER)); subscriptionInstance.addProperty (CIMProperty (CIMName ("Handler"), handlerPath, 0, PEGASUS_CLASSNAME_INDHANDLER_CIMXML)); subscriptionInstance.addProperty (CIMProperty (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2))); CIMObjectPath path = client.createInstance (subscriptionNS, subscriptionInstance); }
CIMObjectPath _createFilter (CIMClient & client, const String & name, const String & query, const String & queryLanguage, const String & sourceNamespace) { CIMInstance filter (FILTER_CLASSNAME); filter.addProperty (CIMProperty (CIMName ("Name"), name)); filter.addProperty (CIMProperty (CIMName ("Query"), query)); filter.addProperty (CIMProperty (CIMName ("QueryLanguage"), queryLanguage)); filter.addProperty (CIMProperty (CIMName ("SourceNamespace"), sourceNamespace)); CIMObjectPath path = client.createInstance (INTEROPNAMESPACE, filter); return path; }
CIMObjectPath CreateSbscriptionInstance (CIMClient& client, const CIMObjectPath handlerRef, const CIMObjectPath filterRef, const CIMNamespaceName & subscriptionNS) { CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION); subscriptionInstance.addProperty(CIMProperty(CIMName ("Filter"), filterRef, 0, PEGASUS_CLASSNAME_INDFILTER)); subscriptionInstance.addProperty(CIMProperty(CIMName ("Handler"), handlerRef, 0, PEGASUS_CLASSNAME_INDHANDLER_CIMXML)); subscriptionInstance.addProperty (CIMProperty (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2))); CIMObjectPath Ref = client.createInstance(subscriptionNS, subscriptionInstance); Ref.setNameSpace (subscriptionNS); return (Ref); }
void _createHandlerInstance (CIMClient & client, const String & name, const String & destination, const CIMNamespaceName & handlerNS) { CIMInstance handlerInstance (PEGASUS_CLASSNAME_INDHANDLER_CIMXML); handlerInstance.addProperty (CIMProperty (CIMName ("SystemCreationClassName"), System::getSystemCreationClassName ())); handlerInstance.addProperty (CIMProperty (CIMName ("SystemName"), System::getFullyQualifiedHostName ())); handlerInstance.addProperty (CIMProperty (CIMName ("CreationClassName"), PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString ())); handlerInstance.addProperty (CIMProperty (CIMName ("Name"), name)); handlerInstance.addProperty (CIMProperty (CIMName ("Destination"), destination)); CIMObjectPath path = client.createInstance (handlerNS, handlerInstance); }
void _addUint16Property (CIMInstance & instance, const String & name, Uint16 value, Boolean null = false, Boolean isArray = false) { if (null) { instance.addProperty (CIMProperty (CIMName (name), CIMValue (CIMTYPE_UINT16, false))); } else { if (isArray) { Array < Uint16 > values; values.append (value); instance.addProperty (CIMProperty (CIMName (name), values)); } else { instance.addProperty (CIMProperty (CIMName (name), value)); } } }
void _addStringProperty (CIMInstance & instance, const String & name, const String & value, Boolean null = false, Boolean isArray = false) { if (null) { instance.addProperty (CIMProperty (CIMName (name), CIMValue (CIMTYPE_STRING, false))); } else { if (isArray) { Array < String > values; values.append (value); instance.addProperty (CIMProperty (CIMName (name), values)); } else { instance.addProperty (CIMProperty (CIMName (name), value)); } } }
CIMInstance _buildSubscriptionInstance (const CIMObjectPath & filterPath, const CIMName & handlerClass, const CIMObjectPath & handlerPath) { CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION); subscriptionInstance.addProperty (CIMProperty (CIMName ("Filter"), filterPath, 0, PEGASUS_CLASSNAME_INDFILTER)); subscriptionInstance. addProperty (CIMProperty (CIMName ("Handler"), handlerPath, 0, handlerClass)); return subscriptionInstance; }
CIMObjectPath _createFilterInstance( CIMClient & client, const String & name, const String & query, const String & qlang) { CIMInstance filterInstance (PEGASUS_CLASSNAME_INDFILTER); filterInstance.addProperty (CIMProperty (CIMName ("SystemCreationClassName"), System::getSystemCreationClassName ())); filterInstance.addProperty (CIMProperty (CIMName ("SystemName"), System::getFullyQualifiedHostName ())); filterInstance.addProperty (CIMProperty (CIMName ("CreationClassName"), PEGASUS_CLASSNAME_INDFILTER.getString ())); filterInstance.addProperty (CIMProperty (CIMName ("Name"), name)); filterInstance.addProperty (CIMProperty (CIMName ("Query"), query)); filterInstance.addProperty (CIMProperty (CIMName ("QueryLanguage"), String (qlang))); filterInstance.addProperty (CIMProperty (CIMName ("SourceNamespace"), SOURCE_NAMESPACE.getString ())); return client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, filterInstance); }
// // Test identical() function with keys that are references // void test04() { // // Create classes A and B referenced classes, C - Association // CIMClass classA (CIMName ("A"), CIMName ()); CIMProperty propertyX ("x", String ()); propertyX.addQualifier (CIMQualifier (CIMName ("Key"), true)); CIMProperty propertyY ("y", String ()); propertyY.addQualifier (CIMQualifier (CIMName ("Key"), true)); CIMProperty propertyZ ("z", String ()); propertyZ.addQualifier (CIMQualifier (CIMName ("Key"), true)); classA.addProperty (propertyX); classA.addProperty (propertyY); classA.addProperty (propertyZ); CIMClass classB ("B"); CIMProperty propertyQ ("q", String ()); propertyQ.addQualifier (CIMQualifier (CIMName ("Key"), true)); CIMProperty propertyR ("r", String ()); propertyR.addQualifier (CIMQualifier (CIMName ("Key"), true)); CIMProperty propertyS ("s", String ()); propertyS.addQualifier (CIMQualifier (CIMName ("Key"), true)); classB.addProperty (propertyQ); classB.addProperty (propertyR); classB.addProperty (propertyS); CIMClass classC ("C"); CIMProperty propertyA ("a", CIMValue ()); propertyA.addQualifier (CIMQualifier (CIMName ("Key"), true)); CIMProperty propertyB ("b", CIMValue ()); propertyB.addQualifier (CIMQualifier (CIMName ("Key"), true)); classC.addProperty (propertyA); classC.addProperty (propertyB); // // Create instances of each classa // CIMInstance instanceA (CIMName ("A")); instanceA.addProperty (CIMProperty (CIMName ("x"), String ("rose"))); instanceA.addProperty (CIMProperty (CIMName ("y"), String ("lavender"))); instanceA.addProperty (CIMProperty (CIMName ("z"), String ("rosemary"))); CIMObjectPath aPath = instanceA.buildPath (classA); CIMObjectPath aPath2 ("A.y=\"lavender\",x=\"rose\",z=\"rosemary\""); PEGASUS_TEST_ASSERT (aPath.identical (aPath2)); CIMInstance instanceB (CIMName ("B")); instanceB.addProperty (CIMProperty (CIMName ("q"), String ("pelargonium"))); instanceB.addProperty (CIMProperty (CIMName ("r"), String ("thyme"))); instanceB.addProperty (CIMProperty (CIMName ("s"), String ("sage"))); // Test to assure that the buildpath function works. CIMObjectPath bPath = instanceB.buildPath (classB); CIMObjectPath bPath2 ("B.s=\"sage\",q=\"pelargonium\",r=\"thyme\""); PEGASUS_TEST_ASSERT (bPath.identical (bPath2)); // Build instance of C and build path from buildPath function. CIMInstance instanceC (CIMName ("C")); instanceC.addProperty (CIMProperty (CIMName ("a"), aPath, 0, CIMName ("A"))); instanceC.addProperty (CIMProperty (CIMName ("b"), bPath, 0, CIMName ("B"))); CIMObjectPath cPath = instanceC.buildPath (classC); // Build CIMObjectPath from keybindings. Array <CIMKeyBinding> keyBindings; CIMKeyBinding aBinding ("a", "A.y=\"lavender\",x=\"rose\",z=\"rosemary\"", CIMKeyBinding::REFERENCE); CIMKeyBinding bBinding ("b", "B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"", CIMKeyBinding::REFERENCE); keyBindings.append (aBinding); keyBindings.append (bBinding); CIMObjectPath cPath2 ("", CIMNamespaceName (), cPath.getClassName (), keyBindings); // Assert that the CIMObjectPaths for C from build path and direct // from keybindings are equal. PEGASUS_TEST_ASSERT (cPath.identical (cPath2)); // ATTN: KS 25 Feb 2003 P3 - Think we can extend these tests // since this is creation of classes and // instnaces for associations and referenced classes. }
void _generateIndication ( IndicationResponseHandler * handler, const String & identifier) { if (_enabled) { CIMInstance indicationInstance (CIMName ("FailureTestIndication")); CIMObjectPath path; path.setNameSpace ("test/testProvider"); path.setClassName ("FailureTestIndication"); indicationInstance.setPath (path); indicationInstance.addProperty (CIMProperty ("IndicationIdentifier", identifier)); CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("IndicationTime", currentDateTime)); Array <String> correlatedIndications; indicationInstance.addProperty (CIMProperty ("CorrelatedIndications", correlatedIndications)); indicationInstance.addProperty (CIMProperty ("Description", String ("Failure Test Indication"))); indicationInstance.addProperty (CIMProperty ("AlertingManagedElement", System::getFullyQualifiedHostName ())); indicationInstance.addProperty (CIMProperty ("AlertingElementFormat", Uint16 (0))); indicationInstance.addProperty (CIMProperty ("AlertType", Uint16 (1))); indicationInstance.addProperty (CIMProperty ("OtherAlertType", String ("Test"))); indicationInstance.addProperty (CIMProperty ("PerceivedSeverity", Uint16 (2))); indicationInstance.addProperty (CIMProperty ("ProbableCause", Uint16 (1))); indicationInstance.addProperty (CIMProperty ("ProbableCauseDescription", String ("Test"))); indicationInstance.addProperty (CIMProperty ("Trending", Uint16 (4))); Array <String> recommendedActions; recommendedActions.append ("Test"); indicationInstance.addProperty (CIMProperty ("RecommendedActions", recommendedActions)); indicationInstance.addProperty (CIMProperty ("EventID", String ("Test"))); CIMDateTime eventTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("EventTime", eventTime)); indicationInstance.addProperty (CIMProperty ("SystemCreationClassName", System::getSystemCreationClassName ())); indicationInstance.addProperty (CIMProperty ("SystemName", System::getFullyQualifiedHostName ())); indicationInstance.addProperty (CIMProperty ("ProviderName", _providerName)); CIMIndication cimIndication (indicationInstance); handler->deliver (cimIndication); } }
void _generateIndication ( IndicationResponseHandler * handler, const CIMName methodName) { if (_enabled) { CIMInstance indicationInstance; if (methodName.equal ("SendTestIndicationSubclass")) { CIMInstance theIndication (CIMName ("RT_TestIndicationSubclass")); indicationInstance = theIndication; } else { CIMInstance theIndication (CIMName ("RT_TestIndication")); indicationInstance = theIndication; } CIMObjectPath path; if (methodName.equal ("SendTestIndicationUnmatchingNamespace")) { // // For SendTestIndicationUnmatchingNamespace, generate an // indication instance with namespace that does not match the // subscription instance name included in the operation context // (nor does it match the namespace for which provider has // registered) // path.setNameSpace ("root/cimv2"); path.setClassName ("RT_TestIndication"); } else if (methodName.equal ("SendTestIndicationUnmatchingClassName")) { // the indication class name and object path class must match indicationInstance = CIMInstance("CIM_AlertIndication"); // // For SendTestIndicationUnmatchingClassName, generate an // indication instance with classname that does not match the // subscription instance name included in the operation context // (nor does it match the classname for which provider has // registered) // path.setNameSpace ("root/SampleProvider"); path.setClassName ("CIM_AlertIndication"); } else if (methodName.equal ("SendTestIndicationSubclass")) { // // For SendTestIndicationSubclass, generate an indication instance // of a the RT_TestIndicationSubclass subclass // path.setNameSpace ("root/SampleProvider"); path.setClassName ("RT_TestIndicationSubclass"); } else { path.setNameSpace("root/SampleProvider"); path.setClassName("RT_TestIndication"); } indicationInstance.setPath(path); char buffer[32]; sprintf(buffer, "%d", _nextUID++); indicationInstance.addProperty (CIMProperty ("IndicationIdentifier",String(buffer))); CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("IndicationTime", currentDateTime)); // // For SendTestIndicationMissingProperty, leave out the // CorrelatedIndications property // if (!methodName.equal ("SendTestIndicationMissingProperty")) { Array <String> correlatedIndications; indicationInstance.addProperty (CIMProperty ("CorrelatedIndications", correlatedIndications)); } if ((methodName.equal ("SendTestIndicationNormal")) || (methodName.equal ("SendTestIndicationSubclass")) || (methodName.equal ("SendTestIndicationMissingProperty")) || (methodName.equal ("SendTestIndicationExtraProperty")) || (methodName.equal ("SendTestIndicationMatchingInstance")) || (methodName.equal ("SendTestIndicationUnmatchingNamespace")) || (methodName.equal ("SendTestIndicationUnmatchingClassName"))) { indicationInstance.addProperty (CIMProperty ("MethodName", CIMValue (methodName.getString()))); } else { indicationInstance.addProperty (CIMProperty ("MethodName", CIMValue (String ("generateIndication")))); } // // For SendTestIndicationExtraProperty, add an extra property, // ExtraProperty, that is not a member of the indication class // if (methodName.equal ("SendTestIndicationExtraProperty")) { indicationInstance.addProperty (CIMProperty ("ExtraProperty", CIMValue (String ("extraProperty")))); } CIMIndication cimIndication (indicationInstance); // // For SendTestIndicationSubclass, // SendTestIndicationMatchingInstance, // SendTestIndicationUnmatchingNamespace or // SendTestIndicationUnmatchingClassName, include // SubscriptionInstanceNamesContainer in operation context // if ((methodName.equal ("SendTestIndicationSubclass")) || (methodName.equal ("SendTestIndicationMatchingInstance")) || (methodName.equal ("SendTestIndicationUnmatchingNamespace")) || (methodName.equal ("SendTestIndicationUnmatchingClassName"))) { Array <CIMObjectPath> subscriptionInstanceNames; Array <CIMKeyBinding> subscriptionKeyBindings; String filterString; filterString.append ("CIM_IndicationFilter.CreationClassName=\"CIM_IndicationFilter\",Name=\"PIFilter01\",SystemCreationClassName=\""); filterString.append (System::getSystemCreationClassName ()); filterString.append ("\",SystemName=\""); filterString.append (System::getFullyQualifiedHostName ()); filterString.append ("\""); subscriptionKeyBindings.append (CIMKeyBinding ("Filter", filterString, CIMKeyBinding::REFERENCE)); String handlerString; handlerString.append ("CIM_IndicationHandlerCIMXML.CreationClassName=\"CIM_IndicationHandlerCIMXML\",Name=\"PIHandler01\",SystemCreationClassName=\""); handlerString.append (System::getSystemCreationClassName ()); handlerString.append ("\",SystemName=\""); handlerString.append (System::getFullyQualifiedHostName ()); handlerString.append ("\""); subscriptionKeyBindings.append (CIMKeyBinding ("Handler", handlerString, CIMKeyBinding::REFERENCE)); CIMObjectPath subscriptionPath ("", CIMNamespaceName ("root/PG_InterOp"), CIMName ("CIM_IndicationSubscription"), subscriptionKeyBindings); subscriptionInstanceNames.append (subscriptionPath); OperationContext context; context.insert (SubscriptionInstanceNamesContainer (subscriptionInstanceNames)); handler->deliver (context, indicationInstance); } else { // deliver an indication without trapOid handler->deliver (indicationInstance); } // // Only deliver extra indication with trapOid for SendTestIndication // if ((!methodName.equal ("SendTestIndicationNormal")) && (!methodName.equal ("SendTestIndicationSubclass")) && (!methodName.equal ("SendTestIndicationMissingProperty")) && (!methodName.equal ("SendTestIndicationExtraProperty")) && (!methodName.equal ("SendTestIndicationMatchingInstance")) && (!methodName.equal ("SendTestIndicationUnmatchingNamespace")) && (!methodName.equal ("SendTestIndicationUnmatchingClassName"))) { // deliver another indication with a trapOid which contains in the // operationContext container OperationContext context; // add trap OID to the context context.insert (SnmpTrapOidContainer("1.3.6.1.4.1.900.2.3.9002.9600")); handler->deliver (context, indicationInstance); } } }
static void TestExceptionHandling(CIMHandler* handler) { CIMInstance indicationHandlerInstance; // Test "invalid IndicationHandlerSNMPMapper instance" exception CIMInstance indicationInstance(testClass1); indicationHandlerInstance = CreateHandlerInstance(); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "no required property TargetHostFormat" exception indicationInstance = CIMInstance(testClass1); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "no required property SNMPVersion" exception indicationInstance = CIMInstance(testClass1); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "unsupported snmp Version" exception indicationInstance = CIMInstance(testClass1); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(5))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "invalid MappingStrings Syntax" exception indicationInstance = CIMInstance(testClass8); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "invalid MappingStrings value" exception indicationInstance = CIMInstance(testClass2); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "no MappingStrings qualifier" exception indicationInstance = CIMInstance(testClass3); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "send trap failed" exception indicationInstance = CIMInstance(testClass4); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPSecurityName"), String("t"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat"))); TestException(handler, indicationHandlerInstance, indicationInstance, CIM_ERR_FAILED); // Test "failed to add snmp variables to PDU", // Both a DiscardedData message and an error message // are logged to log file indicationInstance = CIMInstance(testClass5); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPSecurityName"), String("t"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat"))); TestError(handler, indicationHandlerInstance, indicationInstance); // Test "convert enterprise OID from numeric form to a list of" // "subidentifiers failed". // Both a DiscardedData message and an error message // are logged to log file indicationInstance = CIMInstance(testClass5); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPSecurityName"), String("t"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat"))); TestError(handler, indicationHandlerInstance, indicationInstance); // Test "convert property OID from numeric form to a list of" // "subidentifiers failed". // Both a DiscardedData message and an error message // are logged to log file indicationInstance = CIMInstance(testClass6); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("OctetString"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat"))); TestError(handler, indicationHandlerInstance, indicationInstance); // Test "unsupported SNMP data type for the CIM property" // Both a DiscardedData message and an error message // are logged to log file indicationInstance = CIMInstance(testClass7); indicationInstance.addProperty(CIMProperty( CIMName ("OidDataType"), String("test"))); indicationHandlerInstance = CreateHandlerInstance(); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHost"), String("15.13.140.120"))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("TargetHostFormat"), Uint16(3))); indicationHandlerInstance.addProperty(CIMProperty( CIMName("SNMPVersion"), Uint16(2))); TestError(handler, indicationHandlerInstance, indicationInstance); }
void UNIX_PROVIDER::addManagedSystemElementProperties(CIMInstance &inst, CLASS_IMPLEMENTATION _p) { CIMProperty p; #include <CIM_ManagedElementProvider.cpp> //ManagedSystemElement if (_p.getInstallDate(p)) inst.addProperty(p); if (_p.getName(p)) inst.addProperty(p); if (_p.getStatus(p)) inst.addProperty(p); if (_p.getCommunicationStatus(p)) inst.addProperty(p); if (_p.getDetailedStatus(p)) inst.addProperty(p); if (_p.getHealthStatus(p)) inst.addProperty(p); if (_p.getOperatingStatus(p)) inst.addProperty(p); if (_p.getPrimaryStatus(p)) inst.addProperty(p); if (_p.getOperationalStatus(p)) inst.addProperty(p); if (_p.getStatusDescriptions(p)) inst.addProperty(p); //ALL TOP CLASS /* Let's add it here */ if (_p.getCreationClassName(p)) inst.addProperty(p); if (_p.getSystemCreationClassName(p)) inst.addProperty(p); inst.addProperty(CIMProperty(PROPERTY_SYSTEM_NAME, _hostName)); }
void MCCA_TestAssocProvider::associators( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & associationClass, const CIMName & resultClass, const String & role, const String & resultRole, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, ObjectResponseHandler & handler) { CDEBUG("MCCA_TestAssocProvider::associators() called."); // create a new CIMInstance based on class with name className CIMInstance constructedInstance = CIMInstance(testClassName); CIMObjectPath targetObjectPath = CIMObjectPath(); Array<CIMKeyBinding> keyBindings = Array<CIMKeyBinding>(); Uint32 sourceKey = 0; CDEBUG("Initialisation ended."); handler.processing(); CDEBUG("handler.processing started."); // we do ignore role, resultRole, includeQualifiers, includeClassOrigin, // propertyList CDEBUG("Next building object path."); ///////////////////////////////////////////////////////////////////// // BUILD OBJECTPATH ///////////////////////////////////////////////////////////////////// // preparing object path first targetObjectPath.setHost("localhost:5988"); targetObjectPath.setClassName(testClassName); CDEBUG("Host and classname set, host=" << objectName.getHost()); // determine if source namespace is namespace A or B // and build respective target namespace ... if (objectName.getNameSpace().equal(nameSpaceA)) { targetObjectPath.setNameSpace(nameSpaceB); } if (objectName.getNameSpace().equal(nameSpaceB)) { targetObjectPath.setNameSpace(nameSpaceA); } CDEBUG("NameSpace set."); // determine key of source object so we can create target object Array<CIMKeyBinding> sourceKeyBindings = objectName.getKeyBindings(); CDEBUG("Determining sourceKey."); // only one keyvalue, so we take that first one String keyValueString = String(sourceKeyBindings[0].getValue()); CDEBUG("keyValueString=" << keyValueString); sourceKey = strtoul((const char*) keyValueString.getCString(), NULL, 0); CDEBUG("sourceKey=" << sourceKey); CIMKeyBinding testClassKey = CIMKeyBinding(CIMName("theKey"), CIMValue(sourceKey) ); CDEBUG("Created new KeyBinding testClassKey."); // testClassKey.setValue(keyValueString); CDEBUG("sourceKey = string(set keybinding),int(sourceKey)" << testClassKey.getValue() << "," << sourceKey); keyBindings.append(testClassKey); CDEBUG("Appended(testClassKey)."); targetObjectPath.setKeyBindings(keyBindings); ///////////////////////////////////////////////////////////////////// // ADD PROPERTIES ///////////////////////////////////////////////////////////////////// // add properties to the CIMInstance object constructedInstance.addProperty( CIMProperty( CIMName("theKey"), sourceKey)); constructedInstance.addProperty( CIMProperty( CIMName("theData"), 20+sourceKey)); char buffer[100]; sprintf(buffer,"ABC-%u",20*sourceKey+sourceKey); constructedInstance.addProperty(CIMProperty(CIMName ("theString"), String(buffer))); CDEBUG("Added properties to the CIMInstance object"); CIMObject cimObject(constructedInstance); cimObject.setPath (targetObjectPath); // lets deliver all instances of CIMObjectpaths I do think are okay handler.deliver(cimObject); // complete processing the request handler.complete(); CDEBUG("Association call conmplete."); }
void LifecycleIndicationProvider::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceReference, ResponseHandler & handler) { // cout << "LifecycleIndicationProvider::deleteInstance()" << endl; CIMInstance localInstance; // convert a potential fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), CIMNamespaceName(), instanceReference.getClassName(), instanceReference.getKeyBindings()); // begin processing the request handler.processing(); // instance index corresponds to reference index for(Uint32 i = 0, n = _instances.size(); i < n; i++) { if(localReference == _instances[i].getPath()) { localInstance = _instances[i]; // remove instance from the array _instances.remove(i); break; } } // complete processing the request handler.complete(); // If there is at least one subscription active for the lifecycle indication // InstDeletion_for_Sample_LifecycleIndicationProviderClass, then generate // that indication here, embedding the just-deleted instance as the // SourceInstance property. See LifecycleIndicationProviderR.mof. if (_lifecycle_indications_enabled) { CIMInstance indicationInstance( CIMName( "InstDeletion_for_Sample_LifecycleIndicationProviderClass")); CIMObjectPath path; path.setNameSpace("root/SampleProvider"); path.setClassName( "InstDeletion_for_Sample_LifecycleIndicationProviderClass"); indicationInstance.setPath(path); char buffer[32]; sprintf(buffer, "%d", _nextUID++); indicationInstance.addProperty (CIMProperty ("IndicationIdentifier",String(buffer))); CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("IndicationTime", currentDateTime)); // Before we send the Lifecycle Indication for the delete of this // instance, change the "lastOp" property value to "deleteInstance". Uint32 ix = localInstance.findProperty(CIMName("lastOp")); if (ix != PEG_NOT_FOUND) { localInstance.removeProperty(ix); localInstance.addProperty( CIMProperty( CIMName("lastOp"), String("deleteInstance"))); } indicationInstance.addProperty (CIMProperty ("SourceInstance",CIMObject(localInstance))); _indication_handler->deliver (indicationInstance); // cout << "LifecycleIndicationProvider::deleteInstance() sent " // "InstDeletion_for_Sample_LifecycleIndicationProviderClass" // << endl; } }