os-cmpi-xen

changeset 24:5ea0266dce26

Implement Xen_ProcessorPoolComponent association.
Also fixed bugs found in similar associations while testing ProcessorPoolComponent implementation.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author jfehlig@jfehlig3.provo.novell.com
date Tue Sep 26 15:08:04 2006 -0600 (2006-09-26)
parents 9bfa7666a504
children 16d625984bc4
files Makefile.am schema/Xen_ProcessorPoolComponent.mof schema/Xen_ProcessorPoolComponent.registration src/Makefile.am src/Xen_HostedComputerSystem.c src/Xen_HostedProcessorPool.c src/Xen_HostedVirtualSystemManagementService.c src/Xen_ProcessorPoolComponent.c
line diff
     1.1 --- a/Makefile.am	Tue Sep 05 09:53:07 2006 -0600
     1.2 +++ b/Makefile.am	Tue Sep 26 15:08:04 2006 -0600
     1.3 @@ -103,6 +103,7 @@ XEN_MOFS = \
     1.4  	schema/Xen_HostedMemoryPool.mof \
     1.5  	schema/Xen_ProcessorPool.mof \
     1.6  	schema/Xen_HostedProcessorPool.mof \
     1.7 +	schema/Xen_ProcessorPoolComponent.mof \
     1.8  	schema/Xen_CSSettingDataComponent.mof \
     1.9  	schema/Xen_ProcessorCapabilitiesSettingData.mof \
    1.10  	schema/Xen_MemoryCapabilitiesSettingData.mof \
    1.11 @@ -150,6 +151,7 @@ XEN_REGS = \
    1.12  	schema/Xen_HostedMemoryPool.registration \
    1.13  	schema/Xen_ProcessorPool.registration \
    1.14  	schema/Xen_HostedProcessorPool.registration \
    1.15 +	schema/Xen_ProcessorPoolComponent.registration \
    1.16  	schema/Xen_CSSettingDataComponent.registration \
    1.17  	schema/Xen_ProcessorCapabilitiesSettingData.registration \
    1.18  	schema/Xen_MemoryCapabilitiesSettingData.registration \
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/schema/Xen_ProcessorPoolComponent.mof	Tue Sep 26 15:08:04 2006 -0600
     2.3 @@ -0,0 +1,24 @@
     2.4 +// Copyright (c) 2006 IBM. All rights reserved.
     2.5 +
     2.6 +// *******************************************************************
     2.7 +// Associations
     2.8 +// *******************************************************************
     2.9 +
    2.10 +// ==================================================================
    2.11 +// Xen_HostedProcessorPool
    2.12 +// ==================================================================
    2.13 +[Association,
    2.14 + Provider ("cmpi:Xen_ProcessorPoolComponent"),
    2.15 + Description (
    2.16 +	"A class derived from CIM_ConcreteComponent to represent "
    2.17 +	"the collection of host CIM_Processors assigned to the "
    2.18 +	"processor pool.")]
    2.19 +class Xen_ProcessorPoolComponent : CIM_ConcreteComponent
    2.20 +{
    2.21 +   [Override("PartComponent")]
    2.22 +   CIM_Processor REF PartComponent;
    2.23 +
    2.24 +   [Override("GroupComponent")]
    2.25 +   Xen_ProcessorPool REF GroupComponent;
    2.26 +};
    2.27 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/schema/Xen_ProcessorPoolComponent.registration	Tue Sep 26 15:08:04 2006 -0600
     3.3 @@ -0,0 +1,2 @@
     3.4 +# Classname Namespace ProviderName ProviderModule ProviderTypes ...
     3.5 +Xen_ProcessorPoolComponent root/cimv2 Xen_ProcessorPoolComponent Xen_ProcessorPoolComponent association
     4.1 --- a/src/Makefile.am	Tue Sep 05 09:53:07 2006 -0600
     4.2 +++ b/src/Makefile.am	Tue Sep 26 15:08:04 2006 -0600
     4.3 @@ -111,6 +111,7 @@ provider_LTLIBRARIES = \
     4.4  	libXen_HostedMemoryPool.la \
     4.5  	libXen_ProcessorPool.la \
     4.6  	libXen_HostedProcessorPool.la \
     4.7 +	libXen_ProcessorPoolComponent.la \
     4.8  	libXen_CSSettingDataComponent.la \
     4.9  	libXen_ProcessorCapabilitiesSettingData.la \
    4.10  	libXen_MemoryCapabilitiesSettingData.la \
    4.11 @@ -240,6 +241,9 @@ libXen_ProcessorPool_la_CFLAGS = -I../
    4.12  libXen_HostedProcessorPool_la_SOURCES = Xen_HostedProcessorPool.c
    4.13  libXen_HostedProcessorPool_la_LIBADD = libXen_utils.la
    4.14  
    4.15 +libXen_ProcessorPoolComponent_la_SOURCES = Xen_ProcessorPoolComponent.c
    4.16 +libXen_ProcessorPoolComponent_la_LIBADD = libXen_utils.la
    4.17 +
    4.18  libXen_CSSettingDataComponent_la_SOURCES = Xen_CSSettingDataComponent.c
    4.19  libXen_CSSettingDataComponent_la_LIBADD = libXen_utils.la
    4.20  
     5.1 --- a/src/Xen_HostedComputerSystem.c	Tue Sep 05 09:53:07 2006 -0600
     5.2 +++ b/src/Xen_HostedComputerSystem.c	Tue Sep 26 15:08:04 2006 -0600
     5.3 @@ -159,8 +159,6 @@ static CMPIStatus AssociatorNames(
     5.4        CMPIData data = CMGetNext(objectpaths, NULL);
     5.5        char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
     5.6        
     5.7 -      _SBLIM_TRACE(2, ("--- returning object path = \"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
     5.8 -
     5.9        /* Ignore possible instances of source class. */
    5.10        if (strcmp(class,sourceclass) &&
    5.11            (resultClass == NULL || CMClassPathIsA(_BROKER, data.value.ref, resultClass, NULL))) {
     6.1 --- a/src/Xen_HostedProcessorPool.c	Tue Sep 05 09:53:07 2006 -0600
     6.2 +++ b/src/Xen_HostedProcessorPool.c	Tue Sep 26 15:08:04 2006 -0600
     6.3 @@ -58,6 +58,8 @@ static char * _RHSPROPERTYNAME = "GroupC
     6.4  static char * _LHSNAMESPACE = "root/cimv2";
     6.5  static char * _RHSNAMESPACE = "smash";
     6.6  
     6.7 +static char * _XEN_DOMU_CLASS = "Xen_ComputerSystem";
     6.8 +
     6.9  
    6.10  
    6.11  // ----------------------------------------------------------------------------
    6.12 @@ -111,6 +113,12 @@ static CMPIStatus AssociatorNames(
    6.13     _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
    6.14     _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
    6.15  
    6.16 +   /* Ensure the source class is not a virtual computer system */
    6.17 +   if (strcmp(sourceclass, _XEN_DOMU_CLASS) == 0) {
    6.18 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_CLASS));
    6.19 +      goto exit;
    6.20 +   }
    6.21 +
    6.22     /* Check that the requested association class, if any, is supported. */
    6.23     if (assocClass != NULL) {
    6.24        CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
    6.25 @@ -126,17 +134,17 @@ static CMPIStatus AssociatorNames(
    6.26        goto exit;
    6.27     }
    6.28  
    6.29 -   /* Determine the target class from the source class. */
    6.30 -   if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
    6.31 +   /* Determine the target class and namespace from the source class. */
    6.32 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
    6.33        targetclass = _RHSCLASSNAME;
    6.34        targetnamespace = _RHSNAMESPACE;
    6.35 -   } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
    6.36 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
    6.37        targetclass = _LHSCLASSNAME;
    6.38        targetnamespace = _LHSNAMESPACE;
    6.39     } else {
    6.40        _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
    6.41        goto exit;
    6.42 -   }
    6.43 +   } 
    6.44     _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
    6.45     _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
    6.46  
    6.47 @@ -159,10 +167,14 @@ static CMPIStatus AssociatorNames(
    6.48     /* Return all object paths that exactly match the target class and resultClass, if specified. */
    6.49     while (CMHasNext(objectpaths, NULL)) {
    6.50        CMPIData data = CMGetNext(objectpaths, NULL);
    6.51 +      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
    6.52 +
    6.53        _SBLIM_TRACE(2, ("--- got objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
    6.54  
    6.55 -      if (CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL) &&
    6.56 +      /* Ignore possible instances of source class. */
    6.57 +      if (strcmp(class,sourceclass) &&
    6.58            (resultClass == NULL || CMClassPathIsA(_BROKER, data.value.ref, resultClass, NULL))) {
    6.59 +
    6.60           CMReturnObjectPath(results, data.value.ref);
    6.61        }
    6.62     }
    6.63 @@ -205,6 +217,12 @@ static CMPIStatus Associators(
    6.64     _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
    6.65     _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
    6.66  
    6.67 +   /* Ensure the source class is not a virtual computer system */
    6.68 +   if (strcmp(sourceclass, _XEN_DOMU_CLASS) == 0) {
    6.69 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_CLASS));
    6.70 +      goto exit;
    6.71 +   }
    6.72 +
    6.73     /* Check that the requested association class, if any, is supported. */
    6.74     if (assocClass != NULL) {
    6.75        CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
    6.76 @@ -222,16 +240,16 @@ static CMPIStatus Associators(
    6.77     CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
    6.78  
    6.79     /* Determine the target class from the source class. */
    6.80 -   if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
    6.81 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
    6.82        targetclass = _RHSCLASSNAME;
    6.83        targetnamespace = _RHSNAMESPACE;
    6.84 -   } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
    6.85 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
    6.86        targetclass = _LHSCLASSNAME;
    6.87        targetnamespace = _LHSNAMESPACE;
    6.88     } else {
    6.89        _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
    6.90        goto exit;
    6.91 -   }
    6.92 +   } 
    6.93     _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
    6.94     _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
    6.95  
    6.96 @@ -255,10 +273,13 @@ static CMPIStatus Associators(
    6.97     while (CMHasNext(instances, NULL)) {
    6.98        CMPIData data = CMGetNext(instances, NULL);
    6.99        CMPIObjectPath *op = CMGetObjectPath(data.value.inst,NULL);
   6.100 -      CMSetNameSpace(op, targetnamespace);
   6.101 +      char *class = CMGetCharPtr(CMGetClassName(op, NULL));
   6.102 +
   6.103 +      //CMSetNameSpace(op, targetnamespace);
   6.104        _SBLIM_TRACE(2, ("--- got objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, op, NULL))));
   6.105  
   6.106 -      if (CMClassPathIsA(_BROKER, op, targetclass, NULL) &&
   6.107 +      /* Ignore possible instances of source class. */
   6.108 +      if (strcmp(class,sourceclass) &&
   6.109            (resultClass == NULL || CMClassPathIsA(_BROKER, op, resultClass, NULL))) {
   6.110           CMReturnInstance(results, data.value.inst);
   6.111        }
   6.112 @@ -297,6 +318,12 @@ static CMPIStatus ReferenceNames(
   6.113     _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   6.114     _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
   6.115  
   6.116 +   /* Ensure the source class is not a virtual computer system */
   6.117 +   if (strcmp(sourceclass, _XEN_DOMU_CLASS) == 0) {
   6.118 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_CLASS));
   6.119 +      goto exit;
   6.120 +   }
   6.121 +      
   6.122     /* Check that the requested association class, if any, is supported. */
   6.123     if (assocClass != NULL) {
   6.124        CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   6.125 @@ -313,18 +340,18 @@ static CMPIStatus ReferenceNames(
   6.126     }
   6.127  
   6.128     /* Determine the target class from the source class. */
   6.129 -   if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
   6.130 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   6.131        targetclass = _RHSCLASSNAME;
   6.132        targetnamespace = _RHSNAMESPACE;
   6.133        /* Refences of LHS class should always be in LHS namespace. */
   6.134        CMSetNameSpace(reference, _LHSNAMESPACE);
   6.135 -   } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
   6.136 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   6.137        targetclass = _LHSCLASSNAME;
   6.138        targetnamespace = _LHSNAMESPACE;
   6.139     } else {
   6.140        _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   6.141        goto exit;
   6.142 -   }
   6.143 +   } 
   6.144     _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   6.145     _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   6.146  
   6.147 @@ -348,7 +375,8 @@ static CMPIStatus ReferenceNames(
   6.148     while (CMHasNext(objectpaths, NULL)) {
   6.149        CMPIData data = CMGetNext(objectpaths, NULL);
   6.150  
   6.151 -      if (CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) {
   6.152 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
   6.153 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
   6.154           /* Create an object path for the association. Note that the association
   6.155            * objects should exist in 'virt namespace' not the host namespace.
   6.156            */
   6.157 @@ -404,6 +432,12 @@ static CMPIStatus References(
   6.158     _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   6.159     _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
   6.160  
   6.161 +   /* Ensure the source class is not a virtual computer system */
   6.162 +   if (strcmp(sourceclass, _XEN_DOMU_CLASS) == 0) {
   6.163 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_CLASS));
   6.164 +      goto exit;
   6.165 +   }
   6.166 +
   6.167     /* Check that the requested association class, if any, is supported. */
   6.168     if (assocClass != NULL) {
   6.169        CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   6.170 @@ -420,18 +454,18 @@ static CMPIStatus References(
   6.171     }
   6.172  
   6.173     /* Determine the target class from the source class. */
   6.174 -   if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
   6.175 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   6.176        targetclass = _RHSCLASSNAME;
   6.177        targetnamespace = _RHSNAMESPACE;
   6.178        /* Refences of LHS class should always be in LHS namespace. */
   6.179        CMSetNameSpace(reference, _LHSNAMESPACE);
   6.180 -   } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
   6.181 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   6.182        targetclass = _LHSCLASSNAME;
   6.183        targetnamespace = _LHSNAMESPACE;
   6.184     } else {
   6.185        _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   6.186        goto exit;
   6.187 -   }
   6.188 +   } 
   6.189     _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   6.190     _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   6.191  
   6.192 @@ -454,9 +488,9 @@ static CMPIStatus References(
   6.193     /* Return all object paths that exactly match the target class and resultClass, if specified. */
   6.194     while (CMHasNext(objectpaths, NULL)) {
   6.195        CMPIData data = CMGetNext(objectpaths, NULL);
   6.196 -      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
   6.197  
   6.198 -      if (CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) {
   6.199 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
   6.200 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
   6.201           /* Create an instance for the association. Note that the association
   6.202            * objects should exist in 'virt namespace' not the host namespace.
   6.203            */
   6.204 @@ -475,7 +509,7 @@ static CMPIStatus References(
   6.205              CMSetProperty(refinstance, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref);
   6.206              CMSetProperty(refinstance, _LHSPROPERTYNAME, &reference, CMPI_ref);
   6.207           }
   6.208 -
   6.209 +         
   6.210           CMReturnInstance(results, refinstance);
   6.211        }
   6.212     }
     7.1 --- a/src/Xen_HostedVirtualSystemManagementService.c	Tue Sep 05 09:53:07 2006 -0600
     7.2 +++ b/src/Xen_HostedVirtualSystemManagementService.c	Tue Sep 26 15:08:04 2006 -0600
     7.3 @@ -55,6 +55,11 @@ static char * _LHSCLASSNAME = "Xen_Virtu
     7.4  static char * _RHSCLASSNAME = "CIM_ComputerSystem";
     7.5  static char * _LHSPROPERTYNAME = "Dependent"; 
     7.6  static char * _RHSPROPERTYNAME = "Antecedent";
     7.7 +static char * _LHSNAMESPACE = "root/cimv2";
     7.8 +static char * _RHSNAMESPACE = "smash";
     7.9 +
    7.10 +static char * _XEN_DOMU_CLASS = "Xen_ComputerSystem";
    7.11 +
    7.12  
    7.13  // ----------------------------------------------------------------------------
    7.14  // AssociationCleanup()
    7.15 @@ -94,6 +99,7 @@ static CMPIStatus AssociatorNames(
    7.16     char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
    7.17     char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
    7.18     char *targetclass; 				/* Class of the target object(s). */
    7.19 +   char *targetnamespace;
    7.20  
    7.21     _SBLIM_ENTER("AssociatorNames");
    7.22     _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
    7.23 @@ -106,6 +112,12 @@ static CMPIStatus AssociatorNames(
    7.24     _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
    7.25     _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
    7.26  
    7.27 +   /* Ensure the source class is not a virtual computer system */
    7.28 +   if (strcmp(sourceclass, _XEN_DOMU_CLASS) == 0) {
    7.29 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_CLASS));
    7.30 +      goto exit;
    7.31 +   }
    7.32 +
    7.33     /* Check that the requested association class, if any, is supported. */
    7.34     if (assocClass != NULL) {
    7.35        CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
    7.36 @@ -124,16 +136,19 @@ static CMPIStatus AssociatorNames(
    7.37     /* Determine the target class from the source class. */
    7.38     if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
    7.39        targetclass = _RHSCLASSNAME;
    7.40 +      targetnamespace = _RHSNAMESPACE;
    7.41     } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
    7.42        targetclass = _LHSCLASSNAME;
    7.43 +      targetnamespace = _LHSNAMESPACE;
    7.44     } else {
    7.45        _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
    7.46        goto exit;
    7.47 -   }
    7.48 +   } 
    7.49     _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
    7.50 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
    7.51  
    7.52     /* Create an object path for the result class. */
    7.53 -   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, targetclass, &status);
    7.54 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
    7.55     if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
    7.56        _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
    7.57        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
    7.58 @@ -153,21 +168,10 @@ static CMPIStatus AssociatorNames(
    7.59        CMPIData data = CMGetNext(objectpaths, NULL);
    7.60        char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
    7.61        
    7.62 -      if (CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) {
    7.63 -         /* If the target class is CIM_ComputerSystem, ignore domUs (Xen_ComputerSystem). */
    7.64 -         if (strcmp(targetclass, _RHSCLASSNAME) == 0) {
    7.65 -            char *creationClassName;
    7.66 -            CMPIData keyVal = CMGetKey(data.value.ref, "CreationClassName", &status);
    7.67 -            if ((status.rc != CMPI_RC_OK) || CMIsNullValue(keyVal))
    7.68 -               continue;
    7.69 -            
    7.70 -            creationClassName = CMGetCharPtr(keyVal.value.string);
    7.71 -            if (strcmp(creationClassName, "Xen_ComputerSystem") == 0)
    7.72 -               continue;
    7.73 -         }
    7.74 -      }
    7.75 -      
    7.76 -      if ((resultClass == NULL) || (strcmp(class,resultClass) == 0)) {
    7.77 +      /* Ignore possible instances of source class. */
    7.78 +      if (strcmp(class,sourceclass) &&
    7.79 +          (resultClass == NULL || CMClassPathIsA(_BROKER, data.value.ref, resultClass, NULL))) {
    7.80 +
    7.81           CMReturnObjectPath(results, data.value.ref);
    7.82        }
    7.83     }
    7.84 @@ -197,6 +201,7 @@ static CMPIStatus Associators(
    7.85     char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
    7.86     char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
    7.87     char *targetclass;                           /* Class of the target object(s). */
    7.88 +   char *targetnamespace;
    7.89  
    7.90     _SBLIM_ENTER("Associators");
    7.91     _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
    7.92 @@ -209,6 +214,12 @@ static CMPIStatus Associators(
    7.93     _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
    7.94     _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
    7.95  
    7.96 +   /* Ensure the source class is not a virtual computer system */
    7.97 +   if (strcmp(sourceclass, _XEN_DOMU_CLASS) == 0) {
    7.98 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_CLASS));
    7.99 +      goto exit;
   7.100 +   }
   7.101 +
   7.102     /* Check that the requested association class, if any, is supported. */
   7.103     if (assocClass != NULL) {
   7.104        CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   7.105 @@ -228,57 +239,46 @@ static CMPIStatus Associators(
   7.106     /* Determine the target class from the source class. */
   7.107     if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   7.108        targetclass = _RHSCLASSNAME;
   7.109 +      targetnamespace = _RHSNAMESPACE;
   7.110     } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   7.111        targetclass = _LHSCLASSNAME;
   7.112 +      targetnamespace = _LHSNAMESPACE;
   7.113     } else {
   7.114        _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   7.115        goto exit;
   7.116 -   }
   7.117 +   } 
   7.118     _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   7.119 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   7.120  
   7.121     /* Create an object path for the result class. */
   7.122 -   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, targetclass, &status);
   7.123 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
   7.124     if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   7.125        _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   7.126        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   7.127        goto exit;
   7.128     }
   7.129  
   7.130 -   /* Get the list of all target class object paths from the CIMOM. */
   7.131 -   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
   7.132 -   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
   7.133 -      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
   7.134 +   /* Get the list of all target class instances from the CIMOM. */
   7.135 +   CMPIEnumeration * instances = CBEnumInstances(_BROKER, context, objectpath, NULL, &status);
   7.136 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instances)) {
   7.137 +      _SBLIM_TRACE(1,("--- CBEnumInstances() failed - %s", CMGetCharPtr(status.msg)));
   7.138        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
   7.139        goto exit;
   7.140     }
   7.141  
   7.142     /* Return all instances that exactly match the target class and resultClass, if specified. */
   7.143 -   while (CMHasNext(objectpaths, NULL)) {
   7.144 -      CMPIData data = CMGetNext(objectpaths, NULL);
   7.145 -      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
   7.146 -      _SBLIM_TRACE(2, ("--- got object path =\"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
   7.147 -      
   7.148 -      _SBLIM_TRACE(2, ("--- got class =\"%s\"", class));
   7.149 -      
   7.150 -      if (CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) {
   7.151 -         /* If the target class is CIM_ComputerSystem, ignore domUs (Xen_ComputerSystem). */
   7.152 -         if (strcmp(targetclass, _RHSCLASSNAME) == 0) {
   7.153 -            char *creationClassName;
   7.154 -            CMPIData keyVal = CMGetKey(data.value.ref, "CreationClassName", &status);
   7.155 -            if ((status.rc != CMPI_RC_OK) || CMIsNullValue(keyVal))
   7.156 -               continue;
   7.157 -            
   7.158 -            creationClassName = CMGetCharPtr(keyVal.value.string);
   7.159 -            if (strcmp(creationClassName, "Xen_ComputerSystem") == 0)
   7.160 -               continue;
   7.161 -         }
   7.162 -      }
   7.163 -      
   7.164 -      if ((resultClass == NULL) || (strcmp(class,resultClass) == 0)) {
   7.165 -         /* Found an object that meets the criteria.  Get the instance. */
   7.166 -         CMPIInstance *inst = CBGetInstance(_BROKER, context, data.value.ref, NULL, &status);
   7.167 -         if ((status.rc == CMPI_RC_OK) && !CMIsNullObject(inst))
   7.168 -            CMReturnInstance(results, inst);
   7.169 +   while (CMHasNext(instances, NULL)) {
   7.170 +      CMPIData data = CMGetNext(instances, NULL);
   7.171 +      CMPIObjectPath *op = CMGetObjectPath(data.value.inst,NULL);
   7.172 +      char *class = CMGetCharPtr(CMGetClassName(op, NULL));
   7.173 +
   7.174 +      //CMSetNameSpace(op, targetnamespace);
   7.175 +      _SBLIM_TRACE(2, ("--- got objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, op, NULL))));
   7.176 +
   7.177 +      /* Ignore possible instances of source class. */
   7.178 +      if (strcmp(class,sourceclass) &&
   7.179 +          (resultClass == NULL || CMClassPathIsA(_BROKER, op, resultClass, NULL))) {
   7.180 +         CMReturnInstance(results, data.value.inst);
   7.181        }
   7.182     }
   7.183  
   7.184 @@ -304,6 +304,7 @@ static CMPIStatus ReferenceNames(
   7.185     char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   7.186     char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
   7.187     char *targetclass;                           /* Class of the target object(s). */
   7.188 +   char *targetnamespace;
   7.189  
   7.190     _SBLIM_ENTER("ReferenceNames");
   7.191     _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   7.192 @@ -314,6 +315,12 @@ static CMPIStatus ReferenceNames(
   7.193     _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   7.194     _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
   7.195  
   7.196 +   /* Ensure the source class is not a virtual computer system */
   7.197 +   if (strcmp(sourceclass, _XEN_DOMU_CLASS) == 0) {
   7.198 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_CLASS));
   7.199 +      goto exit;
   7.200 +   }
   7.201 +
   7.202     /* Check that the requested association class, if any, is supported. */
   7.203     if (assocClass != NULL) {
   7.204        CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   7.205 @@ -332,16 +339,21 @@ static CMPIStatus ReferenceNames(
   7.206     /* Determine the target class from the source class. */
   7.207     if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   7.208        targetclass = _RHSCLASSNAME;
   7.209 +      targetnamespace = _RHSNAMESPACE;
   7.210 +      /* Refences of LHS class should always be in LHS namespace. */
   7.211 +      CMSetNameSpace(reference, _LHSNAMESPACE);
   7.212     } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   7.213        targetclass = _LHSCLASSNAME;
   7.214 +      targetnamespace = _LHSNAMESPACE;
   7.215     } else {
   7.216        _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   7.217        goto exit;
   7.218 -   }
   7.219 +   } 
   7.220     _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   7.221 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   7.222  
   7.223     /* Create an object path for the result class. */
   7.224 -   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, targetclass, &status);
   7.225 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
   7.226     if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   7.227        _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   7.228        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   7.229 @@ -359,21 +371,13 @@ static CMPIStatus ReferenceNames(
   7.230     /* Return all object paths that exactly match the target class and resultClass, if specified. */
   7.231     while (CMHasNext(objectpaths, NULL)) {
   7.232        CMPIData data = CMGetNext(objectpaths, NULL);
   7.233 -      if(CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) {
   7.234 -         /* If the target class is CIM_ComputerSystem, ignore domUs (Xen_ComputerSystem). */
   7.235 -         if (strcmp(targetclass, _RHSCLASSNAME) == 0) {
   7.236 -            char *creationClassName;
   7.237 -            CMPIData keyVal = CMGetKey(data.value.ref, "CreationClassName", &status);
   7.238 -            if ((status.rc != CMPI_RC_OK) || CMIsNullValue(keyVal))
   7.239 -               continue;
   7.240 -            
   7.241 -            creationClassName = CMGetCharPtr(keyVal.value.string);
   7.242 -            if (strcmp(creationClassName, "Xen_ComputerSystem") == 0)
   7.243 -               continue;
   7.244 -         }
   7.245  
   7.246 -         /* Create an object path for the association. */
   7.247 -         CMPIObjectPath * refobjectpath = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, &status);
   7.248 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
   7.249 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
   7.250 +         /* Create an object path for the association. Note that the association
   7.251 +          * objects should exist in 'virt namespace' not the host namespace.
   7.252 +          */
   7.253 +         CMPIObjectPath * refobjectpath = CMNewObjectPath(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, &status);
   7.254           if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refobjectpath)) {
   7.255              _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   7.256              CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   7.257 @@ -414,6 +418,7 @@ static CMPIStatus References(
   7.258     char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   7.259     char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
   7.260     char *targetclass;                           /* Class of the target object(s). */
   7.261 +   char *targetnamespace;
   7.262  
   7.263     _SBLIM_ENTER("References");
   7.264     _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   7.265 @@ -424,6 +429,12 @@ static CMPIStatus References(
   7.266     _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   7.267     _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
   7.268  
   7.269 +   /* Ensure the source class is not a virtual computer system */
   7.270 +   if (strcmp(sourceclass, _XEN_DOMU_CLASS) == 0) {
   7.271 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_CLASS));
   7.272 +      goto exit;
   7.273 +   }
   7.274 +
   7.275     /* Check that the requested association class, if any, is supported. */
   7.276     if (assocClass != NULL) {
   7.277        CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   7.278 @@ -442,16 +453,21 @@ static CMPIStatus References(
   7.279     /* Determine the target class from the source class. */
   7.280     if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   7.281        targetclass = _RHSCLASSNAME;
   7.282 +      targetnamespace = _RHSNAMESPACE;
   7.283 +      /* Refences of LHS class should always be in LHS namespace. */
   7.284 +      CMSetNameSpace(reference, _LHSNAMESPACE);
   7.285     } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   7.286        targetclass = _LHSCLASSNAME;
   7.287 +      targetnamespace = _LHSNAMESPACE;
   7.288     } else {
   7.289        _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   7.290        goto exit;
   7.291 -   }
   7.292 +   } 
   7.293     _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   7.294 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   7.295  
   7.296     /* Create an object path for the result class. */
   7.297 -   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, targetclass, &status);
   7.298 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
   7.299     if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   7.300        _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   7.301        CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   7.302 @@ -469,21 +485,13 @@ static CMPIStatus References(
   7.303     /* Return all object paths that exactly match the target class and resultClass, if specified. */
   7.304     while (CMHasNext(objectpaths, NULL)) {
   7.305        CMPIData data = CMGetNext(objectpaths, NULL);
   7.306 -      if(CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) {
   7.307 -         /* If the target class is CIM_ComputerSystem, ignore domUs (Xen_ComputerSystem). */
   7.308 -         if (strcmp(targetclass, _RHSCLASSNAME) == 0) {
   7.309 -            char *creationClassName;
   7.310 -            CMPIData keyVal = CMGetKey(data.value.ref, "CreationClassName", &status);
   7.311 -            if ((status.rc != CMPI_RC_OK) || CMIsNullValue(keyVal))
   7.312 -               continue;
   7.313 -            
   7.314 -            creationClassName = CMGetCharPtr(keyVal.value.string);
   7.315 -            if (strcmp(creationClassName, "Xen_ComputerSystem") == 0)
   7.316 -               continue;
   7.317 -         }
   7.318  
   7.319 -         /* Create an instance for the association. */
   7.320 -         CMPIInstance * refinstance = _CMNewInstance(_BROKER, namespace, _ASSOCCLASS, &status);
   7.321 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
   7.322 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
   7.323 +         /* Create an instance for the association. Note that the association
   7.324 +          * objects should exist in 'virt namespace' not the host namespace.
   7.325 +          */
   7.326 +         CMPIInstance * refinstance = _CMNewInstance(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, &status);
   7.327           if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refinstance)) {
   7.328              _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   7.329              CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   7.330 @@ -498,7 +506,7 @@ static CMPIStatus References(
   7.331              CMSetProperty(refinstance, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref);
   7.332              CMSetProperty(refinstance, _LHSPROPERTYNAME, &reference, CMPI_ref);
   7.333           }
   7.334 -
   7.335 +         
   7.336           CMReturnInstance(results, refinstance);
   7.337        }
   7.338     }
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/Xen_ProcessorPoolComponent.c	Tue Sep 26 15:08:04 2006 -0600
     8.3 @@ -0,0 +1,545 @@
     8.4 +// Copyright (C) 2006 IBM Corporation
     8.5 +//
     8.6 +//    This library is free software; you can redistribute it and/or
     8.7 +//    modify it under the terms of the GNU Lesser General Public
     8.8 +//    License as published by the Free Software Foundation; either
     8.9 +//    version 2.1 of the License, or (at your option) any later version.
    8.10 +//
    8.11 +//    This library is distributed in the hope that it will be useful,
    8.12 +//    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.13 +//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.14 +//    Lesser General Public License for more details.
    8.15 +//
    8.16 +//    You should have received a copy of the GNU Lesser General Public
    8.17 +//    License along with this library; if not, write to the Free Software
    8.18 +//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    8.19 +// ============================================================================
    8.20 +// Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
    8.21 +// Contributors:
    8.22 +// Description:
    8.23 +// ============================================================================
    8.24 +
    8.25 +#include <string.h>
    8.26 +
    8.27 +/* Include the required CMPI data types, function headers, and macros */
    8.28 +#include "cmpidt.h"
    8.29 +#include "cmpift.h"
    8.30 +#include "cmpimacs.h"
    8.31 +
    8.32 +
    8.33 +// ----------------------------------------------------------------------------
    8.34 +// COMMON GLOBAL VARIABLES
    8.35 +// ----------------------------------------------------------------------------
    8.36 +
    8.37 +/* Handle to the CIM broker. Initialized when the provider lib is loaded. */
    8.38 +static CMPIBroker *_BROKER;
    8.39 +
    8.40 +/* Include utility functions */
    8.41 +#include "cmpiutil.h"
    8.42 +
    8.43 +/* Include _SBLIM_TRACE() logging support */
    8.44 +#include "cmpitrace.h"
    8.45 +
    8.46 +
    8.47 +// ============================================================================
    8.48 +// CMPI ASSOCIATION PROVIDER FUNCTION TABLE
    8.49 +// ============================================================================
    8.50 +
    8.51 +// ----------------------------------------------------------------------------
    8.52 +// Info for the class supported by the association provider
    8.53 +// ----------------------------------------------------------------------------
    8.54 +                                                                                                                                 
    8.55 +/* Name of the left and right hand side classes of this association. */
    8.56 +static char * _ASSOCCLASS = "Xen_ProcessorPoolComponent";
    8.57 +static char * _LHSCLASSNAME = "Xen_ProcessorPool";
    8.58 +static char * _RHSCLASSNAME = "CIM_Processor";
    8.59 +static char * _LHSPROPERTYNAME = "GroupComponent"; 
    8.60 +static char * _RHSPROPERTYNAME = "PartComponent";
    8.61 +static char * _LHSNAMESPACE = "root/cimv2";
    8.62 +static char * _RHSNAMESPACE = "smash";
    8.63 +
    8.64 +static char * _XEN_DOMU_PROCESSOR_CLASS = "Xen_Processor";
    8.65 +
    8.66 +
    8.67 +// ----------------------------------------------------------------------------
    8.68 +// AssociationCleanup()
    8.69 +// Perform any necessary cleanup immediately before this provider is unloaded.
    8.70 +// ----------------------------------------------------------------------------
    8.71 +static CMPIStatus AssociationCleanup(
    8.72 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
    8.73 +		CMPIContext * context)		/* [in] Additional context info, if any. */
    8.74 +{
    8.75 +   CMPIStatus status = { CMPI_RC_OK, NULL };	/* Return status of CIM operations. */
    8.76 +
    8.77 +   _SBLIM_ENTER("AssociationCleanup");
    8.78 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
    8.79 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
    8.80 +
    8.81 +   /* Nothing needs to be done for cleanup. */
    8.82 +
    8.83 +exit:
    8.84 +   _SBLIM_RETURNSTATUS(status);
    8.85 +}
    8.86 +
    8.87 +
    8.88 +// ----------------------------------------------------------------------------
    8.89 +// AssociatorNames()
    8.90 +// ----------------------------------------------------------------------------
    8.91 +static CMPIStatus AssociatorNames(
    8.92 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
    8.93 +		CMPIContext * context,		/* [in] Additional context info, if any. */
    8.94 +		CMPIResult * results,		/* [out] Results of this operation. */
    8.95 +		CMPIObjectPath * reference,	/* [in] Contains source namespace, classname and object path. */
    8.96 +		const char * assocClass,
    8.97 +		const char * resultClass,
    8.98 +		const char * role,
    8.99 +		const char * resultRole)
   8.100 +{
   8.101 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
   8.102 +   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   8.103 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
   8.104 +   char *targetclass; 				/* Class of the target object(s). */
   8.105 +   char *targetnamespace;
   8.106 +
   8.107 +   _SBLIM_ENTER("AssociatorNames");
   8.108 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   8.109 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   8.110 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   8.111 +   _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
   8.112 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
   8.113 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
   8.114 +   _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
   8.115 +   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   8.116 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
   8.117 +
   8.118 +   /* Ensure the source class is not a virtual processor */
   8.119 +   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
   8.120 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_PROCESSOR_CLASS));
   8.121 +      goto exit;
   8.122 +   }
   8.123 +
   8.124 +   /* Check that the requested association class, if any, is supported. */
   8.125 +   if (assocClass != NULL) {
   8.126 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   8.127 +      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
   8.128 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
   8.129 +         goto exit;
   8.130 +      }
   8.131 +   }
   8.132 +
   8.133 +   /* Check that the reference matches the required role, if any. */
   8.134 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
   8.135 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
   8.136 +      goto exit;
   8.137 +   }
   8.138 +
   8.139 +   /* Determine the target class from the source class. */
   8.140 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   8.141 +      targetclass = _RHSCLASSNAME;
   8.142 +      targetnamespace = _RHSNAMESPACE;
   8.143 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   8.144 +      targetclass = _LHSCLASSNAME;
   8.145 +      targetnamespace = _LHSNAMESPACE;
   8.146 +   } else {
   8.147 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   8.148 +      goto exit;
   8.149 +   } 
   8.150 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   8.151 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   8.152 +
   8.153 +   /* Create an object path for the result class. */
   8.154 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
   8.155 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   8.156 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   8.157 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   8.158 +      goto exit;
   8.159 +   }
   8.160 +
   8.161 +   /* Get the list of all target class object paths from the CIMOM. */
   8.162 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
   8.163 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
   8.164 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
   8.165 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
   8.166 +      goto exit;
   8.167 +   }
   8.168 +
   8.169 +   /* Return all object paths that exactly match the target class and resultClass, if specified. */
   8.170 +   while (CMHasNext(objectpaths, NULL)) {
   8.171 +      CMPIData data = CMGetNext(objectpaths, NULL);
   8.172 +      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
   8.173 +
   8.174 +      _SBLIM_TRACE(2, ("--- got objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
   8.175 +
   8.176 +      /* Ignore possible instances of source class. */
   8.177 +      if (strcmp(class,sourceclass) &&
   8.178 +          (resultClass == NULL || CMClassPathIsA(_BROKER, data.value.ref, resultClass, NULL))) {
   8.179 +
   8.180 +         CMReturnObjectPath(results, data.value.ref);
   8.181 +      }
   8.182 +   }
   8.183 +
   8.184 +   CMReturnDone(results);
   8.185 +
   8.186 +exit:
   8.187 +   _SBLIM_RETURNSTATUS(status);
   8.188 +}
   8.189 +
   8.190 +
   8.191 +// ----------------------------------------------------------------------------
   8.192 +// Associators()
   8.193 +// ----------------------------------------------------------------------------
   8.194 +static CMPIStatus Associators(
   8.195 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
   8.196 +		CMPIContext * context,		/* [in] Additional context info, if any. */
   8.197 +		CMPIResult * results,		/* [out] Results of this operation. */
   8.198 +		CMPIObjectPath * reference,	/* [in] Contains the source namespace, classname and object path. */
   8.199 +		const char *assocClass,
   8.200 +		const char *resultClass,
   8.201 +		const char *role,
   8.202 +		const char *resultRole,
   8.203 +		char ** properties)		/* [in] List of desired properties (NULL=all). */
   8.204 +{
   8.205 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
   8.206 +   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   8.207 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
   8.208 +   char *targetclass;                           /* Class of the target object(s). */
   8.209 +   char *targetnamespace;
   8.210 +
   8.211 +   _SBLIM_ENTER("Associators");
   8.212 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   8.213 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   8.214 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   8.215 +   _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
   8.216 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
   8.217 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
   8.218 +   _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
   8.219 +   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   8.220 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
   8.221 +
   8.222 +   /* Ensure the source class is not a virtual processor */
   8.223 +   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
   8.224 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_PROCESSOR_CLASS));
   8.225 +      goto exit;
   8.226 +   }
   8.227 +
   8.228 +   /* Check that the requested association class, if any, is supported. */
   8.229 +   if (assocClass != NULL) {
   8.230 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   8.231 +      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
   8.232 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
   8.233 +         goto exit;
   8.234 +      }
   8.235 +   }
   8.236 +
   8.237 +   /* Check that the reference matches the required role, if any. */
   8.238 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
   8.239 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
   8.240 +      goto exit;
   8.241 +   }
   8.242 +   CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL);
   8.243 +
   8.244 +   /* Determine the target class from the source class. */
   8.245 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   8.246 +      targetclass = _RHSCLASSNAME;
   8.247 +      targetnamespace = _RHSNAMESPACE;
   8.248 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   8.249 +      targetclass = _LHSCLASSNAME;
   8.250 +      targetnamespace = _LHSNAMESPACE;
   8.251 +   } else {
   8.252 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   8.253 +      goto exit;
   8.254 +   } 
   8.255 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   8.256 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   8.257 +
   8.258 +   /* Create an object path for the result class. */
   8.259 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
   8.260 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   8.261 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   8.262 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   8.263 +      goto exit;
   8.264 +   }
   8.265 +
   8.266 +   /* Get the list of all target class instances from the CIMOM. */
   8.267 +   CMPIEnumeration * instances = CBEnumInstances(_BROKER, context, objectpath, NULL, &status);
   8.268 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instances)) {
   8.269 +      _SBLIM_TRACE(1,("--- CBEnumInstances() failed - %s", CMGetCharPtr(status.msg)));
   8.270 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
   8.271 +      goto exit;
   8.272 +   }
   8.273 +
   8.274 +   /* Return all instances that exactly match the target class and resultClass, if specified. */
   8.275 +   while (CMHasNext(instances, NULL)) {
   8.276 +      CMPIData data = CMGetNext(instances, NULL);
   8.277 +      CMPIObjectPath *op = CMGetObjectPath(data.value.inst,NULL);
   8.278 +      char *class = CMGetCharPtr(CMGetClassName(op, NULL));
   8.279 +
   8.280 +      CMSetNameSpace(op, targetnamespace);
   8.281 +      _SBLIM_TRACE(2, ("--- got objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, op, NULL))));
   8.282 +      _SBLIM_TRACE(2, ("--- got class=\"%s\"", class));
   8.283 +
   8.284 +      /* Ignore possible instances of source class. */
   8.285 +      if (strcmp(class,sourceclass) &&
   8.286 +          (resultClass == NULL || CMClassPathIsA(_BROKER, op, resultClass, NULL))) {
   8.287 +         _SBLIM_TRACE(2, ("--- returning instance"));
   8.288 +         CMReturnInstance(results, data.value.inst);
   8.289 +      }
   8.290 +   }
   8.291 +   
   8.292 +   CMReturnDone(results);
   8.293 +
   8.294 +exit:
   8.295 +   _SBLIM_RETURNSTATUS(status);
   8.296 +}
   8.297 +
   8.298 +
   8.299 +// ----------------------------------------------------------------------------
   8.300 +// ReferenceNames()
   8.301 +// ----------------------------------------------------------------------------
   8.302 +static CMPIStatus ReferenceNames(
   8.303 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
   8.304 +		CMPIContext * context,		/* [in] Additional context info, if any. */
   8.305 +		CMPIResult * results,		/* [out] Results of this operation. */
   8.306 +		CMPIObjectPath * reference,	/* [in] Contains the source namespace, classname and object path. */
   8.307 +		const char *assocClass, 
   8.308 +		const char *role)
   8.309 +{
   8.310 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
   8.311 +   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   8.312 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
   8.313 +   char *targetclass;                           /* Class of the target object(s). */
   8.314 +   char *targetnamespace;
   8.315 +
   8.316 +   _SBLIM_ENTER("ReferenceNames");
   8.317 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   8.318 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   8.319 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   8.320 +   _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
   8.321 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
   8.322 +   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   8.323 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
   8.324 +
   8.325 +   /* Ensure the source class is not a virtual processor */
   8.326 +   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
   8.327 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_PROCESSOR_CLASS));
   8.328 +      goto exit;
   8.329 +   }
   8.330 +
   8.331 +   /* Check that the requested association class, if any, is supported. */
   8.332 +   if (assocClass != NULL) {
   8.333 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   8.334 +      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
   8.335 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
   8.336 +         goto exit;
   8.337 +      }
   8.338 +   }
   8.339 +
   8.340 +   /* Check that the reference matches the required role, if any. */
   8.341 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
   8.342 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
   8.343 +      goto exit;
   8.344 +   }
   8.345 +
   8.346 +   /* Determine the target class from the source class. */
   8.347 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   8.348 +      targetclass = _RHSCLASSNAME;
   8.349 +      targetnamespace = _RHSNAMESPACE;
   8.350 +      /* Refences of LHS class should always be in LHS namespace. */
   8.351 +      CMSetNameSpace(reference, _LHSNAMESPACE);
   8.352 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   8.353 +      targetclass = _LHSCLASSNAME;
   8.354 +      targetnamespace = _LHSNAMESPACE;
   8.355 +   } else {
   8.356 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   8.357 +      goto exit;
   8.358 +   } 
   8.359 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   8.360 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   8.361 +
   8.362 +   /* Create an object path for the result class. */
   8.363 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
   8.364 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   8.365 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   8.366 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   8.367 +      goto exit;
   8.368 +   }
   8.369 +
   8.370 +   /* Get the list of all target class object paths from the CIMOM. */
   8.371 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
   8.372 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
   8.373 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
   8.374 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
   8.375 +      goto exit;
   8.376 +   }
   8.377 +
   8.378 +   /* Return all object paths that exactly match the target class and resultClass, if specified. */
   8.379 +   while (CMHasNext(objectpaths, NULL)) {
   8.380 +      CMPIData data = CMGetNext(objectpaths, NULL);
   8.381 +
   8.382 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
   8.383 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
   8.384 +         /* Create an object path for the association. Note that the association
   8.385 +          * objects should exist in 'virt namespace' not the host namespace.
   8.386 +          */
   8.387 +         CMPIObjectPath * refobjectpath = CMNewObjectPath(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, &status);
   8.388 +         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refobjectpath)) {
   8.389 +            _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   8.390 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   8.391 +            goto exit;
   8.392 +         }
   8.393 +
   8.394 +         /* Assign the references in the association appropriately. */
   8.395 +         if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
   8.396 +            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &reference, CMPI_ref);
   8.397 +            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &data.value.ref, CMPI_ref);
   8.398 +         } else {
   8.399 +            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref);
   8.400 +            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &reference, CMPI_ref);
   8.401 +         }
   8.402 +
   8.403 +         CMReturnObjectPath(results, refobjectpath);
   8.404 +      }
   8.405 +   }
   8.406 +
   8.407 +exit:
   8.408 +   _SBLIM_RETURNSTATUS(status);
   8.409 +}
   8.410 +
   8.411 +
   8.412 +// ----------------------------------------------------------------------------
   8.413 +// References()
   8.414 +// ----------------------------------------------------------------------------
   8.415 +static CMPIStatus References(
   8.416 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
   8.417 +		CMPIContext * context,		/* [in] Additional context info, if any. */
   8.418 +		CMPIResult * results,		/* [out] Results of this operation. */
   8.419 +		CMPIObjectPath * reference,	/* [in] Contains the namespace, classname and desired object path. */
   8.420 +		const char *assocClass,
   8.421 +		const char *role,
   8.422 +		char **properties)		/* [in] List of desired properties (NULL=all). */
   8.423 +{
   8.424 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
   8.425 +   char *namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   8.426 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
   8.427 +   char *targetclass;                           /* Class of the target object(s). */
   8.428 +   char *targetnamespace;
   8.429 +
   8.430 +   _SBLIM_ENTER("References");
   8.431 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   8.432 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   8.433 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   8.434 +   _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
   8.435 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
   8.436 +   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   8.437 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
   8.438 +
   8.439 +   /* Ensure the source class is not a virtual processor */
   8.440 +   if (strcmp(sourceclass, _XEN_DOMU_PROCESSOR_CLASS) == 0) {
   8.441 +      _SBLIM_TRACE(2, ("--- Ignoring source class %s.", _XEN_DOMU_PROCESSOR_CLASS));
   8.442 +      goto exit;
   8.443 +   }
   8.444 +
   8.445 +   /* Check that the requested association class, if any, is supported. */
   8.446 +   if (assocClass != NULL) {
   8.447 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, NULL);
   8.448 +      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
   8.449 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
   8.450 +         goto exit;
   8.451 +      }
   8.452 +   }
   8.453 +
   8.454 +   /* Check that the reference matches the required role, if any. */
   8.455 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
   8.456 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
   8.457 +      goto exit;
   8.458 +   }
   8.459 +
   8.460 +   /* Determine the target class from the source class. */
   8.461 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
   8.462 +      targetclass = _RHSCLASSNAME;
   8.463 +      targetnamespace = _RHSNAMESPACE;
   8.464 +      /* Refences of LHS class should always be in LHS namespace. */
   8.465 +      CMSetNameSpace(reference, _LHSNAMESPACE);
   8.466 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
   8.467 +      targetclass = _LHSCLASSNAME;
   8.468 +      targetnamespace = _LHSNAMESPACE;
   8.469 +   } else {
   8.470 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
   8.471 +      goto exit;
   8.472 +   } 
   8.473 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
   8.474 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
   8.475 +
   8.476 +   /* Create an object path for the result class. */
   8.477 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
   8.478 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   8.479 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   8.480 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
   8.481 +      goto exit;
   8.482 +   }
   8.483 +
   8.484 +   /* Get the list of all target class object paths from the CIMOM. */
   8.485 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
   8.486 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
   8.487 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
   8.488 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
   8.489 +      goto exit;
   8.490 +   }
   8.491 +
   8.492 +   /* Return all object paths that exactly match the target class and resultClass, if specified. */
   8.493 +   while (CMHasNext(objectpaths, NULL)) {
   8.494 +      CMPIData data = CMGetNext(objectpaths, NULL);
   8.495 +
   8.496 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
   8.497 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
   8.498 +         /* Create an instance for the association. Note that the association
   8.499 +          * objects should exist in 'virt namespace' not the host namespace.
   8.500 +          */
   8.501 +         CMPIInstance * refinstance = _CMNewInstance(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, &status);
   8.502 +         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refinstance)) {
   8.503 +            _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   8.504 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   8.505 +            goto exit;
   8.506 +         }
   8.507 +
   8.508 +         /* Assign the references in the association appropriately. */
   8.509 +         if (strcmp(sourceclass, _RHSCLASSNAME) == 0) {
   8.510 +            CMSetProperty(refinstance, _RHSPROPERTYNAME, &reference, CMPI_ref);
   8.511 +            CMSetProperty(refinstance, _LHSPROPERTYNAME, &data.value.ref, CMPI_ref);
   8.512 +         } else {
   8.513 +            CMSetProperty(refinstance, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref);
   8.514 +            CMSetProperty(refinstance, _LHSPROPERTYNAME, &reference, CMPI_ref);
   8.515 +         }
   8.516 +         
   8.517 +         CMReturnInstance(results, refinstance);
   8.518 +      }
   8.519 +   }
   8.520 +exit:
   8.521 +   _SBLIM_RETURNSTATUS(status);
   8.522 +}
   8.523 +
   8.524 +
   8.525 +// ----------------------------------------------------------------------------
   8.526 +// AssociationInitialize()
   8.527 +// Perform any necessary initialization immediately after this provider is
   8.528 +// first loaded.
   8.529 +// ----------------------------------------------------------------------------
   8.530 +static void AssociationInitialize(
   8.531 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
   8.532 +		CMPIContext * context)		/* [in] Additional context info, if any. */
   8.533 +{
   8.534 +   _SBLIM_ENTER("AssociationInitialize");
   8.535 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   8.536 +   //   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   8.537 +
   8.538 +   /* Nothing needs to be done to initialize this provider */
   8.539 +
   8.540 +exit:
   8.541 +   _SBLIM_RETURN();
   8.542 +}
   8.543 +
   8.544 +
   8.545 +// ============================================================================
   8.546 +// CMPI ASSOCIATION PROVIDER FUNCTION TABLE SETUP
   8.547 +// ============================================================================
   8.548 +CMAssociationMIStub( , Xen_ProcessorPoolComponent, _BROKER, AssociationInitialize(&mi, ctx));