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 ANHProvider::_associators( const Array<CIMInstance>& associationInstances, const CIMObjectPath& localReference, const String& role, const CIMName& resultClass, const String& resultRole, ObjectResponseHandler& handler) { // Filter the instances from the list of association instances against // the specified role filter // Array<CIMInstance> assocInstances = _filterAssociationInstancesByRole( associationInstances, localReference, role); // Now filter the result association instances against the specified // resultClass and resultRole filters // for (Uint32 i = 0, m = assocInstances.size(); i < m; i++) { Array<CIMObjectPath> resultPaths = _filterAssociationInstances( assocInstances[i], localReference, resultClass, resultRole); for (Uint32 j = 0, n = resultPaths.size(); j < n; j++) { CIMName className = resultPaths[j].getClassName(); if (className == CLASS_CIM_NEXT_HOP_ROUTE) { // find instance that corresponds to the reference for (Uint32 k = 0, s = _nhrInstances.size(); k < s; k++) { CIMObjectPath path = _nhrInstances[k].getPath(); // Build a host and namespace independent object path CIMObjectPath localPath = CIMObjectPath( String(), CIMNamespaceName(), path.getClassName(), path.getKeyBindings()); if (resultPaths[j].identical(localPath)) { // deliver the instance handler.deliver(_nhrInstances[k]); } } } else if (className == CLASS_CIM_REMOTE_SERVICE_ACCESS_POINT) { // find instance that corresponds to the reference for (Uint32 k = 0, s = _rsapInstances.size(); k < s; k++) { CIMObjectPath path = _rsapInstances[k].getPath(); // Build a host and namespace independent object path CIMObjectPath localPath = CIMObjectPath( String(), CIMNamespaceName(), path.getClassName(), path.getKeyBindings()); if (resultPaths[j].identical(localPath)) { // deliver instance handler.deliver(_rsapInstances[k]); } } } } } }
/***************************************************************************** * * Implementation of AssociationProvider references method * *****************************************************************************/ void InteropProvider::references( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & resultClass, const String & role, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, ObjectResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::references()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s references. objectName= %s, resultClass= %s role= %s " "includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s", thisProvider, (const char *)objectName.toString().getCString(), (const char *)resultClass.getString().getCString(), (const char *)role.getCString(), boolToString(includeQualifiers), boolToString(includeClassOrigin), (const char *)propertyListToString(propertyList).getCString())); handler.processing(); String tmpRole = role; String tmpTarget; Uint32 numIterations = 1; // // Makes call to internal references method to get result, supplying the // role parameter, but obviously not setting a resultRole/target parameter. // if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) { if (tmpRole.size() == 0) { tmpRole = String("Antecedent"); tmpTarget = String("Dependent"); numIterations = 2; } } for (Uint32 i = 0; i < numIterations; ++i) { Array<CIMInstance> refs = localReferences( context, objectName, resultClass, tmpRole, tmpTarget); for (Uint32 j = 0, n = refs.size(); j < n; ++j) { refs[j].filter(includeQualifiers, includeClassOrigin, propertyList); handler.deliver((CIMObject)refs[j]); } if (numIterations == 2) { tmpRole = String("Dependent"); tmpTarget = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
PEGASUS_NAMESPACE_BEGIN /***************************************************************************** * * Implementation of AssociationProvider associators method * *****************************************************************************/ void InteropProvider::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) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::associators()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s associators. objectName= %s, assocClass= %s resultClass= %s " "role= %s resultRole %s, includeQualifiers= %s, " "includeClassOrigin= %s, PropertyList= %s", thisProvider, (const char *)objectName.toString().getCString(), (const char *)associationClass.getString().getCString(), (const char *)resultClass.getString().getCString(), (const char *)role.getCString(), (const char *)resultRole.getCString(), boolToString(includeQualifiers), boolToString(includeClassOrigin), (const char *)propertyListToString(propertyList).getCString())); handler.processing(); String originRole = role; String targetRole = resultRole; Uint32 numIterations = 1; // // The localReferences call retrieves instances of the desired association // class and sets the originRole and targetRole properties if currently // empty. // if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) { if (originRole.size() == 0 && targetRole.size() == 0) { originRole = String("Antecedent"); targetRole = String("Dependent"); numIterations = 2; } } for (Uint32 i = 0; i < numIterations; ++i) { Array<CIMInstance> refs = localReferences( context, objectName, associationClass, originRole, targetRole, CIMPropertyList(), resultClass); if( refs.size() ) { Array<CIMInstance> refObjs = getReferencedInstances(refs,targetRole,context,propertyList); ConstArrayIterator<CIMInstance> refsIterator(refObjs); for(Uint32 i = 0; i < refsIterator.size(); i++) { handler.deliver(refsIterator[i]); } } if (numIterations == 2) { originRole = String("Dependent"); targetRole = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
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."); }