void _deleteSubscriptionInstance (CIMClient & client, const String & filterName, const String & handlerName) { _deleteSubscriptionInstance (client, filterName, handlerName, CIMNamespaceName (), CIMNamespaceName (), PEGASUS_NAMESPACENAME_INTEROP); }
PEGASUS_NAMESPACE_BEGIN MCCA_TestAssocProvider::MCCA_TestAssocProvider(void) { nameSpaceA = CIMNamespaceName ("root/MCCAtest/A"); nameSpaceB = CIMNamespaceName ("root/MCCAtest/B"); testClassName = CIMName ("MCCA_TestClass"); assocClassName = CIMName ("MCCA_TestAssocClass"); }
void _getKeyValue ( const CIMInstance& namespaceInstance, CIMNamespaceName& childNamespaceName, Boolean& isRelativeName) { //Validate key property Uint32 pos; CIMValue propertyValue; // [Key, MaxLen (256), Description ( // "A string that uniquely identifies the Namespace " // "within the ObjectManager.") ] // string Name; pos = namespaceInstance.findProperty(NAMESPACE_PROPERTYNAME); if (pos == PEG_NOT_FOUND) { throw CIMPropertyNotFoundException (NAMESPACE_PROPERTYNAME.getString()); } propertyValue = namespaceInstance.getProperty(pos).getValue(); if (propertyValue.getType() != CIMTYPE_STRING) { //l10n //throw CIMInvalidParameterException("Invalid type for property: " //+ NAMESPACE_PROPERTYNAME.getString()); throw CIMInvalidParameterException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.INVALID_TYPE_FOR_PROPERTY", "Invalid type for property: $0", NAMESPACE_PROPERTYNAME.getString())); } String cnsName; propertyValue.get(cnsName); if (cnsName == String::EMPTY) { childNamespaceName = CIMNamespaceName(); } else { childNamespaceName = CIMNamespaceName(cnsName); } isRelativeName = !(childNamespaceName.isNull()); }
void _testHostedIndicationServiceInstance(CIMClient &client) { cout << "Testing Association Class " << (const char *)PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE. getString().getCString() << "..."; // Get PG_HostedIndicationService Instances Array<CIMInstance> hostedInstances = client.enumerateInstances( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE); PEGASUS_TEST_ASSERT(hostedInstances.size() == 1); // Get PG_HostedIndicationService Instance names Array<CIMObjectPath> hostedPaths = client.enumerateInstanceNames( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE); PEGASUS_TEST_ASSERT(hostedPaths.size() == 1); // Get CIM_IndicationService instance names Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE); PEGASUS_TEST_ASSERT(servicePaths.size() == 1); // Test the CIM_IndicationService value. CIMValue capValue = hostedInstances[0].getProperty( hostedInstances[0].findProperty("Dependent")).getValue(); CIMObjectPath testPath; capValue.get(testPath); testPath.setNameSpace(CIMNamespaceName()); PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0])); cout << "Test Complete" << endl; }
void IBM_CIMOMStatDataProvider::getInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, InstanceResponseHandler & handler) { CIMObjectPath localReference = CIMObjectPath( String::EMPTY, CIMNamespaceName(), instanceReference.getClassName(), instanceReference.getKeyBindings()); // begin processing the request handler.processing(); // instance index corresponds to reference index for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++) { // cout << "loop" << endl; if(localReference == _references[i]) { // deliver requested instance handler.deliver(getInstance(i)); break; } } // complete processing the request handler.complete(); }
void testArrayType(const Array<T>& x) { WsmToCimRequestMapper mapper((CIMRepository*) 0); // Create a NULL CIMValue of the appropriate type. Normally type // info is retrieved from the repository. CIMValue tmp(x); CIMValue cimValue(tmp.getType(), tmp.isArray()); // Create WsmValue out of the given array Array<String> arr; for (Uint32 i = 0; i < x.size(); i++) { String str = CIMValue(x[i]).toString(); if (tmp.getType() == CIMTYPE_BOOLEAN) { str.toLower(); } arr.append(str); } WsmValue wsmValue(arr); mapper.convertWsmToCimValue(wsmValue, CIMNamespaceName(), cimValue); PEGASUS_TEST_ASSERT(tmp == cimValue); }
Array<CIMInstance> CIMClient::enumerateInstances( const CIMNamespaceName& nameSpace, const CIMName& className, Boolean deepInheritance, Boolean localOnly, Boolean includeQualifiers, Boolean includeClassOrigin, const CIMPropertyList& propertyList) { Array<CIMInstance> a = _rep->enumerateInstances( nameSpace, className, deepInheritance, localOnly, includeQualifiers, includeClassOrigin, propertyList).getInstances(); // remove name space and host name to be instance names for (Uint32 i = 0, n = a.size(); i < n ; i++) { if (!a[i].isUninitialized()) { CIMObjectPath& p = const_cast<CIMObjectPath&>(a[i].getPath()); p.setNameSpace(CIMNamespaceName()); p.setHost(String()); } } return a; }
void AuditLogger::logUpdateInstanceOperation( const char* cimMethodName, AuditEvent eventType, const String& userName, const String& ipAddr, const CIMNamespaceName& nameSpace, const CIMObjectPath& instanceName, const String& moduleName, const String& providerName, CIMStatusCode statusCode) { // check if SMF is gathering this type of records. if (_smf.isRecording(CIM_OPERATION) || (! _isInternalWriterUsed) ) { String cimInstanceName = CIMObjectPath("", CIMNamespaceName(), instanceName.getClassName(), instanceName.getKeyBindings()).toString(); _writeCIMOperationRecord( INSTANCE_OPERATION, userName, statusCode, ipAddr, cimMethodName, cimInstanceName, nameSpace.getString(), providerName, moduleName ); } }
void InstanceProvider::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceReference, ResponseHandler & handler) { // 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()) { // remove instance from the array _instances.remove(i); break; } } // complete processing the request handler.complete(); }
static CMPIEnumeration* mbReferenceNames(const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char *resultClass, const char *role, CMPIStatus *rc) { DDD(cout<<"--- mbReferencesNames()"<<endl); mb=CM_BROKER; CIMObjectPath qop(String::EMPTY,CIMNamespaceName(), CM_ObjectPath(cop)->getClassName(), CM_ObjectPath(cop)->getKeyBindings()); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { Array<CIMObjectPath> const &en=CM_CIMOM(mb)->referenceNames( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), qop, resultClass ? CIMName(resultClass) : CIMName(), role ? String(role) : String::EMPTY); if (rc) CMSetStatus(rc,CMPI_RC_OK); CMPI_Object *obj = new CMPI_Object(new CMPI_OpEnumeration(new Array<CIMObjectPath>(en))); return (CMPI_OpEnumeration *)obj->getHdl(); } catch (const CIMException &e) { DDD(cout<<"### exception: mbReferencesNames - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl); if (rc) CMSetStatusWithString(rc,(CMPIrc)e.getCode(), (CMPIString*)string2CMPIString(e.getMessage())); } if (rc) CMSetStatusWithChars(mb,rc,CMPI_RC_ERROR,"Internal error - CMPIBoker.cpp-11"); return NULL; }
void _sendIndicationShouldBeBlocked (CIMClient & client) { Array <CIMParamValue> inParams; Array <CIMParamValue> outParams; Array <CIMKeyBinding> keyBindings; Sint32 result; CIMName methodName ("SendTestIndication"); CIMObjectPath className (String::EMPTY, CIMNamespaceName (), CIMName("Test_IndicationProviderClass"), keyBindings); try { CIMValue retValue = client.invokeMethod (SOURCENAMESPACE, className, methodName, inParams, outParams); retValue.get (result); PEGASUS_TEST_ASSERT (false); } catch (CIMException & e) { PEGASUS_TEST_ASSERT (e.getCode () == CIM_ERR_NOT_SUPPORTED); } }
void _generateFullNamespaceName( Array<CIMNamespaceName>& namespaceNames, CIMNamespaceName& parentNamespaceName, CIMNamespaceName& childNamespaceName, Boolean isRelativeName, CIMNamespaceName& fullNamespaceName) { // If isRelativeName is true, then the parentNamespace // MUST exist // if (isRelativeName) { if (!Contains(namespaceNames, parentNamespaceName)) { //l10n //throw CIMObjectNotFoundException("Parent namespace does not exist: " //+ parentNamespaceName.getString()); throw CIMObjectNotFoundException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.PARENT_NAMESPACE_DOES_NOT_EXIST", "Parent namespace does not exist: $0", parentNamespaceName.getString())); } // Create full namespace name by prepending parentNamespaceName fullNamespaceName = CIMNamespaceName (parentNamespaceName.getString() + "/" + childNamespaceName.getString()); } else { fullNamespaceName = parentNamespaceName; } }
static CMPIInstance* mbGetInstance(const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char **properties, CMPIStatus *rc) { DDD(cout<<"--- mbGetInstance()"<<endl); mb=CM_BROKER; CMPIFlags flgs=ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; const CIMPropertyList props=getList(properties); CIMObjectPath qop(String::EMPTY,CIMNamespaceName(), CM_ObjectPath(cop)->getClassName(), CM_ObjectPath(cop)->getKeyBindings()); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { CIMInstance ci=CM_CIMOM(mb)->getInstance( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), qop, //*CM_ObjectPath(cop), CM_LocalOnly(flgs), CM_IncludeQualifiers(flgs), CM_ClassOrigin(flgs), props); ci.setPath(*CM_ObjectPath(cop)); if (rc) CMSetStatus(rc,CMPI_RC_OK); return (CMPIInstance*)new CMPI_Object(new CIMInstance(ci)); } catch (const CIMException &e) { DDD(cout<<"### exception: mbGetInstance - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl); if (rc) CMSetStatusWithString(rc,(CMPIrc)e.getCode(), (CMPIString*)string2CMPIString(e.getMessage())); return NULL; } if (rc) CMSetStatusWithChars(mb,rc,CMPI_RC_ERROR,"Internal error - CMPIBoker.cpp-0"); return NULL; }
void TestQualifiers() { // -- Create repository and qualifier test namespace: const CIMNamespaceName QNS = CIMNamespaceName ("TestQualifiers"); try { r->createNameSpace(QNS); } catch (AlreadyExistsException&) { // Ignore this! } // -- Construct a qualifier declaration: CIMQualifierDecl q(CIMName ("abstract"), true, CIMScope::CLASS); r->setQualifier(QNS, q); CIMQualifierDecl qq = r->getQualifier(QNS, CIMName ("abstract")); PEGASUS_TEST_ASSERT(qq.identical(q)); PEGASUS_TEST_ASSERT(q.identical(qq)); // -- Delete the qualifier: r->deleteQualifier(QNS, CIMName ("abstract")); // -- Delete the namespace: r->deleteNameSpace(QNS); }
void _sendTestIndication( CIMClient* client, const CIMName & methodName, Uint32 indicationSendCount) { // // Invoke method to send test indication // Array <CIMParamValue> inParams; Array <CIMParamValue> outParams; Array <CIMKeyBinding> keyBindings; Sint32 result; CIMObjectPath className (String::EMPTY, CIMNamespaceName (), CIMName ("Test_IndicationProviderClass"), keyBindings); inParams.append(CIMParamValue(String("indicationSendCount"), CIMValue(indicationSendCount))); CIMValue retValue = client->invokeMethod (SOURCE_NAMESPACE, className, methodName, inParams, outParams); retValue.get (result); PEGASUS_TEST_ASSERT (result == 0); }
void InstanceProvider::getInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, InstanceResponseHandler & handler) { // 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()) { // deliver requested instance handler.deliver(_instances[i]); break; } } // complete processing the request handler.complete(); }
void _testElementCapabilityInstance(CIMClient &client) { cout << "Testing Association Class " << (const char *)PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES. getString().getCString() << "..."; // Get CIM_IndicationServiceCapabilities instance names Array<CIMObjectPath> capPaths = client.enumerateInstanceNames( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES); PEGASUS_TEST_ASSERT(capPaths.size() == 1); // Get CIM_IndicationService instance names Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE); PEGASUS_TEST_ASSERT(servicePaths.size() == 1); // Get PG_ElementCapabilities instances Array<CIMInstance> eleInstances = client.enumerateInstances( PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_ELEMENTCAPABILITIES); PEGASUS_TEST_ASSERT(eleInstances.size() == 1); // Test PG_ElementCapabilities instance. CIMValue capValue = eleInstances[0].getProperty( eleInstances[0].findProperty("Capabilities")).getValue(); CIMValue meValue = eleInstances[0].getProperty( eleInstances[0].findProperty("ManagedElement")).getValue(); // Now test the instance names of CIM_IndicationService instance and // CIM_IndicationServiceCapabilities instance. CIMObjectPath testPath; capValue.get(testPath); testPath.setNameSpace(CIMNamespaceName()); PEGASUS_TEST_ASSERT(testPath.identical(capPaths[0])); meValue.get(testPath); testPath.setNameSpace(CIMNamespaceName()); PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0])); cout << "Test Complete" << endl; }
void _testDuplicate(CIMClient &client) { CIMObjectPath filterPath; CIMObjectPath handlerPath; CIMObjectPath subscriptionPath; try { handlerPath = CreateHandler1Instance(client, PEGASUS_NAMESPACENAME_INTEROP); filterPath = CreateFilterInstance(client, QUERY1, "WQL", "Filter1", PEGASUS_NAMESPACENAME_INTEROP); subscriptionPath = CreateSbscriptionInstance(client, handlerPath, filterPath, PEGASUS_NAMESPACENAME_INTEROP); _createDuplicate(client, String::EMPTY, CIMNamespaceName(), filterPath, String::EMPTY, CIMNamespaceName(), handlerPath); _createDuplicate(client, String::EMPTY, PEGASUS_NAMESPACENAME_INTEROP, filterPath, String::EMPTY,PEGASUS_NAMESPACENAME_INTEROP, handlerPath); _createDuplicate(client, "127.0.0.1", PEGASUS_NAMESPACENAME_INTEROP, filterPath, String::EMPTY, CIMNamespaceName(), handlerPath); _createDuplicate(client, "127.0.0.1",PEGASUS_NAMESPACENAME_INTEROP, filterPath, "127.0.0.1", PEGASUS_NAMESPACENAME_INTEROP, handlerPath); _createDuplicate(client, String::EMPTY, CIMNamespaceName(), filterPath, "127.0.0.1", PEGASUS_NAMESPACENAME_INTEROP, handlerPath); _checkSubscriptionCount(client); DeleteInstance(client, subscriptionPath, PEGASUS_NAMESPACENAME_INTEROP); DeleteInstance(client, filterPath, PEGASUS_NAMESPACENAME_INTEROP); DeleteInstance(client, handlerPath, PEGASUS_NAMESPACENAME_INTEROP); } catch (const CIMException &e) { PEGASUS_STD(cerr) << "Exception: " << e.getMessage() << PEGASUS_STD (endl); PEGASUS_TEST_ASSERT(0); } }
CIMObjectPath benchmarkProvider::_buildObjectPath( const CIMName& className, CIMKeyBinding keyBinding) { Array<CIMKeyBinding> keyBindings; keyBindings.append(keyBinding); return CIMObjectPath(String(), CIMNamespaceName(NAMESPACE), className, keyBindings); }
void InstanceProvider::modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, const Boolean includeQualifiers, const CIMPropertyList & propertyList, ResponseHandler & handler) { // 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()) { CIMInstance cimInstance = instanceObject.clone(); CIMObjectPath instanceName = CIMObjectPath( String(), CIMNamespaceName(), instanceReference.getClassName(), instanceReference.getKeyBindings()); cimInstance.setPath(instanceName); // overwrite existing instance _instances[i] = instanceObject; break; } } // complete processing the request handler.complete(); }
void InstanceProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, ObjectPathResponseHandler & handler) { // Validate the class name if (!instanceObject.getClassName().equal("Sample_InstanceProviderClass")) { throw CIMNotSupportedException( instanceObject.getClassName().getString()); } // Find the key property Uint32 idIndex = instanceObject.findProperty("Identifier"); if (idIndex == PEG_NOT_FOUND) { throw CIMInvalidParameterException("Missing key value"); } CIMInstance cimInstance = instanceObject.clone(); // Create the new instance name CIMValue idValue = instanceObject.getProperty(idIndex).getValue(); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("Identifier", idValue)); CIMObjectPath instanceName = CIMObjectPath( String(), CIMNamespaceName(), instanceObject.getClassName(), keys); cimInstance.setPath(instanceName); // Determine whether this instance already exists for(Uint32 i = 0, n = _instances.size(); i < n; i++) { if(instanceName == _instances[i].getPath()) { throw CIMObjectAlreadyExistsException(instanceName.toString()); } } // begin processing the request handler.processing(); // add the new instance to the array _instances.append(cimInstance); // deliver the new instance name handler.deliver(instanceName); // complete processing the request handler.complete(); }
CIMInstance UNIX_AccountOnSystem::getPartComponent() const { CIMInstance instance = part_UNIX_Account_ComponentProvider.constructInstance( CIMName("UNIX_Account"), CIMNamespaceName("root/cimv2"), part_UNIX_Account_Component ); return instance; }
CIMInstance UNIX_AccountOnSystem::getGroupComponent() const { CIMInstance instance = group_UNIX_ComputerSystem_ComponentProvider.constructInstance( CIMName("UNIX_ComputerSystem"), CIMNamespaceName("root/cimv2"), group_UNIX_ComputerSystem_Component ); return instance; }
static CMPIEnumeration* mbReferenceNames( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char *resultClass, const char *role, CMPIStatus *rc) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbReferenceNames()"); mb = CM_BROKER; // ATTN-CAKG-P2-20020726: The following condition does not correctly // distinguish instanceNames from classNames in every case // The instanceName of a singleton instance of a keyless class has no // key bindings if (!SCMO_ObjectPath(cop)->getKeyBindingCount()) { CMSetStatus(rc, CMPI_RC_ERR_FAILED); PEG_METHOD_EXIT(); return 0; } SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; try { scmoObjPath->getCIMObjectPath(qop); // For compatibility with previous implementations have empty ns qop.setNameSpace(CIMNamespaceName()); CIMResponseData resData = CM_CIMOM(mb)->referenceNames( *CM_Context(ctx), scmoObjPath->getNameSpace(), qop, resultClass ? CIMName(resultClass) : CIMName(), role ? String(role) : String::EMPTY); // Add the namespace from the input parameters when neccessary resData.completeNamespace(scmoObjPath); Array<SCMOInstance>* aRef = new Array<SCMOInstance>(resData.getSCMO()); CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>( new CMPI_Object(new CMPI_OpEnumeration(aRef))); CMSetStatus(rc,CMPI_RC_OK); PEG_METHOD_EXIT(); return cmpiEnum; } HandlerCatchSetStatus(rc, NULL); // Code flow should never get here. }
void ANHProvider::references( const OperationContext& context, const CIMObjectPath& objectName, const CIMName& resultClass, const String& role, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, ObjectResponseHandler& handler) { // validate namespace const CIMNamespaceName& nameSpace = objectName.getNameSpace(); if (!nameSpace.equal(NAMESPACE)) { throw CIMNotSupportedException( nameSpace.getString() + " not supported."); } // Build a host and namespace independent object path CIMObjectPath localObjectPath = CIMObjectPath( String(), CIMNamespaceName(), objectName.getClassName(), objectName.getKeyBindings()); // begin processing the request handler.processing(); // Filter the instances from the list of association instances against // the specified role filter // Array<CIMInstance> resultInstances; if (resultClass == CLASS_PG_ASSOCIATED_NEXT_HOP) { resultInstances = _filterAssociationInstancesByRole( _AssociationInstances, localObjectPath, role); } else { throw CIMNotSupportedException( resultClass.getString() + " is not supported"); } // return the instances for (Uint32 i = 0, n = resultInstances.size(); i < n; i++) { handler.deliver(resultInstances[i]); } // complete processing the request handler.complete(); }
void testAssociationsHostName( CIMClient & client) { Array<CIMObjectPath> objPaths = client.enumerateInstanceNames( CIMNamespaceName("test/TestProvider"), CIMName("TST_Person")); PEGASUS_TEST_ASSERT(objPaths.size() > 0); Array<CIMObject> objects = client.associators( CIMNamespaceName("test/TestProvider"), objPaths[0]); PEGASUS_TEST_ASSERT(objects.size() > 0); CIMObjectPath path = objects[0].getPath(); String pathHN = path.getHost(); PEGASUS_TEST_ASSERT(String::equal(pathHN,"hugo")); }
void _createSubscription( CIMClient& client, const String& filterName, const String& handlerName, Uint16 onFatalErrorPolicy = 2) { CIMObjectPath filterPath; CIMObjectPath handlerPath; filterPath = _buildFilterOrHandlerPath( PEGASUS_CLASSNAME_INDFILTER, filterName, String::EMPTY, CIMNamespaceName()); handlerPath = _buildFilterOrHandlerPath( PEGASUS_CLASSNAME_LSTNRDST_CIMXML, handlerName, String::EMPTY, CIMNamespaceName()); _createSubscriptionInstance( client, filterPath, handlerPath, onFatalErrorPolicy); }
CIMObjectPath CIMInstanceRep::buildPath( const CIMConstClass& cimClass) const { //-------------------------------------------------------------------------- // Get class name: //-------------------------------------------------------------------------- CIMName className = getClassName(); //-------------------------------------------------------------------------- // Get key names: //-------------------------------------------------------------------------- Array<CIMName> keyNames; cimClass.getKeyNames(keyNames); if (keyNames.size() == 0) return CIMObjectPath("", CIMNamespaceName(), className); //-------------------------------------------------------------------------- // Get type and value for each key (building up key bindings): //-------------------------------------------------------------------------- Array<CIMKeyBinding> keyBindings; for (Uint32 i = 0, n = keyNames.size(); i < n; i++) { const CIMName& keyName = keyNames[i]; Uint32 index = findProperty(keyName); if (index == PEG_NOT_FOUND) { throw NoSuchProperty(keyName.getString()); } CIMConstProperty tmp = getProperty(index); keyBindings.append(CIMKeyBinding(keyName, tmp.getValue())); } return CIMObjectPath(String(), CIMNamespaceName(), className, keyBindings); }
CIMObjectPath _getSubscriptionPath( const String& filterName, const String& handlerName) { Array<CIMKeyBinding> filterKeyBindings; filterKeyBindings.append(CIMKeyBinding("SystemCreationClassName", System::getSystemCreationClassName(), CIMKeyBinding::STRING)); filterKeyBindings.append(CIMKeyBinding("SystemName", System::getFullyQualifiedHostName(), CIMKeyBinding::STRING)); filterKeyBindings.append(CIMKeyBinding("CreationClassName", PEGASUS_CLASSNAME_INDFILTER.getString(), CIMKeyBinding::STRING)); filterKeyBindings.append(CIMKeyBinding("Name", filterName, CIMKeyBinding::STRING)); CIMObjectPath filterPath("", CIMNamespaceName(), PEGASUS_CLASSNAME_INDFILTER, filterKeyBindings); Array<CIMKeyBinding> handlerKeyBindings; handlerKeyBindings.append(CIMKeyBinding("SystemCreationClassName", System::getSystemCreationClassName(), CIMKeyBinding::STRING)); handlerKeyBindings.append(CIMKeyBinding("SystemName", System::getFullyQualifiedHostName(), CIMKeyBinding::STRING)); handlerKeyBindings.append(CIMKeyBinding("CreationClassName", PEGASUS_CLASSNAME_LSTNRDST_CIMXML.getString(), CIMKeyBinding::STRING)); handlerKeyBindings.append(CIMKeyBinding("Name", handlerName, CIMKeyBinding::STRING)); CIMObjectPath handlerPath("", CIMNamespaceName(), PEGASUS_CLASSNAME_LSTNRDST_CIMXML, handlerKeyBindings); Array<CIMKeyBinding> subscriptionKeyBindings; subscriptionKeyBindings.append(CIMKeyBinding("Filter", filterPath.toString(), CIMKeyBinding::REFERENCE)); subscriptionKeyBindings.append(CIMKeyBinding("Handler", handlerPath.toString(), CIMKeyBinding::REFERENCE)); return CIMObjectPath( "", CIMNamespaceName(), PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings); }
void test02() { const CIMNamespaceName NAMESPACE = CIMNamespaceName("/zzz"); CIMClass cimClass(CIMName("MyClass")); cimClass .addProperty(CIMProperty(CIMName("Last"), String()) .addQualifier(CIMQualifier(CIMName("key"), true))) .addProperty(CIMProperty(CIMName("First"), String()) .addQualifier(CIMQualifier(CIMName("key"), true))) .addProperty(CIMProperty(CIMName("Age"), String()) .addQualifier(CIMQualifier(CIMName("key"), true))); CIMInstance cimInstance(CIMName("MyClass")); cimInstance.addProperty(CIMProperty(CIMName("first"), String("John"))); cimInstance.addProperty(CIMProperty(CIMName("last"), String("Smith"))); cimInstance.addProperty(CIMProperty(CIMName("age"), Uint8(101))); assert(cimInstance.findProperty(CIMName("first")) != PEG_NOT_FOUND); assert(cimInstance.findProperty(CIMName("last")) != PEG_NOT_FOUND); assert(cimInstance.findProperty(CIMName("age")) != PEG_NOT_FOUND); assert(cimInstance.getPropertyCount() == 3); CIMObjectPath instanceName = cimInstance.buildPath(CIMConstClass(cimClass)); CIMObjectPath tmp("myclass.age=101,first=\"John\",last=\"Smith\""); assert(tmp.makeHashCode() == instanceName.makeHashCode()); // Test CIMInstance::buildPath with incomplete keys in the instance Boolean caughtNoSuchPropertyException = false; try { CIMInstance badInstance(CIMName("MyClass")); badInstance.addProperty(CIMProperty(CIMName("first"), String("John"))); badInstance.addProperty(CIMProperty(CIMName("last"), String("Smith"))); CIMObjectPath instanceName = badInstance.buildPath(CIMConstClass(cimClass)); } catch (const NoSuchProperty&) { caughtNoSuchPropertyException = true; } assert(caughtNoSuchPropertyException); }