WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-cim

[Xen-cim] [RFC] Rework of association providers

To: xen-cim@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-cim] [RFC] Rework of association providers
From: Jim Fehlig <jfehlig@xxxxxxxxxx>
Date: Mon, 23 Oct 2006 11:29:51 -0600
Delivery-date: Mon, 23 Oct 2006 10:30:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-cim-request@lists.xensource.com?subject=help>
List-id: xen-cim mailing list <xen-cim.lists.xensource.com>
List-post: <mailto:xen-cim@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-cim>, <mailto:xen-cim-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-cim>, <mailto:xen-cim-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-cim-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.7 (X11/20060909)
Attached is a patch (applies cleanly to tip) for the association abstraction work we have been discussing. Only 2 associations (Xen_CSElementSettingData and Xen_ProcessorPoolComponent) have been ported to the new common code in cmpiutil. I would like everyone to agree to this new approach before porting the remaining association providers.

The only issue I have with the patch at this point is whether to place the common code (_CMPIGetTargetEndpoints and its related structures) in cmpiutil or in a new file. As you can see, it currently resides in cmpiutil.[ch].

If there are no objections I will port the remaining association providers and commit to the repository within a few days.

Thanks,
Jim
diff -r 7c937c187b5e configure.ac
--- a/configure.ac      Fri Oct 20 13:20:15 2006 -0600
+++ b/configure.ac      Tue Oct 17 14:27:15 2006 -0600
@@ -167,8 +167,8 @@ AC_CONFIG_HEADER([config.h])
 
 # Autogenerate the Makefiles
 AC_CONFIG_FILES([Makefile
-                src/Makefile])
-
+                src/Makefile
+                src/provider_common.h])
 AM_INIT_AUTOMAKE
 
 # Check for the required C compiler
diff -r 7c937c187b5e src/Xen_CSElementSettingData.c
--- a/src/Xen_CSElementSettingData.c    Fri Oct 20 13:20:15 2006 -0600
+++ b/src/Xen_CSElementSettingData.c    Tue Oct 17 14:27:33 2006 -0600
@@ -15,8 +15,8 @@
 //    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
USA
 // ============================================================================
 // Authors:       Dr. Gareth S. Bestor, <bestor@xxxxxxxxxx>
-// Contributors:
-// Description:
+// Contributors:  Jim Fehlig, <jfehlig@xxxxxxxxxx>
+// Description:   Association provider for Xen_CSElementSettingData.
 // ============================================================================
 
 #include <string.h>
@@ -40,6 +40,9 @@ static CMPIBroker *_BROKER;
 /* Include _SBLIM_TRACE() logging support */
 #include "cmpitrace.h"
 
+/* Include common provider definitions */
+#include "provider_common.h"
+
 
 // ============================================================================
 // CMPI ASSOCIATION PROVIDER FUNCTION TABLE
@@ -48,15 +51,61 @@ static CMPIBroker *_BROKER;
 // ----------------------------------------------------------------------------
 // Info for the class supported by the association provider
 // ----------------------------------------------------------------------------
-                                                                               
                                                  
-/* Name of the left and right hand side classes of this association. */
+
+/* Name of the left and right hand side classes, properties, namespaces, and
+ * key names of this association. */
 static char * _ASSOCCLASS = "Xen_CSElementSettingData";
 static char * _LHSCLASSNAME = "Xen_ComputerSystemSettingData";
 static char * _RHSCLASSNAME = "Xen_ComputerSystem";
 static char * _LHSPROPERTYNAME = "SettingData"; 
 static char * _RHSPROPERTYNAME = "ManagedElement";
+static char * _LHSNAMESPACE = XEN_INSTRUMENTATION_NS;
+static char * _RHSNAMESPACE = XEN_INSTRUMENTATION_NS;
 static char * _LHSKEYNAME = "InstanceID";
 static char * _RHSKEYNAME = "Name";
+
+
+/*
+ * Determine if object path op is a match as defined by the request
+ * parameters incapsulated in assocInfo and assocFilter.
+ */
+static int assocMatch(_CMPIAssocIdentity *assocInfo,
+                      CMPIObjectPath *op,
+                      _CMPIAssocFilter *assocFilter)
+{
+   char *sourceClass = CMGetCharPtr(CMGetClassName(assocInfo->knownEndpoint, 
NULL));
+   char *targetClass = CMGetCharPtr(CMGetClassName(op, NULL));
+   char *sourceKeyName;
+   char *targetKeyName;
+   char *sourceName;
+
+   if (CMClassPathIsA(_BROKER, assocInfo->knownEndpoint, _LHSCLASSNAME, NULL)) 
{
+      sourceKeyName = _LHSKEYNAME;
+      targetKeyName = _RHSKEYNAME;
+   }
+   else {
+      sourceKeyName = _RHSKEYNAME;
+      targetKeyName = _LHSKEYNAME;
+   }
+
+   CMPIData nameData = CMGetKey(assocInfo->knownEndpoint, sourceKeyName, NULL);
+   sourceName = CMGetCharPtr(nameData.value.string);
+   
+   _SBLIM_TRACE(2, ("--- sourcename=\"%s\"", sourceName));
+
+   /* Ignore possible instances of source class. */
+   if (strcmp(targetClass, sourceClass) &&
+       (assocFilter->resultClass == NULL || CMClassPathIsA(_BROKER, op, 
assocFilter->resultClass, NULL))) {
+      /* Only return entries whose name matches the reference. */
+      nameData = CMGetKey(op, targetKeyName, NULL);
+      char *resultName = CMGetCharPtr(nameData.value.string);
+      if (strcmp(sourceName, resultName) == 0)
+         return 1;
+   }
+   
+   return 0;
+}
+
 
 // ----------------------------------------------------------------------------
 // AssociationCleanup()
@@ -93,12 +142,9 @@ static CMPIStatus AssociatorNames(
                const char * resultRole)
 {
    CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
-   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target 
namespace. */
-   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
-   char *targetclass;                          /* Class of the target 
object(s). */
-
-   char *sourcekeyname;
-   char *targetkeyname;
+   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
+   _CMPIAssocIdentity assocInfo;
+   _CMPIAssocFilter assocFilter;
 
    _SBLIM_ENTER("AssociatorNames");
    _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
@@ -108,69 +154,24 @@ static CMPIStatus AssociatorNames(
    _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
    _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
    _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
-   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
-   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
-
-   /* Check that the requested association class, if any, is supported. */
-   if (assocClass != NULL) {
-      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, NULL);
-      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
-         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
-         goto exit;
-      }
-   }
-
-   /* Check that the reference matches the required role, if any. */
-   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
-      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
-      goto exit;
-   }
-
-   /* Determine the target class from the source class. */
-   if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
-      sourcekeyname = _LHSKEYNAME;
-      targetclass = _RHSCLASSNAME;
-      targetkeyname = _RHSKEYNAME;
-   } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
-      sourcekeyname = _RHSKEYNAME;
-      targetclass = _LHSCLASSNAME;
-      targetkeyname = _LHSKEYNAME;
-   } else {
-      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
-      goto exit;
-   }
-   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
-
-   CMPIData namedata = CMGetKey(reference, sourcekeyname, NULL);
-   char * sourcename = CMGetCharPtr(namedata.value.string);
-   _SBLIM_TRACE(2, ("--- sourcename=\"%s\"", sourcename));
-
-   /* Create an object path for the result class. */
-   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, 
targetclass, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
-      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
-      goto exit;
-   }
-
-   /* Get the list of all target class object paths from the CIMOM. */
-   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, 
objectpath, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
-      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate 
target class");
-      goto exit;
-   }
-
-   /* Return all object paths that exactly match the target class and 
resultClass, if specified. */
-   while (CMHasNext(objectpaths, NULL)) {
-      CMPIData data = CMGetNext(objectpaths, NULL);
-      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
-      if ((strcmp(class,targetclass) == 0) && ((resultClass == NULL) || 
(strcmp(class,resultClass) == 0))) {
-         /* Only return entries whose name matches the reference. */
-         namedata = CMGetKey(data.value.ref, targetkeyname, &status);
-         char * resultname = CMGetCharPtr(namedata.value.string);
-         if (strcmp(sourcename, resultname) == 0) CMReturnObjectPath(results, 
data.value.ref);
-      }
+   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
+
+   assocInfo.knownEndpoint = reference;
+   assocInfo.assocClassName = _ASSOCCLASS;
+   assocInfo.lhsClassName = _LHSCLASSNAME;
+   assocInfo.lhsNamespace = _LHSNAMESPACE;
+   assocInfo.rhsClassName = _RHSCLASSNAME;
+   assocInfo.rhsNamespace = _RHSNAMESPACE;
+   assocInfo.opCode = _CMPI_ASSOC_OP_AN;
+
+   assocFilter.assocClass = assocClass;
+   assocFilter.resultClass = resultClass;
+   assocFilter.role = role;
+   assocFilter.resultRole = resultRole;
+
+   if (_CMPIGetTargetEndpoints(_BROKER, context, &assocInfo, &assocFilter, 
assocMatch, results, &status)) {
+      _SBLIM_TRACE(1,("--- _CMPIGetTargetEndpoints() failed - %s", 
CMGetCharPtr(status.msg)));
+      goto exit;
    }
 
    CMReturnDone(results);
@@ -192,15 +193,12 @@ static CMPIStatus Associators(
                const char *resultClass,
                const char *role,
                const char *resultRole,
-               char ** properties)             /* [in] List of desired 
properties (NULL=all). */
-{
-   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
-   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target 
namespace. */
-   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
-   char *targetclass;                           /* Class of the target 
object(s). */
-
-   char *sourcekeyname;
-   char *targetkeyname;
+               const char ** properties)               /* [in] List of desired 
properties (NULL=all). */
+{
+   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
+   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
+   _CMPIAssocIdentity assocInfo;
+   _CMPIAssocFilter assocFilter;
 
    _SBLIM_ENTER("Associators");
    _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
@@ -210,72 +208,25 @@ static CMPIStatus Associators(
    _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
    _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
    _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
-   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
-   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
-
-   /* Check that the requested association class, if any, is supported. */
-   if (assocClass != NULL) {
-      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, NULL);
-      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
-         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
-         goto exit;
-      }
-   }
-
-   /* Check that the reference matches the required role, if any. */
-   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
-      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
-      goto exit;
-   }
-   CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
-
-   /* Determine the target class from the source class. */
-   if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
-      sourcekeyname = _LHSKEYNAME;
-      targetclass = _RHSCLASSNAME;
-      targetkeyname = _RHSKEYNAME;
-   } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
-      sourcekeyname = _RHSKEYNAME;
-      targetclass = _LHSCLASSNAME;
-      targetkeyname = _LHSKEYNAME;
-   } else {
-      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
-      goto exit;
-   }
-   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
-
-   CMPIData namedata = CMGetKey(reference, sourcekeyname, NULL);
-   char * sourcename = CMGetCharPtr(namedata.value.string);
-   _SBLIM_TRACE(2, ("--- sourcename=\"%s\"", sourcename));
-
-   /* Create an object path for the result class. */
-   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, 
targetclass, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
-      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
-      goto exit;
-   }
-
-   /* Get the list of all target class instances from the CIMOM. */
-   CMPIEnumeration * instances = CBEnumInstances(_BROKER, context, objectpath, 
NULL, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instances)) {
-      _SBLIM_TRACE(1,("--- CBEnumInstances() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate 
target class");
-      goto exit;
-   }
-
-   /* Return all instances that exactly match the target class and 
resultClass, if specified. */
-   while (CMHasNext(instances, NULL)) {
-      CMPIData data = CMGetNext(instances, NULL);
-      char *class = 
CMGetCharPtr(CMGetClassName(CMGetObjectPath(data.value.inst,NULL), NULL));
-      if ((strcmp(class,targetclass) == 0) && ((resultClass == NULL) || 
(strcmp(class,resultClass) == 0))) {
-         /* Only return entries whose name matches the reference. */
-         namedata = CMGetProperty(data.value.inst, targetkeyname, NULL);
-         char * resultname = CMGetCharPtr(namedata.value.string);
-// BUG - returning data causes crash !?!
-_SBLIM_TRACE(2, ("--- data.value.inst=\"%s\"", 
CMGetCharPtr(CDToString(_BROKER, data.value.inst, NULL))));
-//         if (strcmp(sourcename, resultname) == 0) CMReturnInstance(results, 
data.value.inst);
-      }
+   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
+
+   assocInfo.knownEndpoint = reference;
+   assocInfo.assocClassName = _ASSOCCLASS;
+   assocInfo.lhsClassName = _LHSCLASSNAME;
+   assocInfo.lhsNamespace = _LHSNAMESPACE;
+   assocInfo.rhsClassName = _RHSCLASSNAME;
+   assocInfo.rhsNamespace = _RHSNAMESPACE;
+   assocInfo.properties = properties;
+   assocInfo.opCode = _CMPI_ASSOC_OP_A;
+
+   assocFilter.assocClass = assocClass;
+   assocFilter.resultClass = resultClass;
+   assocFilter.role = role;
+   assocFilter.resultRole = resultRole;
+
+   if (_CMPIGetTargetEndpoints(_BROKER, context, &assocInfo, &assocFilter, 
assocMatch, results, &status)) {
+      _SBLIM_TRACE(1,("--- _CMPIGetTargetEndpoints() failed - %s", 
CMGetCharPtr(status.msg)));
+      goto exit;
    }
 
    CMReturnDone(results);
@@ -299,10 +250,8 @@ static CMPIStatus ReferenceNames(
    CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
    char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target 
namespace. */
    char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
-   char *targetclass;                           /* Class of the target 
object(s). */
-
-   char *sourcekeyname;
-   char *targetkeyname;
+   _CMPIAssocIdentity assocInfo;
+   _CMPIAssocFilter assocFilter;
 
    _SBLIM_ENTER("ReferenceNames");
    _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
@@ -310,88 +259,30 @@ static CMPIStatus ReferenceNames(
    _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, 
reference, NULL))));
    _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
    _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
-   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
-   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
-
-   /* Check that the requested association class, if any, is supported. */
-   if (assocClass != NULL) {
-      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, NULL);
-      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
-         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
-         goto exit;
-      }
-   }
-
-   /* Check that the reference matches the required role, if any. */
-   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
-      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
-      goto exit;
-   }
-
-   /* Determine the target class from the source class. */
-   if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
-      sourcekeyname = _LHSKEYNAME;
-      targetclass = _RHSCLASSNAME;
-      targetkeyname = _RHSKEYNAME;
-   } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
-      sourcekeyname = _RHSKEYNAME;
-      targetclass = _LHSCLASSNAME;
-      targetkeyname = _LHSKEYNAME;
-   } else {
-      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
-      goto exit;
-   }
-   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
-
-   CMPIData namedata = CMGetKey(reference, sourcekeyname, NULL);
-   char * sourcename = CMGetCharPtr(namedata.value.string);
-   _SBLIM_TRACE(2, ("--- sourcename=\"%s\"", sourcename));
-
-   /* Create an object path for the result class. */
-   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, 
targetclass, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
-      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
-      goto exit;
-   }
-
-   /* Get the list of all target class object paths from the CIMOM. */
-   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, 
objectpath, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
-      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate 
target class");
-      goto exit;
-   }
-
-   /* Return all object paths that exactly match the target class and 
resultClass, if specified. */
-   while (CMHasNext(objectpaths, NULL)) {
-      CMPIData data = CMGetNext(objectpaths, NULL);
-      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
-      if (strcmp(class,targetclass) == 0) {
-
-         /* Create an object path for the association. */
-         CMPIObjectPath * refobjectpath = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, &status);
-         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refobjectpath)) {
-            _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot 
create new CMPIObjectPath");
-            goto exit;
-         }
-
-         /* Assign the references in the association appropriately. */
-         if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
-            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &reference, CMPI_ref);
-            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &data.value.ref, 
CMPI_ref);
-         } else {
-            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &data.value.ref, 
CMPI_ref);
-            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &reference, CMPI_ref);
-         }
-
-         /* Only return entries whose name matches the reference. */
-         namedata = CMGetKey(data.value.ref, targetkeyname, &status);
-         char * resultname = CMGetCharPtr(namedata.value.string);
-         if (strcmp(sourcename, resultname) == 0) CMReturnObjectPath(results, 
refobjectpath);
-      }
-   }
+   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
+
+   assocInfo.knownEndpoint = reference;
+   assocInfo.assocClassName = _ASSOCCLASS;
+   assocInfo.lhsClassName = _LHSCLASSNAME;
+   assocInfo.lhsNamespace = _LHSNAMESPACE;
+   assocInfo.lhsPropertyName = _LHSPROPERTYNAME;
+   assocInfo.rhsClassName = _RHSCLASSNAME;
+   assocInfo.rhsNamespace = _RHSNAMESPACE;
+   assocInfo.rhsPropertyName = _RHSPROPERTYNAME;
+   assocInfo.opCode = _CMPI_ASSOC_OP_RN;
+
+   assocFilter.assocClass = assocClass;
+   assocFilter.resultClass = NULL;
+   assocFilter.role = role;
+   assocFilter.resultRole = NULL;
+
+   if (_CMPIGetTargetEndpoints(_BROKER, context, &assocInfo, &assocFilter, 
assocMatch, results, &status)) {
+      
+      _SBLIM_TRACE(1,("--- _CMPIGetTargetEndpoints() failed - %s", 
CMGetCharPtr(status.msg)));
+      goto exit;
+   }
+
+   CMReturnDone(results);
 
 exit:
    _SBLIM_RETURNSTATUS(status);
@@ -408,15 +299,13 @@ static CMPIStatus References(
                CMPIObjectPath * reference,     /* [in] Contains the namespace, 
classname and desired object path. */
                const char *assocClass,
                const char *role,
-               char **properties)              /* [in] List of desired 
properties (NULL=all). */
+               const char **properties)                /* [in] List of desired 
properties (NULL=all). */
 {
    CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
    char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target 
namespace. */
    char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
-   char *targetclass;                           /* Class of the target 
object(s). */
-
-   char *sourcekeyname;
-   char *targetkeyname;
+   _CMPIAssocIdentity assocInfo;
+   _CMPIAssocFilter assocFilter;
 
    _SBLIM_ENTER("References");
    _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
@@ -424,89 +313,33 @@ static CMPIStatus References(
    _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, 
reference, NULL))));
    _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
    _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
-   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
-   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
-
-   /* Check that the requested association class, if any, is supported. */
-   if (assocClass != NULL) {
-      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, NULL);
-      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
-         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
-         goto exit;
-      }
-   }
-
-   /* Check that the reference matches the required role, if any. */
-   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
-      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
-      goto exit;
-   }
-
-   /* Determine the target class from the source class. */
-   if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
-      sourcekeyname = _LHSKEYNAME;
-      targetclass = _RHSCLASSNAME;
-      targetkeyname = _RHSKEYNAME;
-   } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
-      sourcekeyname = _RHSKEYNAME;
-      targetclass = _LHSCLASSNAME;
-      targetkeyname = _LHSKEYNAME;
-   } else {
-      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
-      goto exit;
-   }
-   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
-
-   CMPIData namedata = CMGetKey(reference, sourcekeyname, NULL);
-   char * sourcename = CMGetCharPtr(namedata.value.string);
-   _SBLIM_TRACE(2, ("--- sourcename=\"%s\"", sourcename));
-
-   /* Create an object path for the result class. */
-   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, 
targetclass, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
-      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
-      goto exit;
-   }
-
-   /* Get the list of all target class object paths from the CIMOM. */
-   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, 
objectpath, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
-      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate 
target class");
-      goto exit;
-   }
-
-   /* Return all object paths that exactly match the target class and 
resultClass, if specified. */
-   while (CMHasNext(objectpaths, NULL)) {
-      CMPIData data = CMGetNext(objectpaths, NULL);
-      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
-      if (strcmp(class,targetclass) == 0) {
-
-         /* Create an instance for the association. */
-         CMPIInstance * refinstance = _CMNewInstance(_BROKER, namespace, 
_ASSOCCLASS, &status);
-         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refinstance)) {
-            _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", 
CMGetCharPtr(status.msg)));
-            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot 
create new CMPIInstance");
-            goto exit;
-         }
-
-         /* Assign the references in the association appropriately. */
-         if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
-            CMSetProperty(refinstance, _RHSPROPERTYNAME, &reference, CMPI_ref);
-            CMSetProperty(refinstance, _LHSPROPERTYNAME, &data.value.ref, 
CMPI_ref);
-         } else {
-            CMSetProperty(refinstance, _RHSPROPERTYNAME, &data.value.ref, 
CMPI_ref);
-            CMSetProperty(refinstance, _LHSPROPERTYNAME, &reference, CMPI_ref);
-         }
-
-         /* Only return entries whose name matches the reference. */
-         namedata = CMGetKey(data.value.ref, targetkeyname, &status);
-         char * resultname = CMGetCharPtr(namedata.value.string);
-         if (strcmp(sourcename, resultname) == 0) CMReturnInstance(results, 
refinstance);
-      }
-   }
-exit:
+   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
+
+   assocInfo.knownEndpoint = reference;
+   assocInfo.assocClassName = _ASSOCCLASS;
+   assocInfo.lhsClassName = _LHSCLASSNAME;
+   assocInfo.lhsNamespace = _LHSNAMESPACE;
+   assocInfo.lhsPropertyName = _LHSPROPERTYNAME;
+   assocInfo.rhsClassName = _RHSCLASSNAME;
+   assocInfo.rhsNamespace = _RHSNAMESPACE;
+   assocInfo.rhsPropertyName = _RHSPROPERTYNAME;
+   assocInfo.properties = properties;
+   assocInfo.opCode = _CMPI_ASSOC_OP_R;
+
+   assocFilter.assocClass = assocClass;
+   assocFilter.resultClass = NULL;
+   assocFilter.role = role;
+   assocFilter.resultRole = NULL;
+
+   if (_CMPIGetTargetEndpoints(_BROKER, context, &assocInfo, &assocFilter, 
assocMatch, results, &status)) {
+      
+      _SBLIM_TRACE(1,("--- _CMPIGetTargetEndpoints() failed - %s", 
CMGetCharPtr(status.msg)));
+      goto exit;
+   }
+
+   CMReturnDone(results);
+
+ exit:
    _SBLIM_RETURNSTATUS(status);
 }
 
diff -r 7c937c187b5e src/Xen_ProcessorPoolComponent.c
--- a/src/Xen_ProcessorPoolComponent.c  Fri Oct 20 13:20:15 2006 -0600
+++ b/src/Xen_ProcessorPoolComponent.c  Tue Oct 17 14:27:50 2006 -0600
@@ -16,7 +16,7 @@
 // ============================================================================
 // Authors:       Jim Fehlig, <jfehlig@xxxxxxxxxx>
 // Contributors:
-// Description:
+// Description:   Association provider for Xen_ProcessorPoolComponent.
 // ============================================================================
 
 #include <string.h>
@@ -40,6 +40,8 @@ static CMPIBroker *_BROKER;
 /* Include _SBLIM_TRACE() logging support */
 #include "cmpitrace.h"
 
+/* Include common provider definitions */
+#include "provider_common.h"
 
 // ============================================================================
 // CMPI ASSOCIATION PROVIDER FUNCTION TABLE
@@ -48,18 +50,40 @@ static CMPIBroker *_BROKER;
 // ----------------------------------------------------------------------------
 // Info for the class supported by the association provider
 // ----------------------------------------------------------------------------
-                                                                               
                                                  
-/* Name of the left and right hand side classes of this association. */
+
+/* Name of the left and right hand side classes, properties, namespaces, and
+ * key names of this association. */
 static char * _ASSOCCLASS = "Xen_ProcessorPoolComponent";
 static char * _LHSCLASSNAME = "Xen_ProcessorPool";
-static char * _RHSCLASSNAME = "CIM_Processor";
+static char * _RHSCLASSNAME = HOST_INSTRUMENTATION_PREFIX"Processor";
 static char * _LHSPROPERTYNAME = "GroupComponent"; 
 static char * _RHSPROPERTYNAME = "PartComponent";
-static char * _LHSNAMESPACE = "root/cimv2";
-static char * _RHSNAMESPACE = "smash";
+static char * _LHSNAMESPACE = XEN_INSTRUMENTATION_NS;
+static char * _RHSNAMESPACE = HOST_INSTRUMENTATION_NS;
 
 static char * _XEN_DOMU_PROCESSOR_CLASS = "Xen_Processor";
 
+
+/*
+ * Determine if object path op is a match as defined by the request
+ * parameters incapsulated in assocInfo and assocFilter.
+ */
+static int assocMatch(_CMPIAssocIdentity *assocInfo,
+                      CMPIObjectPath *op,
+                      _CMPIAssocFilter *assocFilter)
+{
+   char *sourceClass = CMGetCharPtr(CMGetClassName(assocInfo->knownEndpoint, 
NULL));
+   char *targetClass = CMGetCharPtr(CMGetClassName(op, NULL));
+   
+   /* Ignore possible instances of source class. */
+   if (strcmp(targetClass, sourceClass) &&
+       (assocFilter->resultClass == NULL || CMClassPathIsA(_BROKER, op, 
assocFilter->resultClass, NULL))) {
+      
+      return 1;
+   }
+
+   return 0;
+}
 
 // ----------------------------------------------------------------------------
 // AssociationCleanup()
@@ -96,10 +120,9 @@ static CMPIStatus AssociatorNames(
                const char * resultRole)
 {
    CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
-   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target 
namespace. */
-   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
-   char *targetclass;                          /* Class of the target 
object(s). */
-   char *targetnamespace;
+   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
+   _CMPIAssocIdentity assocInfo;
+   _CMPIAssocFilter assocFilter;
 
    _SBLIM_ENTER("AssociatorNames");
    _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
@@ -109,73 +132,31 @@ static CMPIStatus AssociatorNames(
    _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
    _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
    _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
-   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
-   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
-
-   /* Ensure the source class is not a virtual processor */
-   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
-      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", 
_XEN_DOMU_PROCESSOR_CLASS));
-      goto exit;
-   }
-
-   /* Check that the requested association class, if any, is supported. */
-   if (assocClass != NULL) {
-      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, NULL);
-      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
-         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
-         goto exit;
-      }
-   }
-
-   /* Check that the reference matches the required role, if any. */
-   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
-      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
-      goto exit;
-   }
-
-   /* Determine the target class from the source class. */
-   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
-      targetclass = _RHSCLASSNAME;
-      targetnamespace = _RHSNAMESPACE;
-   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
-      targetclass = _LHSCLASSNAME;
-      targetnamespace = _LHSNAMESPACE;
-   } else {
-      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
-      goto exit;
-   } 
-   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
-   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
-
-   /* Create an object path for the result class. */
-   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, 
targetclass, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
-      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
-      goto exit;
-   }
-
-   /* Get the list of all target class object paths from the CIMOM. */
-   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, 
objectpath, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
-      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate 
target class");
-      goto exit;
-   }
-
-   /* Return all object paths that exactly match the target class and 
resultClass, if specified. */
-   while (CMHasNext(objectpaths, NULL)) {
-      CMPIData data = CMGetNext(objectpaths, NULL);
-      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
-
-      _SBLIM_TRACE(2, ("--- got objectpath=\"%s\"", 
CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
-
-      /* Ignore possible instances of source class. */
-      if (strcmp(class,sourceclass) &&
-          (resultClass == NULL || CMClassPathIsA(_BROKER, data.value.ref, 
resultClass, NULL))) {
-
-         CMReturnObjectPath(results, data.value.ref);
-      }
+   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
+
+   /* Ensure the source class is not a virtual processor */
+   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
+      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", 
_XEN_DOMU_PROCESSOR_CLASS));
+      goto exit;
+   }
+
+   assocInfo.knownEndpoint = reference;
+   assocInfo.assocClassName = _ASSOCCLASS;
+   assocInfo.lhsClassName = _LHSCLASSNAME;
+   assocInfo.lhsNamespace = _LHSNAMESPACE;
+   assocInfo.rhsClassName = _RHSCLASSNAME;
+   assocInfo.rhsNamespace = _RHSNAMESPACE;
+   assocInfo.rhsPropertyName = _RHSPROPERTYNAME;
+   assocInfo.opCode = _CMPI_ASSOC_OP_AN;
+
+   assocFilter.assocClass = assocClass;
+   assocFilter.resultClass = resultClass;
+   assocFilter.role = role;
+   assocFilter.resultRole = resultRole;
+
+   if (_CMPIGetTargetEndpoints(_BROKER, context, &assocInfo, &assocFilter, 
assocMatch, results, &status)) {
+      _SBLIM_TRACE(1,("--- _CMPIGetTargetEndpoints() failed - %s", 
CMGetCharPtr(status.msg)));
+      goto exit;
    }
 
    CMReturnDone(results);
@@ -197,13 +178,12 @@ static CMPIStatus Associators(
                const char *resultClass,
                const char *role,
                const char *resultRole,
-               char ** properties)             /* [in] List of desired 
properties (NULL=all). */
-{
-   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
-   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target 
namespace. */
-   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
-   char *targetclass;                           /* Class of the target 
object(s). */
-   char *targetnamespace;
+               const char ** properties)               /* [in] List of desired 
properties (NULL=all). */
+{
+   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
+   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
+   _CMPIAssocIdentity assocInfo;
+   _CMPIAssocFilter assocFilter;
 
    _SBLIM_ENTER("Associators");
    _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
@@ -213,79 +193,33 @@ static CMPIStatus Associators(
    _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
    _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
    _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
-   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
-   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
-
-   /* Ensure the source class is not a virtual processor */
-   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
-      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", 
_XEN_DOMU_PROCESSOR_CLASS));
-      goto exit;
-   }
-
-   /* Check that the requested association class, if any, is supported. */
-   if (assocClass != NULL) {
-      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, NULL);
-      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
-         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
-         goto exit;
-      }
-   }
-
-   /* Check that the reference matches the required role, if any. */
-   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
-      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
-      goto exit;
-   }
-   CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
-
-   /* Determine the target class from the source class. */
-   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
-      targetclass = _RHSCLASSNAME;
-      targetnamespace = _RHSNAMESPACE;
-   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
-      targetclass = _LHSCLASSNAME;
-      targetnamespace = _LHSNAMESPACE;
-   } else {
-      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
-      goto exit;
-   } 
-   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
-   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
-
-   /* Create an object path for the result class. */
-   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, 
targetclass, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
-      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
-      goto exit;
-   }
-
-   /* Get the list of all target class instances from the CIMOM. */
-   CMPIEnumeration * instances = CBEnumInstances(_BROKER, context, objectpath, 
NULL, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instances)) {
-      _SBLIM_TRACE(1,("--- CBEnumInstances() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate 
target class");
-      goto exit;
-   }
-
-   /* Return all instances that exactly match the target class and 
resultClass, if specified. */
-   while (CMHasNext(instances, NULL)) {
-      CMPIData data = CMGetNext(instances, NULL);
-      CMPIObjectPath *op = CMGetObjectPath(data.value.inst,NULL);
-      char *class = CMGetCharPtr(CMGetClassName(op, NULL));
-
-      CMSetNameSpace(op, targetnamespace);
-      _SBLIM_TRACE(2, ("--- got objectpath=\"%s\"", 
CMGetCharPtr(CDToString(_BROKER, op, NULL))));
-      _SBLIM_TRACE(2, ("--- got class=\"%s\"", class));
-
-      /* Ignore possible instances of source class. */
-      if (strcmp(class,sourceclass) &&
-          (resultClass == NULL || CMClassPathIsA(_BROKER, op, resultClass, 
NULL))) {
-         _SBLIM_TRACE(2, ("--- returning instance"));
-         CMReturnInstance(results, data.value.inst);
-      }
-   }
-   
+   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
+
+   /* Ensure the source class is not a virtual processor */
+   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
+      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", 
_XEN_DOMU_PROCESSOR_CLASS));
+      goto exit;
+   }
+
+   assocInfo.knownEndpoint = reference;
+   assocInfo.assocClassName = _ASSOCCLASS;
+   assocInfo.lhsClassName = _LHSCLASSNAME;
+   assocInfo.lhsNamespace = _LHSNAMESPACE;
+   assocInfo.rhsClassName = _RHSCLASSNAME;
+   assocInfo.rhsNamespace = _RHSNAMESPACE;
+   assocInfo.properties = properties;
+   assocInfo.opCode = _CMPI_ASSOC_OP_A;
+
+   assocFilter.assocClass = assocClass;
+   assocFilter.resultClass = resultClass;
+   assocFilter.role = role;
+   assocFilter.resultRole = resultRole;
+
+   if (_CMPIGetTargetEndpoints(_BROKER, context, &assocInfo, &assocFilter, 
assocMatch, results, &status)) {
+      _SBLIM_TRACE(1,("--- _CMPIGetTargetEndpoints() failed - %s", 
CMGetCharPtr(status.msg)));
+      goto exit;
+   }
+
    CMReturnDone(results);
 
 exit:
@@ -305,10 +239,9 @@ static CMPIStatus ReferenceNames(
                const char *role)
 {
    CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
-   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target 
namespace. */
-   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
-   char *targetclass;                           /* Class of the target 
object(s). */
-   char *targetnamespace;
+   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
+   _CMPIAssocIdentity assocInfo;
+   _CMPIAssocFilter assocFilter;
 
    _SBLIM_ENTER("ReferenceNames");
    _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
@@ -316,90 +249,36 @@ static CMPIStatus ReferenceNames(
    _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, 
reference, NULL))));
    _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
    _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
-   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
-   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
-
-   /* Ensure the source class is not a virtual processor */
-   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
-      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", 
_XEN_DOMU_PROCESSOR_CLASS));
-      goto exit;
-   }
-
-   /* Check that the requested association class, if any, is supported. */
-   if (assocClass != NULL) {
-      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, NULL);
-      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
-         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
-         goto exit;
-      }
-   }
-
-   /* Check that the reference matches the required role, if any. */
-   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
-      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
-      goto exit;
-   }
-
-   /* Determine the target class from the source class. */
-   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
-      targetclass = _RHSCLASSNAME;
-      targetnamespace = _RHSNAMESPACE;
-      /* Refences of LHS class should always be in LHS namespace. */
-      CMSetNameSpace(reference, _LHSNAMESPACE);
-   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
-      targetclass = _LHSCLASSNAME;
-      targetnamespace = _LHSNAMESPACE;
-   } else {
-      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
-      goto exit;
-   } 
-   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
-   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
-
-   /* Create an object path for the result class. */
-   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, 
targetclass, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
-      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
-      goto exit;
-   }
-
-   /* Get the list of all target class object paths from the CIMOM. */
-   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, 
objectpath, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
-      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate 
target class");
-      goto exit;
-   }
-
-   /* Return all object paths that exactly match the target class and 
resultClass, if specified. */
-   while (CMHasNext(objectpaths, NULL)) {
-      CMPIData data = CMGetNext(objectpaths, NULL);
-
-      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
-         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
-         /* Create an object path for the association. Note that the 
association
-          * objects should exist in 'virt namespace' not the host namespace.
-          */
-         CMPIObjectPath * refobjectpath = CMNewObjectPath(_BROKER, 
_LHSNAMESPACE, _ASSOCCLASS, &status);
-         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refobjectpath)) {
-            _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot 
create new CMPIObjectPath");
-            goto exit;
-         }
-
-         /* Assign the references in the association appropriately. */
-         if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
-            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &reference, CMPI_ref);
-            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &data.value.ref, 
CMPI_ref);
-         } else {
-            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &data.value.ref, 
CMPI_ref);
-            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &reference, CMPI_ref);
-         }
-
-         CMReturnObjectPath(results, refobjectpath);
-      }
-   }
+   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
+
+   /* Ensure the source class is not a virtual processor */
+   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
+      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", 
_XEN_DOMU_PROCESSOR_CLASS));
+      goto exit;
+   }
+
+   assocInfo.knownEndpoint = reference;
+   assocInfo.assocClassName = _ASSOCCLASS;
+   assocInfo.lhsClassName = _LHSCLASSNAME;
+   assocInfo.lhsNamespace = _LHSNAMESPACE;
+   assocInfo.lhsPropertyName = _LHSPROPERTYNAME;
+   assocInfo.rhsClassName = _RHSCLASSNAME;
+   assocInfo.rhsNamespace = _RHSNAMESPACE;
+   assocInfo.rhsPropertyName = _RHSPROPERTYNAME;
+   assocInfo.opCode = _CMPI_ASSOC_OP_RN;
+
+   assocFilter.assocClass = assocClass;
+   assocFilter.resultClass = NULL;
+   assocFilter.role = role;
+   assocFilter.resultRole = NULL;
+
+   if (_CMPIGetTargetEndpoints(_BROKER, context, &assocInfo, &assocFilter, 
assocMatch, results, &status)) {
+      
+      _SBLIM_TRACE(1,("--- _CMPIGetTargetEndpoints() failed - %s", 
CMGetCharPtr(status.msg)));
+      goto exit;
+   }
+
+   CMReturnDone(results);
 
 exit:
    _SBLIM_RETURNSTATUS(status);
@@ -416,13 +295,12 @@ static CMPIStatus References(
                CMPIObjectPath * reference,     /* [in] Contains the namespace, 
classname and desired object path. */
                const char *assocClass,
                const char *role,
-               char **properties)              /* [in] List of desired 
properties (NULL=all). */
-{
-   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
-   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target 
namespace. */
-   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
-   char *targetclass;                           /* Class of the target 
object(s). */
-   char *targetnamespace;
+               const char **properties)                /* [in] List of desired 
properties (NULL=all). */
+{
+   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM 
operations. */
+   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* 
Class of the source reference object */
+   _CMPIAssocIdentity assocInfo;
+   _CMPIAssocFilter assocFilter;
 
    _SBLIM_ENTER("References");
    _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
@@ -430,90 +308,38 @@ static CMPIStatus References(
    _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, 
reference, NULL))));
    _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
    _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
-   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
-   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
-
-   /* Ensure the source class is not a virtual processor */
-   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
-      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", 
_XEN_DOMU_PROCESSOR_CLASS));
-      goto exit;
-   }
-
-   /* Check that the requested association class, if any, is supported. */
-   if (assocClass != NULL) {
-      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, 
_ASSOCCLASS, NULL);
-      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
-         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
-         goto exit;
-      }
-   }
-
-   /* Check that the reference matches the required role, if any. */
-   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
-      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
-      goto exit;
-   }
-
-   /* Determine the target class from the source class. */
-   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
-      targetclass = _RHSCLASSNAME;
-      targetnamespace = _RHSNAMESPACE;
-      /* Refences of LHS class should always be in LHS namespace. */
-      CMSetNameSpace(reference, _LHSNAMESPACE);
-   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
-      targetclass = _LHSCLASSNAME;
-      targetnamespace = _LHSNAMESPACE;
-   } else {
-      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
-      goto exit;
-   } 
-   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
-   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
-
-   /* Create an object path for the result class. */
-   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, 
targetclass, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
-      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
-      goto exit;
-   }
-
-   /* Get the list of all target class object paths from the CIMOM. */
-   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, 
objectpath, &status);
-   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
-      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", 
CMGetCharPtr(status.msg)));
-      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate 
target class");
-      goto exit;
-   }
-
-   /* Return all object paths that exactly match the target class and 
resultClass, if specified. */
-   while (CMHasNext(objectpaths, NULL)) {
-      CMPIData data = CMGetNext(objectpaths, NULL);
-
-      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
-         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
-         /* Create an instance for the association. Note that the association
-          * objects should exist in 'virt namespace' not the host namespace.
-          */
-         CMPIInstance * refinstance = _CMNewInstance(_BROKER, _LHSNAMESPACE, 
_ASSOCCLASS, &status);
-         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refinstance)) {
-            _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", 
CMGetCharPtr(status.msg)));
-            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot 
create new CMPIInstance");
-            goto exit;
-         }
-
-         /* Assign the references in the association appropriately. */
-         if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
-            CMSetProperty(refinstance, _RHSPROPERTYNAME, &reference, CMPI_ref);
-            CMSetProperty(refinstance, _LHSPROPERTYNAME, &data.value.ref, 
CMPI_ref);
-         } else {
-            CMSetProperty(refinstance, _RHSPROPERTYNAME, &data.value.ref, 
CMPI_ref);
-            CMSetProperty(refinstance, _LHSPROPERTYNAME, &reference, CMPI_ref);
-         }
-         
-         CMReturnInstance(results, refinstance);
-      }
-   }
+   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
+
+   /* Ensure the source class is not a virtual processor */
+   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
+      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", 
_XEN_DOMU_PROCESSOR_CLASS));
+      goto exit;
+   }
+
+   assocInfo.knownEndpoint = reference;
+   assocInfo.assocClassName = _ASSOCCLASS;
+   assocInfo.lhsClassName = _LHSCLASSNAME;
+   assocInfo.lhsNamespace = _LHSNAMESPACE;
+   assocInfo.lhsPropertyName = _LHSPROPERTYNAME;
+   assocInfo.rhsClassName = _RHSCLASSNAME;
+   assocInfo.rhsNamespace = _RHSNAMESPACE;
+   assocInfo.rhsPropertyName = _RHSPROPERTYNAME;
+   assocInfo.properties = properties;
+   assocInfo.opCode = _CMPI_ASSOC_OP_R;
+      
+   assocFilter.assocClass = assocClass;
+   assocFilter.resultClass = NULL;
+   assocFilter.role = role;
+   assocFilter.resultRole = NULL;
+
+   if (_CMPIGetTargetEndpoints(_BROKER, context, &assocInfo, &assocFilter, 
assocMatch, results, &status)) {
+      
+      _SBLIM_TRACE(1,("--- _CMPIGetTargetEndpoints() failed - %s", 
CMGetCharPtr(status.msg)));
+      goto exit;
+   }
+
+   CMReturnDone(results);
+
 exit:
    _SBLIM_RETURNSTATUS(status);
 }
diff -r 7c937c187b5e src/cmpiutil.c
--- a/src/cmpiutil.c    Fri Oct 20 13:20:15 2006 -0600
+++ b/src/cmpiutil.c    Mon Oct 23 11:17:36 2006 -0600
@@ -15,7 +15,7 @@
 //    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
USA
 // ============================================================================
 // Author:       Dr. Gareth S. Bestor <bestor@xxxxxxxxxx>
-// Contributors:
+// Contributors: Jim Fehlig <jfehlig@xxxxxxxxxx>
 // Summary:      Some useful utility functions
 // Description:
 //    TODO
@@ -30,6 +30,13 @@
 #include "cmpidt.h"
 #include "cmpift.h"
 #include "cmpimacs.h"
+
+#include "cmpiutil.h"
+#include "cmpitrace.h"
+
+/* Include common provider definitions */
+#include "provider_common.h"
+
 
 /* ------------------------------------------------------------------------- */
 
@@ -385,3 +392,150 @@ char * _CMPIValueToString ( CMPIData dat
    }
 }
 
+
+/*
+ * Get target endpoints for association defined by assocInfo.
+ * assocFilter defines any restrictions on the returned enpoints.
+ * matchFunc must be a non-null function that returns true (1) if
+ * potential target endpoints meet the requirements of defined in
+ * assocInfo and assocFilter.  Results are collected in the results
+ * out parameter.
+ * Returns non-zero on failure with additional error information
+ * available in out parameter rc.
+ */
+int _CMPIGetTargetEndpoints(CMPIBroker *mb,
+                            CMPIContext *context,
+                            _CMPIAssocIdentity *assocInfo,
+                            _CMPIAssocFilter *assocFilter,
+                            _CMPIAssocMatchFunc matchFunc,
+                            CMPIResult *results,
+                            CMPIStatus *status)
+{
+   char *sourceClass = CMGetCharPtr(CMGetClassName(assocInfo->knownEndpoint, 
NULL)); /* Class of the source reference object */
+   char *sourceNamespace = 
CMGetCharPtr(CMGetNameSpace(assocInfo->knownEndpoint, NULL)); /* Source 
namespace. */
+   char *targetclass; /* Class of the target object. */
+   char *targetnamespace; /* Namespace of target object. */
+   
+   if (assocInfo == NULL || assocFilter == NULL || matchFunc == NULL ||
+       results == NULL || status == NULL) {
+      _SBLIM_TRACE(1, ("--- Invalid parameter."));
+      CMSetStatus(status, CMPI_RC_ERR_INVALID_PARAMETER);
+      return 1;
+   }
+
+   /* Check that the requested association class, if any, is supported. */
+   if (assocFilter->assocClass != NULL) {
+      CMPIObjectPath *assoc = CMNewObjectPath(mb, sourceNamespace, 
assocInfo->assocClassName, NULL);
+      if (!CMClassPathIsA(mb, assoc, assocFilter->assocClass, NULL)) {
+         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring 
request."));
+         return 1;
+      }
+   }
+
+   /* Check that the reference matches the required role, if any. */
+   if ((assocFilter->role != NULL) && strcmp(assocFilter->role, sourceClass) 
!= 0) {
+      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring 
request."));
+      return 1;
+   }
+
+   /* Determine the target class from the source class. */
+   if (CMClassPathIsA(mb, assocInfo->knownEndpoint, assocInfo->lhsClassName, 
NULL)) {
+      targetclass = assocInfo->rhsClassName;
+      targetnamespace = assocInfo->rhsNamespace;
+   } else if (CMClassPathIsA(mb, assocInfo->knownEndpoint, 
assocInfo->rhsClassName, NULL)) {
+      targetclass = assocInfo->lhsClassName;
+      targetnamespace = assocInfo->lhsNamespace;
+   } else {
+      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
+      return 1;
+   } 
+   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
+   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
+
+   /* Create an object path for the result class. */
+   CMPIObjectPath *objectpath = CMNewObjectPath(mb, targetnamespace, 
targetclass, status);
+   if ((status->rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
+      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status->msg)));
+      CMSetStatusWithChars(mb, status, CMPI_RC_ERROR, "Cannot create new 
CMPIObjectPath");
+      return 1;
+   }
+
+   /* Get the list of all target class object paths from the CIMOM. */
+   CMPIEnumeration *objectpaths = CBEnumInstanceNames(mb, context, objectpath, 
status);
+   if ((status->rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
+      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", 
CMGetCharPtr(status->msg)));
+      CMSetStatusWithChars(mb, status, CMPI_RC_ERROR, "Cannot enumerate target 
class");
+      return 1;
+   }
+
+   /* Return all object paths that exactly match the target class and 
resultClass, if specified. */
+   while (CMHasNext(objectpaths, NULL)) {
+      CMPIData data = CMGetNext(objectpaths, NULL);
+      if (matchFunc(assocInfo, data.value.ref, assocFilter)) {
+         switch (assocInfo->opCode) {
+            case _CMPI_ASSOC_OP_AN:
+            {
+               CMReturnObjectPath(results, data.value.ref);
+               break;
+            }
+            
+            case _CMPI_ASSOC_OP_A:
+            {
+               CMPIInstance *inst = CBGetInstance(mb, context, data.value.ref, 
assocInfo->properties, status);
+               if ((status->rc == CMPI_RC_OK) && (!CMIsNullObject(inst))) {
+                  //CMSetNameSpace(op, targetnamespace);
+                  CMReturnInstance(results, inst);
+               }
+               break;
+            }
+            
+            case _CMPI_ASSOC_OP_RN:
+            {
+               CMPIObjectPath *refobjectpath = CMNewObjectPath(mb, 
XEN_INSTRUMENTATION_NS, assocInfo->assocClassName, status);
+               if ((status->rc != CMPI_RC_OK) || 
CMIsNullObject(refobjectpath)) {
+                  _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", 
CMGetCharPtr(status->msg)));
+                  CMSetStatusWithChars(mb, status, CMPI_RC_ERROR, "Cannot 
create new CMPIObjectPath");
+                  return 1;
+               }
+
+               /* Assign the references in the association appropriately. */
+               if (strcmp(sourceClass, assocInfo->rhsClassName) == 0) {
+                  CMAddKey(refobjectpath, assocInfo->rhsPropertyName, 
&(assocInfo->knownEndpoint), CMPI_ref);
+                  CMAddKey(refobjectpath, assocInfo->lhsPropertyName, 
&data.value.ref, CMPI_ref);
+               } else {
+                  CMAddKey(refobjectpath, assocInfo->rhsPropertyName, 
&data.value.ref, CMPI_ref);
+                  CMAddKey(refobjectpath, assocInfo->lhsPropertyName, 
&(assocInfo->knownEndpoint), CMPI_ref);
+               }
+               
+               CMReturnObjectPath(results, refobjectpath);
+               break;
+            }
+               
+            case _CMPI_ASSOC_OP_R:
+            {
+               CMPIInstance *refinstance = _CMNewInstance(mb, 
XEN_INSTRUMENTATION_NS, assocInfo->assocClassName, status);
+               if ((status->rc != CMPI_RC_OK) || CMIsNullObject(refinstance)) {
+                  _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", 
CMGetCharPtr(status->msg)));
+                  CMSetStatusWithChars(mb, status, CMPI_RC_ERROR, "Cannot 
create new CMPIInstance");
+                  return 1;
+               }
+               
+               /* Assign the references in the association appropriately. */
+               if (strcmp(sourceClass, assocInfo->rhsClassName) == 0) {
+                  CMSetProperty(refinstance, assocInfo->rhsPropertyName, 
&(assocInfo->knownEndpoint), CMPI_ref);
+                  CMSetProperty(refinstance, assocInfo->lhsPropertyName, 
&data.value.ref, CMPI_ref);
+               } else {
+                  CMSetProperty(refinstance, assocInfo->rhsPropertyName, 
&data.value.ref, CMPI_ref);
+                  CMSetProperty(refinstance, assocInfo->lhsPropertyName, 
&(assocInfo->knownEndpoint), CMPI_ref);
+               }
+               
+               CMReturnInstance(results, refinstance);
+               break;
+            }
+         }
+      }
+   }
+   
+   return 0;
+}
+
diff -r 7c937c187b5e src/cmpiutil.h
--- a/src/cmpiutil.h    Fri Oct 20 13:20:15 2006 -0600
+++ b/src/cmpiutil.h    Mon Oct 23 10:58:26 2006 -0600
@@ -15,7 +15,7 @@
 //    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
USA
 // ============================================================================
 // Author:       Dr. Gareth S. Bestor <bestor@xxxxxxxxxx>
-// Contributors:
+// Contributors: Jim Fehlig <jfehlig@xxxxxxxxxx>
 // Summary:      Some useful utility functions
 // Description:
 //    TODO
@@ -62,4 +62,77 @@ const char * _CMPITypeName ( CMPIType ty
 /* Return a string representation of a CMPI value. */
 char * _CMPIValueToString ( CMPIData data );
 
+
+/*
+ * An enumeration defining an association operation, e.g.
+ * AssociatorNames (AN), References (R), etc.
+ */
+enum _CMPIAssocOperation
+{
+   _CMPI_ASSOC_OP_AN,
+   _CMPI_ASSOC_OP_A,
+   _CMPI_ASSOC_OP_RN,
+   _CMPI_ASSOC_OP_R
+};
+
+
+/*
+ * A structure used to specify association meta-data, i.e. its
+ * identitiy.
+ */
+typedef struct _CMPIAssocIdentityStruct
+{
+   CMPIObjectPath *knownEndpoint;
+   char *assocClassName;
+   char *lhsClassName;
+   char *lhsNamespace;
+   char *lhsPropertyName;
+   char *rhsClassName;
+   char *rhsNamespace;
+   char *rhsPropertyName;
+   const char **properties;
+   enum _CMPIAssocOperation opCode;
+} _CMPIAssocIdentity;
+
+
+/*
+ * A structure used to specifiy filters for an association.
+ */
+typedef struct _CMPIAssocFilterStruct
+{
+   const char *assocClass;
+   const char *resultClass;
+   const char *role;
+   const char *resultRole;
+} _CMPIAssocFilter;
+
+
+/*
+ * Function prototype for an association match function.  Associations
+ * must implement a match function that returns true (1) if the
+ * object path op matches the association defined by assocInfo according
+ * to the restriction in assocFilter.
+ */
+typedef int (*_CMPIAssocMatchFunc) (_CMPIAssocIdentity *assocInfo, 
CMPIObjectPath *op, _CMPIAssocFilter *assocFilter);
+
+
+/*
+ * Get target endpoints for association defined by assocInfo.
+ * assocFilter defines any restrictions on the returned enpoints.
+ * matchFunc must be a non-null function that returns true (1) if
+ * potential target endpoints meet the requirements of defined in
+ * assocInfo and assocFilter.  Results are collected in the results
+ * out parameter.
+ * Returns non-zero on failure with additional error information
+ * available in out parameter rc.
+ */
+int _CMPIGetTargetEndpoints( CMPIBroker *mb,
+                             CMPIContext *context,
+                             _CMPIAssocIdentity *assocInfo,
+                             _CMPIAssocFilter *assocFilter,
+                             _CMPIAssocMatchFunc matchFunc,
+                             CMPIResult *results,
+                             CMPIStatus *rc );
+
+
 #endif /* _CMPIUTIL_H_ */
diff -r 7c937c187b5e src/provider_common.h.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/provider_common.h.in  Tue Oct 17 14:28:42 2006 -0600
@@ -0,0 +1,29 @@
+// Copyright (C) 2006 Novell, Inc.
+//
+//    This library is free software; you can redistribute it and/or
+//    modify it under the terms of the GNU Lesser General Public
+//    License as published by the Free Software Foundation; either
+//    version 2.1 of the License, or (at your option) any later version.
+//
+//    This library is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    Lesser General Public License for more details.
+//
+//    You should have received a copy of the GNU Lesser General Public
+//    License along with this library; if not, write to the Free Software
+//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
USA
+// ============================================================================
+// Authors:       Jim Fehlig, <jfehlig@xxxxxxxxxx>
+// Contributors:
+// Description:    Common provider definitions, macros, etc.
+// ============================================================================
+
+#if !defined(__PROVIDER_COMMON_H__)
+#define __PROVIDER_COMMON_H__
+
+#define HOST_INSTRUMENTATION_NS "@HOST_INSTRUMENTATION_NS@"
+#define HOST_INSTRUMENTATION_PREFIX "@HOST_INSTRUMENTATION_PREFIX@"
+#define XEN_INSTRUMENTATION_NS "root/cimv2"
+
+#endif /* __PROVIDER_COMMON_H__ */
diff -r 7c937c187b5e src/provider_common.h
--- a/src/provider_common.h     Fri Oct 20 13:20:15 2006 -0600
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-// Copyright (C) 2006 Novell, Inc.
-//
-//    This library is free software; you can redistribute it and/or
-//    modify it under the terms of the GNU Lesser General Public
-//    License as published by the Free Software Foundation; either
-//    version 2.1 of the License, or (at your option) any later version.
-//
-//    This library is distributed in the hope that it will be useful,
-//    but WITHOUT ANY WARRANTY; without even the implied warranty of
-//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//    Lesser General Public License for more details.
-//
-//    You should have received a copy of the GNU Lesser General Public
-//    License along with this library; if not, write to the Free Software
-//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
USA
-// ============================================================================
-// Authors:       
-// Contributors:
-// Description:    Common provider definitions, macros, etc.
-// ============================================================================
-
-#if !defined(__PROVIDER_COMMON_H__)
-#define __PROVIDER_COMMON_H__
-
-#define HOST_INSTRUMENTATION_NS "smash"
-
-
-#endif /* __PROVIDER_COMMON_H__ */
_______________________________________________
Xen-cim mailing list
Xen-cim@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-cim
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-cim] [RFC] Rework of association providers, Jim Fehlig <=