diff -r 17b5de70c6ab schema/Xen_ComputerSystem.mof --- a/schema/Xen_ComputerSystem.mof Thu Apr 27 22:26:52 2006 +++ b/schema/Xen_ComputerSystem.mof Wed May 17 16:09:04 2006 @@ -7,7 +7,8 @@ Description ( "A class derived from CIM_VirtualComputerSystem to represent " "the Xen virtual machines/domains running on the system.")] -class Xen_ComputerSystem : CIM_VirtualComputerSystem +class Xen_ComputerSystem : CIM_ComputerSystem +//Changed from VirtualComputerSystem since VirtualComputerSystem is deprecated - Raj@Unisys { [Description("Remove a DomU configuration, and stop the DomU if running.")] uint32 DestroyVirtualSystem(); diff -r 17b5de70c6ab schema/Xen_HostedComputerSystem.mof --- a/schema/Xen_HostedComputerSystem.mof Thu Apr 27 22:26:52 2006 +++ b/schema/Xen_HostedComputerSystem.mof Wed May 17 16:09:04 2006 @@ -12,13 +12,13 @@ Description ( "A class derived from CIM_HostedDependency to represent " "the association of a Xen virtual machine/domain with the " - "host Linux_ComputerSystem.")] + "host CIM_ComputerSystem.")] class Xen_HostedComputerSystem : CIM_HostedDependency { [Override("Dependent")] Xen_ComputerSystem REF Dependent; [Override("Antecedent")] - Linux_ComputerSystem REF Antecedent; + CIM_ComputerSystem REF Antecedent; }; diff -r 17b5de70c6ab src/Xen_HostedComputerSystem.c --- a/src/Xen_HostedComputerSystem.c Thu Apr 27 22:26:52 2006 +++ b/src/Xen_HostedComputerSystem.c Wed May 17 16:09:04 2006 @@ -51,7 +51,7 @@ /* Name of the left and right hand side classes of this association. */ static char * _ASSOCCLASS = "Xen_HostedComputerSystem"; static char * _LHSCLASSNAME = "Xen_ComputerSystem"; -static char * _RHSCLASSNAME = "Linux_ComputerSystem"; +static char * _RHSCLASSNAME = "CIM_ComputerSystem"; static char * _LHSPROPERTYNAME = "Dependent"; static char * _RHSPROPERTYNAME = "Antecedent"; @@ -121,14 +121,16 @@ } /* Determine the target class from the source class. */ - if (strcmp(sourceclass, _LHSCLASSNAME) == 0) { + /* This used to be done with strcmp, we will now do it with CMClassPAthIsA*/ + + if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) { targetclass = _RHSCLASSNAME; - } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) { + } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) { targetclass = _LHSCLASSNAME; } else { _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request.")); goto exit; - } + } _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass)); /* Create an object path for the result class. */ @@ -147,17 +149,20 @@ goto exit; } - /* Return all object paths that exactly match the target class and resultClass, if specified. */ + /* Return all object paths that do not match the sourceClass and resultClass, if specified. + If the target class is CIM_ComputerSystem, the CIMOM will return both Xen_ComputerSystem and the + Host Provider. We need to return only the Host Provider. + This will also work, if the source class is the Host Provider's class. In that case, the only value returned + will be the Xen_ComputerSystem. + */ 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))) { + if (!(strcmp(class,sourceclass) == 0) && ((resultClass == NULL) || (strcmp(class,resultClass) == 0))) { CMReturnObjectPath(results, data.value.ref); } } - CMReturnDone(results); - exit: _SBLIM_RETURNSTATUS(status); } @@ -210,14 +215,15 @@ CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_SUPPORTED, NULL); /* Determine the target class from the source class. */ - if (strcmp(sourceclass, _LHSCLASSNAME) == 0) { + /* This used to be done with strcmp, we will now do it with CMClassPAthIsA*/ + if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) { targetclass = _RHSCLASSNAME; - } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) { + } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) { targetclass = _LHSCLASSNAME; } else { _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request.")); goto exit; - } + } _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass)); /* Create an object path for the result class. */ @@ -240,10 +246,10 @@ 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))) { + if (!(strcmp(class,targetclass) == 0) && ((resultClass == NULL) || (strcmp(class,resultClass) == 0))) { // BUG - returning data causes crash !?! _SBLIM_TRACE(2, ("--- data.value.inst=\"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.inst, NULL)))); -// CMReturnInstance(results, data.value.inst); + CMReturnInstance(results, data.value.inst); } } @@ -295,15 +301,16 @@ } /* Determine the target class from the source class. */ - if (strcmp(sourceclass, _LHSCLASSNAME) == 0) { + /* This used to be done with strcmp, we will now do it with CMClassPAthIsA*/ + if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) { targetclass = _RHSCLASSNAME; - } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) { + } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) { targetclass = _LHSCLASSNAME; } else { _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request.")); goto exit; - } - _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass)); + } + _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass)); /* Create an object path for the result class. */ CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, namespace, targetclass, &status); @@ -324,9 +331,10 @@ /* 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) { - + //char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL)); + // This used to be strcmp, now replaced with CMClassPathIsA + //if (strcmp(class,targetclass) == 0) { + if(CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) { /* Create an object path for the association. */ CMPIObjectPath * refobjectpath = CMNewObjectPath(_BROKER, namespace, _ASSOCCLASS, &status); if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refobjectpath)) { @@ -336,12 +344,15 @@ } /* 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 { + /* This used to be strcmp (sourceclass, _RHSCLASSNAME), but since the RHSCLASSNAME will always be CIM_COMPUTERSYSTEM, + we will be better off comparing it to the _LHSCLASSNAME + */ + if (strcmp(sourceclass, _LHSCLASSNAME) == 0) { CMAddKey(refobjectpath, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref); CMAddKey(refobjectpath, _LHSPROPERTYNAME, &reference, CMPI_ref); + } else { + CMAddKey(refobjectpath, _RHSPROPERTYNAME, &reference, CMPI_ref); + CMAddKey(refobjectpath, _LHSPROPERTYNAME, &data.value.ref, CMPI_ref); } CMReturnObjectPath(results, refobjectpath); @@ -395,14 +406,15 @@ } /* Determine the target class from the source class. */ - if (strcmp(sourceclass, _LHSCLASSNAME) == 0) { + /* This used to be done with strcmp, we will now do it with CMClassPAthIsA*/ + if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) { targetclass = _RHSCLASSNAME; - } else if (strcmp(sourceclass, _RHSCLASSNAME) == 0) { + } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) { targetclass = _LHSCLASSNAME; } else { _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request.")); goto exit; - } + } _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass)); /* Create an object path for the result class. */ @@ -424,9 +436,10 @@ /* 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) { - + //char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL)); + // This used to be strcmp, now replaced with CMClassPathIsA + //if (strcmp(class,targetclass) == 0) { + if(CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) { /* Create an instance for the association. */ CMPIInstance * refinstance = _CMNewInstance(_BROKER, namespace, _ASSOCCLASS, &status); if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refinstance)) { @@ -436,14 +449,16 @@ } /* 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); + /* This used to be strcmp (sourceclass, _RHSCLASSNAME), but since the RHSCLASSNAME will always be CIM_COMPUTERSYSTEM, + we will be better off comparing it to the _LHSCLASSNAME + */ + if (strcmp(sourceclass, _LHSCLASSNAME) == 0) { + CMSetProperty(refinstance, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref); CMSetProperty(refinstance, _LHSPROPERTYNAME, &reference, CMPI_ref); + } else { + CMSetProperty(refinstance, _RHSPROPERTYNAME, &reference, CMPI_ref); + CMSetProperty(refinstance, _LHSPROPERTYNAME, &data.value.ref, CMPI_ref); } - CMReturnInstance(results, refinstance); } }