CMPIStatus Linux_FanAssociatedSensorProviderAssociators( CMPIAssociationMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * cop, const char * assocClass, const char * resultClass, const char * role, const char * resultRole, const char ** propertyList) { UNUSED(mi); UNUSED(propertyList); CMPIStatus rc = {CMPI_RC_OK, NULL}; CMPIObjectPath * op = NULL; int refrc = 0; _OSBASE_TRACE(1,("--- %s CMPI Associators() called",_ClassName)); if( assocClass ) { op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(cop,&rc)), _ClassName, &rc ); if( op==NULL ) { CMSetStatusWithChars( _broker, &rc, CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); _OSBASE_TRACE(2, ("--- %s CMPI Associators() failed : %s",CMGetCharPtr(rc.msg))); return rc; } } if ( (assocClass == NULL) || (CMClassPathIsA(_broker,op,assocClass,&rc) == 1)) { if( _assoc_check_parameter_const( _broker,cop,_RefLeft,_RefRight, _RefLeftClass,_RefRightClass, resultClass,role,resultRole, &rc ) == 0 ) { goto exit; } refrc = _assoc_create_refs_1toN(_broker, ctx, rslt, cop, _ClassName,_RefLeftClass,_RefRightClass, _RefLeft,_RefRight, 1, 1, &rc); if( refrc != 0 ) { if( rc.msg != NULL ) { _OSBASE_TRACE(1, ("--- %s CMPI Associators() failed : %s", _ClassName,CMGetCharPtr(rc.msg))); } else { _OSBASE_TRACE(1,("--- %s CMPI Associators() failed",_ClassName)); } return rc; } } exit: CMReturnDone( rslt ); _OSBASE_TRACE(1,("--- %s CMPI Associators() exited",_ClassName)); CMReturn(CMPI_RC_OK); }
// To increase the coverage in CMPIBrokerEnc.cpp static int _testBrokerEnc (const CMPIContext * ctx, const CMPIResult * rslt) { int flag = 1 ; int count; char* msgId; char* illegal; char path[100]; void* hdl; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIString *type; CMPIString *cmpiStr; CMPIBoolean bol=0; CMPIBoolean bool=0; CMPIArray* cmpiArray = NULL ; CMPIInstance* instance = NULL; CMPIInstance* instance1 = NULL; CMPIInstance* instanceErr = NULL; CMPIObjectPath* objPath = NULL; CMPIObjectPath* objPath1 = NULL; CMPICount cmpiCnt = 5; CMPIType cmpiType = CMPI_uint64; CMPIDateTime* cmpiDateTime = NULL ; CMPIMsgFileHandle msgFileHandle; CMPIEnumeration* cmpiEnum; CMPISelectExp* selExp; CMPIValue val; CMPIError* err; CMPIStatus* rc1 = NULL; CMPIArgs* args = NULL; void* handle; CMPIInstanceFT* funcTable; PROV_LOG ("++++ _testBrokerEnc "); PROV_LOG ("++++ ObjectPath testing"); objPath1 = CMNewObjectPath (_broker, NULL, _ClassName, &rc); PROV_LOG ("++++ New object path with NULL namespace creation : (%s)", strCMPIStatus (rc)); CMRelease(objPath1); objPath1 = CMNewObjectPath (_broker, _Namespace, "abc", &rc); PROV_LOG ("++++ New object path with wrong classname : (%s)", strCMPIStatus (rc)); instance = CMNewInstance(_broker, NULL, &rc); PROV_LOG ("++++ New Instance with NULL object path : (%s)", strCMPIStatus (rc)); handle = objPath1->hdl; objPath1->hdl=NULL; instance = CMNewInstance(_broker, objPath1, &rc); PROV_LOG ("++++ New Instance with object path handle set to NULL: (%s)", strCMPIStatus (rc)); objPath1->hdl = handle; objPath = make_ObjectPath(_broker, _Namespace, _ClassName); instance = CMNewInstance(_broker, objPath, &rc); PROV_LOG ("++++ New Instance creation status: (%s)", strCMPIStatus (rc)); instance1 = CMClone(instance, &rc); instanceErr = CMClone(instance, &rc); cmpiStr = CMNewString(_broker, NULL, &rc); PROV_LOG ("++++ Status of mbNewString with NULL parameter:(%s)", strCMPIStatus (rc)); err = CMNewCMPIError(_broker, "abc", "abc", "abc", 4, 5, 6, rc1); if (err) { PROV_LOG ("++++ CMNewCMPIError called with null rc"); } cmpiDateTime = CMNewDateTimeFromChars(_broker, "datetime", &rc); PROV_LOG ("++++ Status of CMNewDateTimeFromChars with junk parameter:(%s)", strCMPIStatus (rc)); if (!CMClassPathIsA(_broker, NULL, NULL, &rc)) { PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)", strCMPIStatus (rc)); } if (!CMClassPathIsA(_broker, objPath, NULL, &rc)) { PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)", strCMPIStatus (rc)); } illegal = "$"; if (!CMClassPathIsA(_broker, objPath, illegal, &rc)) { PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)", strCMPIStatus (rc)); } rc = CMLogMessage(_broker, 2, "TestProvider", "Testing Severity 2 in TestCMPIBrokerEnc", NULL); PROV_LOG ("++++ Status of CMLogMessage with Severity 2:(%s)", strCMPIStatus (rc)); rc = CMLogMessage(_broker, 3, "TestProvider", "Testing Severity 3 in TestCMPIBrokerEnc", NULL); PROV_LOG ("++++ Status of CMLogMessage with Severity 3:(%s)", strCMPIStatus (rc)); rc = CMLogMessage(_broker, 4, "TestProvider", "Testing Severity 4 in TestCMPIBrokerEnc", NULL); PROV_LOG ("++++ Status of CMLogMessage with Severity 4:(%s)", strCMPIStatus (rc)); rc = CMTraceMessage(_broker, 2, "CMPIProvider", "Tracing for level 2", NULL); PROV_LOG ("++++ Status of CMTraceMessage with level 2:(%s)", strCMPIStatus (rc)); rc = CMTraceMessage(_broker, 3, "CMPIProvider", "Tracing for level 3", NULL); PROV_LOG ("++++ Status of CMTraceMessage with level 3:(%s)", strCMPIStatus (rc)); rc = CMTraceMessage(_broker, 4, "CMPIProvider", "Tracing for level 4", NULL); PROV_LOG ("++++ Status of CMTraceMessage with level 4:(%s)", strCMPIStatus (rc)); cmpiStr = CMNewString(_broker, "Tracing for level 5", &rc); rc = CMTraceMessage(_broker, 5, "CMPIProvider", NULL, cmpiStr); PROV_LOG ("++++ Status of CMTraceMessage with level 5:(%s)", strCMPIStatus (rc)); CMRelease(cmpiStr); PROV_LOG ("++++ Calling mbEncToString function "); type = CDToString (_broker, _broker, &rc); PROV_LOG ("++++ Error status of mbEncToString with wrong object path:" " (%s)", strCMPIStatus (rc)); type = CDToString (_broker, NULL, &rc); PROV_LOG ("++++ Error status of mbEncToString with NULL parameter:" " (%s)", strCMPIStatus (rc)); type = CDToString (_broker, type, &rc); PROV_LOG ("++++ Passing CMPIString to mbEncToString successes : (%s)", strCMPIStatus (rc)); type = CDToString (_broker, objPath, &rc); PROV_LOG ("++++ Passing CMPIObjectPath to mbEncToString successes : (%s)", strCMPIStatus (rc)); handle = objPath1->hdl; objPath1->hdl = NULL; type = CDToString (_broker, objPath1, &rc); if ( rc.rc == CMPI_RC_ERR_INVALID_PARAMETER) { PROV_LOG ("++++ Error status of mbEncToString with object path with " "NULL handle: (%s)", strCMPIStatus (rc)); } objPath1->hdl = handle; val.boolean = 1; rc = CMSetProperty (instance, "Boolean", &val, CMPI_boolean); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_boolean : (%s)", strCMPIStatus (rc)); val.uint8 = 8; rc = CMSetProperty (instance, "Uint8", &val, CMPI_uint8); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint8 : (%s)", strCMPIStatus (rc)); val.uint16 = 16; rc = CMSetProperty (instance, "Uint16", &val, CMPI_uint16); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint16 : (%s)", strCMPIStatus (rc)); val.uint32 = 32; rc = CMSetProperty (instance, "Uint32", &val, CMPI_uint32); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint32 : (%s)", strCMPIStatus (rc)); val.uint64 = 64; rc = CMSetProperty (instance, "Uint64", &val, CMPI_uint64); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint64 : (%s)", strCMPIStatus (rc)); val.sint8 = -8; rc = CMSetProperty (instance, "Sint8", &val, CMPI_sint8); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint8 : (%s)", strCMPIStatus (rc)); val.sint16 = -16; rc = CMSetProperty (instance, "Sint16", &val, CMPI_sint16); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint16 : (%s)", strCMPIStatus (rc)); val.sint32 = -32; rc = CMSetProperty (instance, "Sint32", &val, CMPI_sint32); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint32 : (%s)", strCMPIStatus (rc)); val.sint64 = -64; rc = CMSetProperty (instance, "Sint64", &val, CMPI_sint64); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint64 : (%s)", strCMPIStatus (rc)); val.real32 = 32.32; rc = CMSetProperty (instance, "Real32", &val, CMPI_real32); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_real32 : (%s)", strCMPIStatus (rc)); val.real64 = 64.64; rc = CMSetProperty (instance, "Real64", &val, CMPI_real64); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_real64 : (%s)", strCMPIStatus (rc)); val.char16 = 'c'; rc = CMSetProperty (instance, "Char16", &val, CMPI_char16); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_char16 : (%s)", strCMPIStatus (rc)); cmpiDateTime = CMNewDateTime (_broker, &rc); val.dateTime = cmpiDateTime; rc = CMSetProperty (instance, "DateTime", &val, CMPI_dateTime); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_dateTime : (%s)", strCMPIStatus (rc)); val.ref = objPath; rc = CMSetProperty (instance, "Ref", &val, CMPI_ref); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_ref : (%s)", strCMPIStatus (rc)); val.inst = instance1; rc = CMSetProperty (instance, "Instance", &val, CMPI_instance); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_instance : (%s)", strCMPIStatus (rc)); type = CDToString (_broker, instance, &rc); PROV_LOG ("++++ Passing CMPIInstance to mbEncToString successes : (%s)", strCMPIStatus (rc)); args = CMNewArgs(_broker, &rc); PROV_LOG ("++++ Status of CMNewArgs : (%s)", strCMPIStatus (rc)); type = CDToString (_broker, args, &rc); PROV_LOG ("++++ Passing CMPIArgs to mbEncToString successes : (%s)", strCMPIStatus (rc)); PROV_LOG ("++++ Calling mbEncGetType function "); rc1 = NULL; type = CDGetType (_broker, NULL, rc1); if (!type) { PROV_LOG ("++++ Error calling mbEncGetType with NULL rc"); } rc1 = NULL; funcTable = instanceErr->ft; instanceErr->ft = NULL; type = CDGetType (_broker, instanceErr, rc1); if (!type) { PROV_LOG ("++++ Error calling mbEncGetType with wrong parameter and" " NULL rc"); } type = CDGetType (_broker, instanceErr, &rc); PROV_LOG ("++++ Error status of mbEncGetType with wrong input : (%s)", strCMPIStatus (rc)); instanceErr->ft = funcTable; type = CDGetType (_broker, NULL, &rc); PROV_LOG ("++++ Error status of mbEncGetType with NULL input : (%s)", strCMPIStatus (rc)); type = CDGetType (_broker, instance, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIInstance" " : (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, objPath, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIObjectPath:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); cmpiStr = CMNewString(_broker, "Test1", & rc); type = CDGetType (_broker, cmpiStr, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIString:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, _broker, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIBroker:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); cmpiArray = CMNewArray(_broker, cmpiCnt,cmpiType, &rc); type = CDGetType (_broker, cmpiArray, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIArray:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, cmpiDateTime, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIDateTime:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, ctx, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIContext:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, rslt, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIResult:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); rc1 = NULL; selExp = CMNewSelectExp(_broker, "SELECT c,b FROM TestCMPI_Indication WHERE c='c' OR b=1", "WQL", NULL, rc1); PROV_LOG ("++++ CMNewSelectExp with rc set to NULL Called"); selExp = CMNewSelectExp(_broker, "SELECT c,b FROM TestCMPI_Indication", "WQL", NULL, &rc); PROV_LOG ("++++ Status of CMNewSelectExp: (%s) ", strCMPIStatus (rc)); type = CDGetType (_broker, selExp, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPISelectExp:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); handle = objPath1->hdl; objPath1->hdl = NULL; rc = CMRelease(objPath1); PROV_LOG ("++++ Status of CMRelease(objPath1): (%s)", strCMPIStatus (rc)); objPath1->hdl = handle; rc = CMRelease(objPath1); PROV_LOG ("++++ Status of CMRelease(objPath1): (%s)", strCMPIStatus (rc)); objPath1 = CMNewObjectPath(_broker, "test/TestProvider", "TestCMPI_Instance", &rc); PROV_LOG ("++++ Status of CMNewObjectPath for TestCMPI_Instance : (%s)", strCMPIStatus (rc)); PROV_LOG_CLOSE(); cmpiEnum = CBEnumInstances(_broker, ctx, objPath1, NULL, &rc); PROV_LOG_OPEN (_ClassName, _ProviderLocation); PROV_LOG ("++++ Status of CBEnumInstances : (%s)", strCMPIStatus (rc)); type = CDGetType (_broker, cmpiEnum, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIEnumeration:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, args, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIArgs:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); PROV_LOG ("++++ Calling mbEncIsOfType function "); bol = CDIsOfType (_broker, NULL, "No object", rc1); if(!bol) { PROV_LOG ("++++Calling mbEncIsOfType with NULL rc and wrong" " parameters"); } bol = CDIsOfType (_broker, instance, "CMPIInstance", rc1); if(!bol) { PROV_LOG ("++++ Calling mbEncIsOfType with NULL rc"); } bol = CDIsOfType (_broker, NULL, "No object", &rc); PROV_LOG ("++++ Error Status of mbEncIsOfType : (%s)", strCMPIStatus (rc)); bol = CDIsOfType (_broker, instance, "CMPIInstance", &rc); if ( bol ) { PROV_LOG ("++++ CDIsOfType for CMPIInstance status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, instance, "CMPI", &rc); if ( !bol ) { PROV_LOG ("++++ CDIsOfType for CMPIInstance status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, objPath, "CMPIObjectPath", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIObjectPath status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, objPath, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIObjectPath status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiDateTime, "CMPIDateTime", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIDateTime status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiDateTime, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIDateTime status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiStr, "CMPIString", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIString status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiStr, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIString status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, _broker, "CMPIBroker", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIBroker status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, _broker, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIBroker status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiArray, "CMPIArray", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIArray status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiArray, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIArray status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, rslt, "CMPIResult", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIResult status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, rslt, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIResult status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, ctx, "CMPIContext", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIContext status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, ctx, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIContext status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiEnum, "CMPIEnumeration", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIEnumeration status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiEnum, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIEnumeration status is (%s) : %d", strCMPIStatus (rc), bol); } /* Testcase to increase coverage in CMPI_Enumeration.cpp*/ rc = CMRelease(cmpiEnum); PROV_LOG ("++++ Status of CMRelease on cmpiEnum :(%s)", strCMPIStatus (rc)); /**********************************************************/ bol = CDIsOfType (_broker, selExp, "CMPISelectExp", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPISelectExp status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, selExp, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPISelectExp status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, args, "CMPIArgs", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIArgs status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, args, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CdIsOfType for CMPIArgs status is (%s) : %d", strCMPIStatus (rc), bol); } type = CMGetMessage (_broker, "msgid", "Test 0 arguments", &rc, 0); PROV_LOG ("++++ Status of GetMessage with 0 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0", &rc, CMFmtArgs1(CMFmtChars("one argument"))); PROV_LOG ("++++ Status of GetMessage with 1 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1", &rc, CMFmtArgs2(CMFmtChars("Sint32 ::"), CMFmtSint(-1))); PROV_LOG ("++++ Status of GetMessage with 2 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2", &rc, CMFmtArgs3(CMFmtChars("Sint32, Uint32 ::"), CMFmtSint(-1), CMFmtUint(1))); PROV_LOG ("++++ Status of GetMessage with 3 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3", &rc, CMFmtArgs4(CMFmtChars("Sint32, Uint32, Sint64 ::"), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64))); PROV_LOG ("++++ Status of GetMessage with 4 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4", &rc, CMFmtArgs5(CMFmtChars("Sint32, Uint32, Sint64, Uint64 ::"), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64))); PROV_LOG ("++++ Status of GetMessage with 5 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4, $5", &rc, CMFmtArgs6(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64 ::"), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64))); PROV_LOG ("++++ Status of GetMessage with 6 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4, $5, $6", &rc, CMFmtArgs7(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean:: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1))); PROV_LOG ("++++ Status of GetMessage with 7 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4, $5, $6, $7", &rc, CMFmtArgs8(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean, chars:: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1), CMFmtChars("chars"))); PROV_LOG ("++++ Status of GetMessage with 8 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4, $5, $6, $7, $8", &rc, CMFmtArgs9(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean, chars, String :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1), CMFmtChars("chars"), CMFmtString(cmpiStr))); PROV_LOG ("++++ Status of GetMessage with 9 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); strcpy(path,"path"); rc = CMOpenMessageFile(_broker, path, &msgFileHandle); PROV_LOG ("++++ Status of CMOpenMessageFile (%s) ", strCMPIStatus (rc)); type = CMGetMessage2(_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test zero arguments", &rc, 0); PROV_LOG ("++++ Status of GetMessage2 with 0 argument (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2(_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0", &rc, CMFmtArgs1(CMFmtChars("Single argument"))); PROV_LOG ("++++ Status of GetMessage2 with 1 argument (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2(_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1", &rc, CMFmtArgs2(CMFmtChars("Sint32 ::"),CMFmtSint(1))); PROV_LOG ("++++ Status of GetMessage2 with 2 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2", &rc, CMFmtArgs3(CMFmtChars("Sint32, Uint32 :: "), CMFmtSint(-1), CMFmtUint(1))); PROV_LOG ("++++ Status of GetMessage2 with 3 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3", &rc, CMFmtArgs4(CMFmtChars("Sint32, Uint32, Sint64 :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64))); PROV_LOG ("++++ Status of GetMessage2 with 4 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4", &rc, CMFmtArgs5(CMFmtChars("Sint32, Uint32, Sint64, Uint64 :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64))); PROV_LOG ("++++ Status of GetMessage2 with 5 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4, $5", &rc, CMFmtArgs6(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64 :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64))); PROV_LOG ("++++ Status of GetMessage2 with 6 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4, $5, $6", &rc, CMFmtArgs7(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1))); PROV_LOG ("++++ Status of GetMessage2 with 7 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4, $5, $6, $7", &rc, CMFmtArgs8(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean, chars :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1), CMFmtChars("chars"))); PROV_LOG ("++++ Status of GetMessage2 with 8 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4, $5, $6, $7, $8", &rc, CMFmtArgs9(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean, chars, String :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1), CMFmtChars("chars"), CMFmtString(cmpiStr))); PROV_LOG ("++++ Status of GetMessage2 with 9 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); rc = CMCloseMessageFile(_broker, msgFileHandle); PROV_LOG ("++++ Status of CMCloseMessageFile (%s) ", strCMPIStatus (rc)); CMRelease(instance1); CMRelease(instanceErr); return flag ; }
CMPIStatus IndCIMXMLHandlerCreateInstance(CMPIInstanceMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop, const CMPIInstance *ci) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIArgs *in, *out = NULL; CMPIObjectPath *op; CMPIData rv; unsigned short persistenceType; _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerCreateInstance"); if (interOpNameSpace(cop, &st) == 0) _SFCB_RETURN(st); internalProviderGetInstance(cop, &st); if (st.rc == CMPI_RC_ERR_FAILED) _SFCB_RETURN(st); if (st.rc == CMPI_RC_OK) { setStatus(&st, CMPI_RC_ERR_ALREADY_EXISTS, NULL); _SFCB_RETURN(st); } CMPIInstance *ciLocal = CMClone(ci, NULL); memLinkInstance(ciLocal); CMPIObjectPath* copLocal = CMClone(cop, NULL); memLinkObjectPath(copLocal); setCCN(copLocal,ciLocal,"CIM_ComputerSystem"); CMPIString *sysname=ciLocal->ft->getProperty(ciLocal,"SystemName",&st).value.string; if (sysname == NULL || sysname->hdl == NULL) { char hostName[512]; hostName[0]=0; gethostname(hostName,511); /* should be the same as SystemName of IndicationService */ CMAddKey(copLocal, "SystemName", hostName, CMPI_chars); CMSetProperty(ciLocal,"SystemName",hostName,CMPI_chars); } CMPIString *dest = CMGetProperty(ciLocal, "destination", &st).value.string; if (dest == NULL || CMGetCharPtr(dest) == NULL) { setStatus(&st, CMPI_RC_ERR_FAILED, "Destination property not found; is required"); CMRelease(ciLocal); _SFCB_RETURN(st); } else { /* if no scheme is given, assume http (as * req. for param by mof) */ char *ds = CMGetCharPtr(dest); if (strstr(ds, "://") == NULL) { char *prefix = "http://"; int n = strlen(ds) + strlen(prefix) + 1; char *newdest = (char *) malloc(n * sizeof(char)); strcpy(newdest, prefix); strcat(newdest, ds); CMSetProperty(ciLocal, "destination", newdest, CMPI_chars); free(newdest); } } CMPIData persistence = CMGetProperty(ciLocal, "persistencetype", &st); if (persistence.state == CMPI_nullValue || persistence.state == CMPI_notFound) { persistenceType = 2; /* default is 2 = permanent */ } else if (persistence.value.uint16 < 1 || persistence.value.uint16 > 3) { setStatus(&st, CMPI_RC_ERR_FAILED, "PersistenceType property must be 1, 2, or 3"); CMRelease(ciLocal); _SFCB_RETURN(st); } else { persistenceType = persistence.value.uint16; } CMSetProperty(ciLocal, "persistencetype", &persistenceType, CMPI_uint16); if (CMClassPathIsA(_broker, copLocal, "cim_listenerdestination", NULL)) { //get the creation timestamp struct timeval tv; struct timezone tz; char context[100]; gettimeofday(&tv, &tz); struct tm cttm; char * gtime = (char *) malloc(15 * sizeof(char)); memset(gtime, 0, 15 * sizeof(char)); if (gmtime_r(&tv.tv_sec, &cttm) != NULL) { strftime(gtime, 15, "%Y%m%d%H%M%S", &cttm); } // Even though reliable indications may be disabled, we need to do this // in case it ever gets enabled. // Get the IndicationService name CMPIObjectPath * isop = CMNewObjectPath(_broker, "root/interop", "CIM_IndicationService", NULL); CMPIEnumeration * isenm = _broker->bft->enumerateInstances(_broker, ctx, isop, NULL, NULL); CMPIData isinst = CMGetNext(isenm, NULL); CMPIData mc = CMGetProperty(isinst.value.inst, "Name", NULL); // build the context string sprintf (context,"%s#%s#",mc.value.string->ft->getCharPtr(mc.value.string,NULL),gtime); CMPIValue scontext; scontext.string = sfcb_native_new_CMPIString(context, NULL, 0); free(gtime); // set the properties CMSetProperty(ciLocal, "SequenceContext", &scontext, CMPI_string); CMPIValue zarro = {.sint64 = -1 }; CMSetProperty(ciLocal, "LastSequenceNumber", &zarro, CMPI_sint64); } CMPIString *str = CDToString(_broker, copLocal, NULL); CMPIString *ns = CMGetNameSpace(copLocal, NULL); _SFCB_TRACE(1, ("--- handler %s %s", (char *) ns->hdl, (char *) str->hdl)); in = CMNewArgs(_broker, NULL); CMAddArg(in, "handler", &ciLocal, CMPI_instance); CMAddArg(in, "key", &copLocal, CMPI_ref); op = CMNewObjectPath(_broker, "root/interop", "cim_indicationsubscription", &st); rv = CBInvokeMethod(_broker, ctx, op, "_addHandler", in, out, &st); if (st.rc == CMPI_RC_OK) { st = InternalProviderCreateInstance(NULL, ctx, rslt, copLocal, ciLocal); } else { rv=CBInvokeMethod(_broker,ctx,op,"_removeHandler",in,out,NULL); } _SFCB_RETURN(st); } CMPIStatus IndCIMXMLHandlerModifyInstance(CMPIInstanceMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop, const CMPIInstance *ci, const char **properties) { CMPIStatus st = { CMPI_RC_ERR_NOT_SUPPORTED, NULL }; _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerSetInstance"); _SFCB_RETURN(st); }
CMPIStatus getRefs(const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop, const char *assocClass, const char *resultClass, const char *role, const char *resultRole, const char **propertyList, int associatorFunction) { UtilList *refs = UtilFactory->newList(memAddUtilList, memUnlinkEncObj); char *ns = (char *) CMGetNameSpace(cop, NULL)->hdl; CMPIStatus st = { CMPI_RC_OK, NULL }; _SFCB_ENTER(TRACE_INTERNALPROVIDER, "getRefs"); if (assocClass != NULL) { CMPIObjectPath *path; if (assocForName(ns, assocClass, role, resultRole) == NULL) { /* * for an unknown class we just return nothing */ _SFCB_RETURN(st); } path = CMNewObjectPath(_broker, ns, assocClass, NULL); SafeInternalProviderAddEnumInstances(refs, NULL, ctx, path, propertyList, &st, 1); } else { CMPIData rv; CMPIObjectPath *op = CMNewObjectPath(Broker, ns, "$ClassProvider$", &st); CMPIArgs *in = CMNewArgs(Broker, NULL); CMPIArgs *out = CMNewArgs(Broker, NULL); rv = CBInvokeMethod(Broker, ctx, op, "getassocs", in, out, &st); if (out) { int i, m; CMPIArray *ar = CMGetArg(out, "assocs", &st).value.array; for (i = 0, m = CMGetArrayCount(ar, NULL); i < m; i++) { char *name = CMGetArrayElementAt(ar, i, NULL).value.string->hdl; if (name) { CMPIObjectPath *cop = CMNewObjectPath(Broker, ns, name, NULL); if (cop) { SafeInternalProviderAddEnumInstances(refs, NULL, ctx, cop, propertyList, &st, 1); } } _SFCB_TRACE(1, ("--- assoc %s", name)); } } } if (role) { // filter out the associations not matching the role property CMPIInstance *ci; UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop); for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) { CMPIData data = CMGetProperty(ci, role, NULL); if ((data.state & CMPI_notFound) || data.type != CMPI_ref || objectPathEquals(pn, data.value.ref, NULL, 0) == 0) { refs->ft->removeCurrent(refs); } } pn->ft->release(pn); } else { // filter out associations not referencing pathName CMPIInstance *ci; int matched, i, m; UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop); for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) { for (matched = 0, i = 0, m = CMGetPropertyCount(ci, NULL); i < m; i++) { CMPIData data = CMGetPropertyAt(ci, i, NULL, NULL); if (data.type == CMPI_ref && objectPathEquals(pn, data.value.ref, NULL, 0)) { matched = 1; break; } } if (matched == 0) refs->ft->removeCurrent(refs); } pn->ft->release(pn); } if (associatorFunction == REF) { CMPIInstance *ci; for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) { CMReturnInstance(rslt, ci); } refs->ft->release(refs); _SFCB_RETURN(st); } else if (associatorFunction == REF_NAME) { CMPIInstance *ci; for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) { CMPIObjectPath *ref = CMGetObjectPath(ci, NULL); CMReturnObjectPath(rslt, ref); } refs->ft->release(refs); _SFCB_RETURN(st); } else { // Use hashtable to avoid dup'd associators CMPIInstance *ci; UtilHashTable *assocs = UtilFactory->newHashTable(61, UtilHashTable_charKey); UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop); for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) { // Q: for ASSOC_NAME we should not require the // object exist if we go by the book, should we? // The current approach retrieves the instances // via the CIMOM handle if (resultRole) { CMPIData data = CMGetProperty(ci, resultRole, NULL); UtilStringBuffer *an = NULL; if ((data.state & CMPI_notFound) == 0 && data.type == CMPI_ref && objectPathEquals(pn, data.value.ref, &an, 0) == 0) { if (resultClass == NULL || CMClassPathIsA(Broker, data.value.ref, resultClass, NULL)) { CMPIInstance *aci = CBGetInstance(Broker, ctx, data.value.ref, propertyList, &st); assocs->ft->put(assocs, an->ft->getCharPtr(an), aci); } } } else { // must loop over the properties to find ref instances int i, m; for (i = 0, m = CMGetPropertyCount(ci, NULL); i < m; i++) { CMPIData data = CMGetPropertyAt(ci, i, NULL, NULL); if (data.type == CMPI_ref) { CMPIObjectPath *ref = data.value.ref; CMPIString *tns = CMGetNameSpace(ref, NULL); if (tns == NULL || tns->hdl == NULL) CMSetNameSpace(ref, ns); UtilStringBuffer *an = NULL; if (objectPathEquals(pn, ref, &an, 0) == 0) { if (resultClass == NULL || CMClassPathIsA(Broker, ref, resultClass, NULL)) { CMPIInstance *aci = CBGetInstance(Broker, ctx, ref, propertyList, &st); if (aci) assocs->ft->put(assocs, an->ft->getCharPtr(an), aci); } } } } } } { HashTableIterator *it; char *an; CMPIInstance *aci; for (it = assocs->ft->getFirst(assocs, (void **) &an, (void **) &aci); it; it = assocs->ft->getNext(assocs, it, (void **) &an, (void **) &aci)) { if (associatorFunction == ASSOC) CMReturnInstance(rslt, aci); else { CMPIObjectPath *op = CMGetObjectPath(aci, NULL); CMReturnObjectPath(rslt, op); } } } refs->ft->release(refs); assocs->ft->release(assocs); pn->ft->release(pn); _SFCB_RETURN(st); } }