os-cmpi-xen

changeset 21:d41f84e91f1d

Initial implementation of System Virtualization and Virtual System Profile registration.
TODO: Need to determine how to handle importing schema into multiple namespaces.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author jfehlig@jfehlig3.provo.novell.com
date Fri Aug 25 11:31:36 2006 -0600 (2006-08-25)
parents efe4945dbfd0
children 168eab2523f9
files Makefile.am schema/Xen_ElementConformsToSVProfile.mof schema/Xen_ElementConformsToSVProfile.registration schema/Xen_ElementConformsToVSProfile.mof schema/Xen_ElementConformsToVSProfile.registration schema/Xen_RegisteredSVProfile.mof schema/Xen_RegisteredSVProfile.registration schema/Xen_RegisteredVSProfile.mof schema/Xen_RegisteredVSProfile.registration src/Makefile.am src/Xen_ElementConformsToSVProfile.c src/Xen_ElementConformsToVSProfile.c src/Xen_RegisteredProfiles.c
line diff
     1.1 --- a/Makefile.am	Thu Aug 24 10:49:03 2006 -0600
     1.2 +++ b/Makefile.am	Fri Aug 25 11:31:36 2006 -0600
     1.3 @@ -107,7 +107,11 @@ XEN_MOFS = \
     1.4  	schema/Xen_ProcessorCapabilitiesSettingData.mof \
     1.5  	schema/Xen_MemoryCapabilitiesSettingData.mof \
     1.6  	schema/Xen_ProcessorAllocatedFromPool.mof \
     1.7 -	schema/Xen_ProcessorSettingAllocationFromPool.mof
     1.8 +	schema/Xen_ProcessorSettingAllocationFromPool.mof \
     1.9 +	schema/Xen_RegisteredSVProfile.mof \
    1.10 +	schema/Xen_ElementConformsToSVProfile.mof \
    1.11 +	schema/Xen_RegisteredVSProfile.mof \
    1.12 +	schema/Xen_ElementConformsToVSProfile.mof
    1.13  #	schema/Xen_HostedProcessor.mof
    1.14  
    1.15  # LIST ALL THE CLASS CIMOM REGISTRATION FILES HERE
    1.16 @@ -150,7 +154,11 @@ XEN_REGS = \
    1.17  	schema/Xen_ProcessorCapabilitiesSettingData.registration \
    1.18  	schema/Xen_MemoryCapabilitiesSettingData.registration \
    1.19  	schema/Xen_ProcessorAllocatedFromPool.registration \
    1.20 -	schema/Xen_ProcessorSettingAllocationFromPool.registration
    1.21 +	schema/Xen_ProcessorSettingAllocationFromPool.registration \
    1.22 +	schema/Xen_RegisteredSVProfile.registration \
    1.23 +	schema/Xen_ElementConformsToSVProfile.registration \
    1.24 +	schema/Xen_RegisteredVSProfile.registration \
    1.25 +	schema/Xen_ElementConformsToVSProfile.registration
    1.26  #	schema/Xen_HostedProcessor.registration
    1.27  
    1.28  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/schema/Xen_ElementConformsToSVProfile.mof	Fri Aug 25 11:31:36 2006 -0600
     2.3 @@ -0,0 +1,28 @@
     2.4 +// Copyright (c) 2006 Novell, Inc. All rights reserved.
     2.5 +
     2.6 +// *******************************************************************
     2.7 +// Associations
     2.8 +// *******************************************************************
     2.9 +
    2.10 +// ==================================================================
    2.11 +// Xen_ElementConformsToSVProfile
    2.12 +// ==================================================================
    2.13 +[Association,
    2.14 + Provider ("cmpi:Xen_ElementConformsToSVProfile"),
    2.15 + Description (
    2.16 +	"A class derived from CIM_ElementConformsToProfile "
    2.17 +	"indicating that a ManagedElement conforms to the "
    2.18 +	"System Virtualization Profile.")]
    2.19 +class Xen_ElementConformsToSVProfile : CIM_ElementConformsToProfile
    2.20 +{
    2.21 +   [Override ("ConformantStandard"), Key,
    2.22 +	Description ("The RegisteredSystemVirtualizationProfile to "
    2.23 +	             "which the ManagedElement conforms.")]
    2.24 +   Xen_RegisteredSVProfile REF ConformantStandard;
    2.25 +
    2.26 +   [Override ("ManagedElement"), Key,
    2.27 +	Description ("The ManagedElement that conforms to the "
    2.28 +	             "RegisteredSystemVirtualizationProfile.")]
    2.29 +   CIM_ManagedElement REF ManagedElement;
    2.30 +};
    2.31 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/schema/Xen_ElementConformsToSVProfile.registration	Fri Aug 25 11:31:36 2006 -0600
     3.3 @@ -0,0 +1,2 @@
     3.4 +# Classname Namespace ProviderName ProviderModule ProviderTypes ...
     3.5 +Xen_ElementConformsToSVProfile Interop Xen_ElementConformsToSVProfile Xen_ElementConformsToSVProfile association
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/schema/Xen_ElementConformsToVSProfile.mof	Fri Aug 25 11:31:36 2006 -0600
     4.3 @@ -0,0 +1,28 @@
     4.4 +// Copyright (c) 2006 Novell, Inc. All rights reserved.
     4.5 +
     4.6 +// *******************************************************************
     4.7 +// Associations
     4.8 +// *******************************************************************
     4.9 +
    4.10 +// ==================================================================
    4.11 +// Xen_ElementConformsToSVProfile
    4.12 +// ==================================================================
    4.13 +[Association,
    4.14 + Provider ("cmpi:Xen_ElementConformsToVSProfile"),
    4.15 + Description (
    4.16 +	"A class derived from CIM_ElementConformsToProfile "
    4.17 +	"indicating that a ManagedElement conforms to the "
    4.18 +	"Virtual System Profile.")]
    4.19 +class Xen_ElementConformsToVSProfile : CIM_ElementConformsToProfile
    4.20 +{
    4.21 +   [Override ("ConformantStandard"), Key,
    4.22 +	Description ("The RegisteredVirtualSystemProfile to "
    4.23 +	             "which the ManagedElement conforms.")]
    4.24 +   Xen_RegisteredVSProfile REF ConformantStandard;
    4.25 +
    4.26 +   [Override ("ManagedElement"), Key,
    4.27 +	Description ("The ManagedElement that conforms to the "
    4.28 +	             "RegisteredVirtualSystemProfile.")]
    4.29 +   CIM_ManagedElement REF ManagedElement;
    4.30 +};
    4.31 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/schema/Xen_ElementConformsToVSProfile.registration	Fri Aug 25 11:31:36 2006 -0600
     5.3 @@ -0,0 +1,2 @@
     5.4 +# Classname Namespace ProviderName ProviderModule ProviderTypes ...
     5.5 +Xen_ElementConformsToVSProfile Interop Xen_ElementConformsToVSProfile Xen_ElementConformsToVSProfile association
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/schema/Xen_RegisteredSVProfile.mof	Fri Aug 25 11:31:36 2006 -0600
     6.3 @@ -0,0 +1,13 @@
     6.4 +// Copyright (c) 2006 Novell, Inc. All rights reserved.
     6.5 +
     6.6 +// ==================================================================
     6.7 +// Xen_RegisteredSVProfile
     6.8 +// ==================================================================
     6.9 +[Provider ("cmpi:Xen_RegisteredProfiles"),
    6.10 + Description (
    6.11 +        "A class derived from CIM_RegisteredProfile used to "
    6.12 +        "advertise conformance to the System Virtualization Profile.")]
    6.13 +class Xen_RegisteredSVProfile : CIM_RegisteredProfile
    6.14 +{
    6.15 +};
    6.16 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/schema/Xen_RegisteredSVProfile.registration	Fri Aug 25 11:31:36 2006 -0600
     7.3 @@ -0,0 +1,2 @@
     7.4 +# Classname Namespace ProviderName ProviderModule ProviderTypes ...
     7.5 +Xen_RegisteredSVProfile Interop Xen_RegisteredProfiles Xen_RegisteredProfiles instance
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/schema/Xen_RegisteredVSProfile.mof	Fri Aug 25 11:31:36 2006 -0600
     8.3 @@ -0,0 +1,13 @@
     8.4 +// Copyright (c) 2006 Novell, Inc. All rights reserved.
     8.5 +
     8.6 +// ==================================================================
     8.7 +// Xen_RegisteredSVProfile
     8.8 +// ==================================================================
     8.9 +[Provider ("cmpi:Xen_RegisteredProfiles"),
    8.10 + Description (
    8.11 +        "A class derived from CIM_RegisteredProfile used to "
    8.12 +        "advertise conformance to the Virtual System Profile.")]
    8.13 +class Xen_RegisteredVSProfile : CIM_RegisteredProfile
    8.14 +{
    8.15 +};
    8.16 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/schema/Xen_RegisteredVSProfile.registration	Fri Aug 25 11:31:36 2006 -0600
     9.3 @@ -0,0 +1,2 @@
     9.4 +# Classname Namespace ProviderName ProviderModule ProviderTypes ...
     9.5 +Xen_RegisteredVSProfile Interop Xen_RegisteredProfiles Xen_RegisteredProfiles instance
    10.1 --- a/src/Makefile.am	Thu Aug 24 10:49:03 2006 -0600
    10.2 +++ b/src/Makefile.am	Fri Aug 25 11:31:36 2006 -0600
    10.3 @@ -115,7 +115,10 @@ provider_LTLIBRARIES = \
    10.4  	libXen_ProcessorCapabilitiesSettingData.la \
    10.5  	libXen_MemoryCapabilitiesSettingData.la \
    10.6  	libXen_ProcessorAllocatedFromPool.la \
    10.7 -	libXen_ProcessorSettingAllocationFromPool.la
    10.8 +	libXen_ProcessorSettingAllocationFromPool.la \
    10.9 +	libXen_ElementConformsToSVProfile.la \
   10.10 +	libXen_ElementConformsToVSProfile.la \
   10.11 +	libXen_RegisteredProfiles.la
   10.12  
   10.13  
   10.14  libXen_ComputerSystem_la_SOURCES = Xen_ComputerSystem.c Xen_ComputerSystem_Resource.c
   10.15 @@ -254,6 +257,15 @@ libXen_ProcessorAllocatedFromPool_la_LIB
   10.16  libXen_ProcessorSettingAllocationFromPool_la_SOURCES = Xen_ProcessorSettingAllocationFromPool.c
   10.17  libXen_ProcessorSettingAllocationFromPool_la_LIBADD = libXen_utils.la
   10.18  
   10.19 +libXen_ElementConformsToSVProfile_la_SOURCES = Xen_ElementConformsToSVProfile.c
   10.20 +libXen_ElementConformsToSVProfile_la_LIBADD = libXen_utils.la
   10.21 +
   10.22 +libXen_ElementConformsToVSProfile_la_SOURCES = Xen_ElementConformsToVSProfile.c
   10.23 +libXen_ElementConformsToVSProfile_la_LIBADD = libXen_utils.la
   10.24 +
   10.25 +libXen_RegisteredProfiles_la_SOURCES = Xen_RegisteredProfiles.c
   10.26 +libXen_RegisteredProfiles_la_LIBADD = libXen_utils.la
   10.27 +
   10.28  
   10.29  BUILT_SOURCES=Xen_SettingDataLexer.c Xen_SettingDataParser.c
   10.30  AM_YFLAGS=-d
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/Xen_ElementConformsToSVProfile.c	Fri Aug 25 11:31:36 2006 -0600
    11.3 @@ -0,0 +1,524 @@
    11.4 +// Copyright (C) 2006 Novell, Inc.
    11.5 +//
    11.6 +//    This library is free software; you can redistribute it and/or
    11.7 +//    modify it under the terms of the GNU Lesser General Public
    11.8 +//    License as published by the Free Software Foundation; either
    11.9 +//    version 2.1 of the License, or (at your option) any later version.
   11.10 +//
   11.11 +//    This library is distributed in the hope that it will be useful,
   11.12 +//    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.13 +//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.14 +//    Lesser General Public License for more details.
   11.15 +//
   11.16 +//    You should have received a copy of the GNU Lesser General Public
   11.17 +//    License along with this library; if not, write to the Free Software
   11.18 +//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.19 +// ============================================================================
   11.20 +// Authors:      Jim Fehlig <jfehlig@novell.com>
   11.21 +
   11.22 +// Contributors:
   11.23 +// Description:
   11.24 +// ============================================================================
   11.25 +
   11.26 +#include <string.h>
   11.27 +
   11.28 +/* Include the required CMPI data types, function headers, and macros */
   11.29 +#include "cmpidt.h"
   11.30 +#include "cmpift.h"
   11.31 +#include "cmpimacs.h"
   11.32 +
   11.33 +
   11.34 +// ----------------------------------------------------------------------------
   11.35 +// COMMON GLOBAL VARIABLES
   11.36 +// ----------------------------------------------------------------------------
   11.37 +
   11.38 +/* Handle to the CIM broker. Initialized when the provider lib is loaded. */
   11.39 +static CMPIBroker *_BROKER;
   11.40 +
   11.41 +/* Include utility functions */
   11.42 +#include "cmpiutil.h"
   11.43 +
   11.44 +/* Include _SBLIM_TRACE() logging support */
   11.45 +#include "cmpitrace.h"
   11.46 +
   11.47 +
   11.48 +// ============================================================================
   11.49 +// CMPI ASSOCIATION PROVIDER FUNCTION TABLE
   11.50 +// ============================================================================
   11.51 +
   11.52 +// ----------------------------------------------------------------------------
   11.53 +// Info for the class supported by the association provider
   11.54 +// ----------------------------------------------------------------------------
   11.55 +                                                                                                                                 
   11.56 +/* Name of the left and right hand side classes of this association. */
   11.57 +static char * _ASSOCCLASS = "Xen_ElementConformsToSVProfile";
   11.58 +static char * _LHSCLASSNAME = "Xen_RegisteredSVProfile";
   11.59 +static char * _RHSCLASSNAME = "CIM_ComputerSystem";
   11.60 +static char * _LHSPROPERTYNAME = "ConformantStandard"; 
   11.61 +static char * _RHSPROPERTYNAME = "ManagedElement";
   11.62 +static char * _LHSNAMESPACE = "Interop";
   11.63 +static char * _RHSNAMESPACE = "smash";
   11.64 +
   11.65 +// ----------------------------------------------------------------------------
   11.66 +// AssociationCleanup()
   11.67 +// Perform any necessary cleanup immediately before this provider is unloaded.
   11.68 +// ----------------------------------------------------------------------------
   11.69 +static CMPIStatus AssociationCleanup(
   11.70 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
   11.71 +		CMPIContext * context)		/* [in] Additional context info, if any. */
   11.72 +{
   11.73 +   CMPIStatus status = { CMPI_RC_OK, NULL };	/* Return status of CIM operations. */
   11.74 +
   11.75 +   _SBLIM_ENTER("AssociationCleanup");
   11.76 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   11.77 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   11.78 +
   11.79 +   /* Nothing needs to be done for cleanup. */
   11.80 +
   11.81 +exit:
   11.82 +   _SBLIM_RETURNSTATUS(status);
   11.83 +}
   11.84 +
   11.85 +
   11.86 +// ----------------------------------------------------------------------------
   11.87 +// AssociatorNames()
   11.88 +// ----------------------------------------------------------------------------
   11.89 +static CMPIStatus AssociatorNames(
   11.90 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
   11.91 +		CMPIContext * context,		/* [in] Additional context info, if any. */
   11.92 +		CMPIResult * results,		/* [out] Results of this operation. */
   11.93 +		CMPIObjectPath * reference,	/* [in] Contains source namespace, classname and object path. */
   11.94 +		const char * assocClass,
   11.95 +		const char * resultClass,
   11.96 +		const char * role,
   11.97 +		const char * resultRole)
   11.98 +{
   11.99 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
  11.100 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
  11.101 +   char *targetclass; 				/* Class of the target object(s). */
  11.102 +   char *targetnamespace;
  11.103 +
  11.104 +   _SBLIM_ENTER("AssociatorNames");
  11.105 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  11.106 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  11.107 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  11.108 +   _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
  11.109 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
  11.110 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
  11.111 +   _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
  11.112 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
  11.113 +
  11.114 +   /* Determine the target class and namespace from the source class. */
  11.115 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
  11.116 +      targetclass = _RHSCLASSNAME;
  11.117 +      targetnamespace = _RHSNAMESPACE;
  11.118 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
  11.119 +      targetclass = _LHSCLASSNAME;
  11.120 +      targetnamespace = _LHSNAMESPACE;
  11.121 +   } else {
  11.122 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
  11.123 +      goto exit;
  11.124 +   } 
  11.125 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
  11.126 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
  11.127 + 
  11.128 +   /* Check that the requested association class, if any, is supported. */
  11.129 +   if (assocClass != NULL) {
  11.130 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, targetnamespace, _ASSOCCLASS, NULL);
  11.131 +      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
  11.132 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
  11.133 +         goto exit;
  11.134 +      }
  11.135 +   }
  11.136 +
  11.137 +   /* Check that the reference matches the required role, if any. */
  11.138 +   /* TODO: Not sure about this check.  IIRC 'role' is a property name. */
  11.139 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
  11.140 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
  11.141 +      goto exit;
  11.142 +   }
  11.143 +
  11.144 +   /* Create an object path for the result class. */
  11.145 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
  11.146 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
  11.147 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  11.148 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  11.149 +      goto exit;
  11.150 +   }
  11.151 +
  11.152 +   /* Get the list of all target class object paths from the CIMOM. */
  11.153 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
  11.154 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
  11.155 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
  11.156 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
  11.157 +      goto exit;
  11.158 +   }
  11.159 +
  11.160 +   /* Return all object paths that match resultClass, if specified. */
  11.161 +   while (CMHasNext(objectpaths, NULL)) {
  11.162 +      CMPIData data = CMGetNext(objectpaths, NULL);
  11.163 +      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
  11.164 +      
  11.165 +      _SBLIM_TRACE(2, ("--- returning object path = \"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
  11.166 +
  11.167 +      /* Ignore possible instances of source class. */
  11.168 +      if (strcmp(class,sourceclass) &&
  11.169 +          (resultClass == NULL || CMClassPathIsA(_BROKER, data.value.ref, resultClass, NULL))) {
  11.170 +         _SBLIM_TRACE(2, ("--- returning object path = \"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
  11.171 +         CMReturnObjectPath(results, data.value.ref);
  11.172 +      }
  11.173 +   }
  11.174 +
  11.175 +   CMReturnDone(results);
  11.176 +exit:
  11.177 +   _SBLIM_RETURNSTATUS(status);
  11.178 +}
  11.179 +
  11.180 +
  11.181 +// ----------------------------------------------------------------------------
  11.182 +// Associators()
  11.183 +// ----------------------------------------------------------------------------
  11.184 +static CMPIStatus Associators(
  11.185 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
  11.186 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  11.187 +		CMPIResult * results,		/* [out] Results of this operation. */
  11.188 +		CMPIObjectPath * reference,	/* [in] Contains the source namespace, classname and object path. */
  11.189 +		const char *assocClass,
  11.190 +		const char *resultClass,
  11.191 +		const char *role,
  11.192 +		const char *resultRole,
  11.193 +		char ** properties)		/* [in] List of desired properties (NULL=all). */
  11.194 +{
  11.195 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
  11.196 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
  11.197 +   char *targetclass;                           /* Class of the target object(s). */
  11.198 +   char *targetnamespace;
  11.199 +
  11.200 +   _SBLIM_ENTER("Associators");
  11.201 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  11.202 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  11.203 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  11.204 +   _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
  11.205 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
  11.206 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
  11.207 +   _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
  11.208 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
  11.209 +
  11.210 +   /* Determine the target class from the source class. */
  11.211 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
  11.212 +      targetclass = _RHSCLASSNAME;
  11.213 +      targetnamespace = _RHSNAMESPACE;
  11.214 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
  11.215 +      targetclass = _LHSCLASSNAME;
  11.216 +      targetnamespace = _LHSNAMESPACE;
  11.217 +   } else {
  11.218 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
  11.219 +      goto exit;
  11.220 +   } 
  11.221 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
  11.222 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
  11.223 +
  11.224 +   /* Check that the requested association class, if any, is supported. */
  11.225 +   if (assocClass != NULL) {
  11.226 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, targetnamespace, _ASSOCCLASS, NULL);
  11.227 +      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
  11.228 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
  11.229 +         goto exit;
  11.230 +      }
  11.231 +   }
  11.232 +
  11.233 +   /* Check that the reference matches the required role, if any. */
  11.234 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
  11.235 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
  11.236 +      goto exit;
  11.237 +   }
  11.238 +
  11.239 +   /* Create an object path for the result class. */
  11.240 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
  11.241 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
  11.242 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  11.243 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  11.244 +      goto exit;
  11.245 +   }
  11.246 +
  11.247 +   /* Get the list of all target class instances from the CIMOM. */
  11.248 +   CMPIEnumeration * instances = CBEnumInstances(_BROKER, context, objectpath, NULL, &status);
  11.249 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instances)) {
  11.250 +      _SBLIM_TRACE(1,("--- CBEnumInstances() failed - %s", CMGetCharPtr(status.msg)));
  11.251 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
  11.252 +      goto exit;
  11.253 +   }
  11.254 +
  11.255 +   /* Return all instances that match the resultClass, if specified. */
  11.256 +   while (CMHasNext(instances, NULL)) {
  11.257 +      CMPIData data = CMGetNext(instances, NULL);
  11.258 +      CMPIObjectPath *op = CMGetObjectPath(data.value.inst,NULL);
  11.259 +      char *class = CMGetCharPtr(CMGetClassName(op, NULL));
  11.260 +
  11.261 +      _SBLIM_TRACE(2, ("--- got inst with object path = \"%s\"", CMGetCharPtr(CDToString(_BROKER, op, NULL))));
  11.262 +
  11.263 +      /* Ignore possible instances of source class. */
  11.264 +      if (strcmp(class,sourceclass) &&
  11.265 +          (resultClass == NULL || CMClassPathIsA(_BROKER, op, resultClass, NULL))) {
  11.266 +         _SBLIM_TRACE(2, ("--- data.value.inst=\"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.inst, NULL))));
  11.267 +         
  11.268 +         CMReturnInstance(results, data.value.inst);
  11.269 +      }
  11.270 +   }
  11.271 +   
  11.272 +   CMReturnDone(results);
  11.273 +
  11.274 +exit:
  11.275 +   _SBLIM_RETURNSTATUS(status);
  11.276 +}
  11.277 +
  11.278 +
  11.279 +// ----------------------------------------------------------------------------
  11.280 +// ReferenceNames()
  11.281 +// ----------------------------------------------------------------------------
  11.282 +static CMPIStatus ReferenceNames(
  11.283 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
  11.284 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  11.285 +		CMPIResult * results,		/* [out] Results of this operation. */
  11.286 +		CMPIObjectPath * reference,	/* [in] Contains the source namespace, classname and object path. */
  11.287 +		const char *resultClass, 
  11.288 +		const char *role)
  11.289 +{
  11.290 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
  11.291 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
  11.292 +   char *targetclass;                           /* Class of the target object(s). */
  11.293 +   char *targetnamespace;
  11.294 +
  11.295 +   _SBLIM_ENTER("ReferenceNames");
  11.296 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  11.297 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  11.298 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  11.299 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
  11.300 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
  11.301 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
  11.302 +
  11.303 +   /* Need to have object paths for objects on both sides of the returned
  11.304 +    * association names.  We are given one in the reference parameter.  Need to
  11.305 +    * fetch the others from cimom.
  11.306 +    */
  11.307 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
  11.308 +      targetclass = _RHSCLASSNAME;
  11.309 +      targetnamespace = _RHSNAMESPACE;
  11.310 +      /* Refences of LHS class should always be in LHS namespace. */
  11.311 +      CMSetNameSpace(reference, _LHSNAMESPACE);
  11.312 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
  11.313 +      targetclass = _LHSCLASSNAME;
  11.314 +      targetnamespace = _LHSNAMESPACE;
  11.315 +   } else {
  11.316 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
  11.317 +      goto exit;
  11.318 +   } 
  11.319 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
  11.320 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
  11.321 +
  11.322 +   /* If resultClass is specified, it should be a Xen_HostedComputerSystem.
  11.323 +    * Otherwise caller is looking for a different association than what this
  11.324 +    * code implements.
  11.325 +    */
  11.326 +   if (resultClass != NULL) {
  11.327 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, NULL);
  11.328 +      if (!CMClassPathIsA(_BROKER, assoc, resultClass, NULL)) {
  11.329 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
  11.330 +         goto exit;
  11.331 +      }
  11.332 +   }
  11.333 +
  11.334 +   /* Check that the reference matches the required role, if any. */
  11.335 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
  11.336 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
  11.337 +      goto exit;
  11.338 +   }
  11.339 +
  11.340 +   /* Retrieve object paths of objects on other side of association. */
  11.341 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
  11.342 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
  11.343 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  11.344 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  11.345 +      goto exit;
  11.346 +   }
  11.347 +
  11.348 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
  11.349 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
  11.350 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
  11.351 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
  11.352 +      goto exit;
  11.353 +   }
  11.354 +
  11.355 +   /* Already made it past the filters so return an association name
  11.356 +    * (object path) for each association that exists to the source object.
  11.357 +    */
  11.358 +   while (CMHasNext(objectpaths, NULL)) {
  11.359 +      CMPIData data = CMGetNext(objectpaths, NULL);
  11.360 +      
  11.361 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
  11.362 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
  11.363 +         /* Create an object path for the association. Note that the association
  11.364 +          * objects should exist in 'virt namespace' not the host namespace.
  11.365 +          */
  11.366 +         CMPIObjectPath * refobjectpath = CMNewObjectPath(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, &status);
  11.367 +         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refobjectpath)) {
  11.368 +            _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  11.369 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  11.370 +            goto exit;
  11.371 +         }
  11.372 +      
  11.373 +         /* Assign the references in the association appropriately. */
  11.374 +         if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
  11.375 +            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref);
  11.376 +            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &reference, CMPI_ref);
  11.377 +         } else {
  11.378 +            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &reference, CMPI_ref);
  11.379 +            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &data.value.ref, CMPI_ref);
  11.380 +         }
  11.381 +         
  11.382 +         CMReturnObjectPath(results, refobjectpath);
  11.383 +      }
  11.384 +   }
  11.385 +   
  11.386 +exit:
  11.387 +   _SBLIM_RETURNSTATUS(status);
  11.388 +}
  11.389 +
  11.390 +
  11.391 +// ----------------------------------------------------------------------------
  11.392 +// References()
  11.393 +// ----------------------------------------------------------------------------
  11.394 +static CMPIStatus References(
  11.395 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
  11.396 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  11.397 +		CMPIResult * results,		/* [out] Results of this operation. */
  11.398 +		CMPIObjectPath * reference,	/* [in] Contains the namespace, classname and desired object path. */
  11.399 +		const char *resultClass,
  11.400 +		const char *role,
  11.401 +		char **properties)		/* [in] List of desired properties (NULL=all). */
  11.402 +{
  11.403 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
  11.404 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
  11.405 +   char *targetclass;                           /* Class of the target object(s). */
  11.406 +   char *targetnamespace;
  11.407 +
  11.408 +   _SBLIM_ENTER("References");
  11.409 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  11.410 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  11.411 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  11.412 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
  11.413 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
  11.414 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
  11.415 +
  11.416 +   /* Need to have object paths for objects on both sides of the returned
  11.417 +    * associations.  We are given one in the reference parameter.  Need to
  11.418 +    * fetch the others from cimom.
  11.419 +    */
  11.420 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
  11.421 +      targetclass = _RHSCLASSNAME;
  11.422 +      targetnamespace = _RHSNAMESPACE;
  11.423 +      /* Refences of LHS class should always be in LHS namespace. */
  11.424 +      CMSetNameSpace(reference, _LHSNAMESPACE);
  11.425 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
  11.426 +      targetclass = _LHSCLASSNAME;
  11.427 +      targetnamespace = _LHSNAMESPACE;
  11.428 +   } else {
  11.429 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
  11.430 +      goto exit;
  11.431 +   } 
  11.432 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
  11.433 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
  11.434 +
  11.435 +   /* If resultClass is specified, it should be a Xen_HostedComputerSystem.
  11.436 +    * Otherwise caller is looking for a different association than what this
  11.437 +    * code implements.
  11.438 +    */
  11.439 +   if (resultClass != NULL) {
  11.440 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, targetnamespace, _ASSOCCLASS, NULL);
  11.441 +      if (!CMClassPathIsA(_BROKER, assoc, resultClass, NULL)) {
  11.442 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
  11.443 +         goto exit;
  11.444 +      }
  11.445 +   }
  11.446 +
  11.447 +   /* Check that the reference matches the required role, if any. */
  11.448 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
  11.449 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
  11.450 +      goto exit;
  11.451 +   }
  11.452 +
  11.453 +   /* Create an object path for the result class. */
  11.454 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
  11.455 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
  11.456 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  11.457 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  11.458 +      goto exit;
  11.459 +   }
  11.460 +
  11.461 +   /* Retrieve object paths of objects on other side of association. */
  11.462 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
  11.463 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
  11.464 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
  11.465 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
  11.466 +      goto exit;
  11.467 +   }
  11.468 +
  11.469 +   /* Already made it past the filters so return an association instance
  11.470 +    * for each association that exists to the source object.
  11.471 +    */
  11.472 +   while (CMHasNext(objectpaths, NULL)) {
  11.473 +      CMPIData data = CMGetNext(objectpaths, NULL);
  11.474 +       
  11.475 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
  11.476 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {  
  11.477 +         /* Create an instance for the association. Note that the association
  11.478 +          * objects should exist in 'virt namespace' not the host namespace.
  11.479 +          */
  11.480 +         CMPIInstance * refinstance = _CMNewInstance(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, &status);
  11.481 +         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refinstance)) {
  11.482 +            _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
  11.483 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
  11.484 +            goto exit;
  11.485 +         }
  11.486 +         
  11.487 +         /* Assign the references in the association appropriately. */
  11.488 +         if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
  11.489 +            CMSetProperty(refinstance, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref);
  11.490 +            CMSetProperty(refinstance, _LHSPROPERTYNAME, &reference, CMPI_ref);
  11.491 +         } else {
  11.492 +            CMSetProperty(refinstance, _RHSPROPERTYNAME, &reference, CMPI_ref);
  11.493 +            CMSetProperty(refinstance, _LHSPROPERTYNAME, &data.value.ref, CMPI_ref);
  11.494 +         }
  11.495 +         CMReturnInstance(results, refinstance);
  11.496 +      }
  11.497 +   }
  11.498 +   
  11.499 +exit:
  11.500 +   _SBLIM_RETURNSTATUS(status);
  11.501 +}
  11.502 +
  11.503 +
  11.504 +// ----------------------------------------------------------------------------
  11.505 +// AssociationInitialize()
  11.506 +// Perform any necessary initialization immediately after this provider is
  11.507 +// first loaded.
  11.508 +// ----------------------------------------------------------------------------
  11.509 +static void AssociationInitialize(
  11.510 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
  11.511 +		CMPIContext * context)		/* [in] Additional context info, if any. */
  11.512 +{
  11.513 +   _SBLIM_ENTER("AssociationInitialize");
  11.514 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  11.515 +   //   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  11.516 +
  11.517 +   /* Nothing needs to be done to initialize this provider */
  11.518 +
  11.519 +exit:
  11.520 +   _SBLIM_RETURN();
  11.521 +}
  11.522 +
  11.523 +
  11.524 +// ============================================================================
  11.525 +// CMPI ASSOCIATION PROVIDER FUNCTION TABLE SETUP
  11.526 +// ============================================================================
  11.527 +CMAssociationMIStub( , Xen_ElementConformsToSVProfile, _BROKER, AssociationInitialize(&mi, ctx));
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/Xen_ElementConformsToVSProfile.c	Fri Aug 25 11:31:36 2006 -0600
    12.3 @@ -0,0 +1,524 @@
    12.4 +// Copyright (C) 2006 Novell, Inc.
    12.5 +//
    12.6 +//    This library is free software; you can redistribute it and/or
    12.7 +//    modify it under the terms of the GNU Lesser General Public
    12.8 +//    License as published by the Free Software Foundation; either
    12.9 +//    version 2.1 of the License, or (at your option) any later version.
   12.10 +//
   12.11 +//    This library is distributed in the hope that it will be useful,
   12.12 +//    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.13 +//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.14 +//    Lesser General Public License for more details.
   12.15 +//
   12.16 +//    You should have received a copy of the GNU Lesser General Public
   12.17 +//    License along with this library; if not, write to the Free Software
   12.18 +//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.19 +// ============================================================================
   12.20 +// Authors:      Jim Fehlig <jfehlig@novell.com>
   12.21 +
   12.22 +// Contributors:
   12.23 +// Description:
   12.24 +// ============================================================================
   12.25 +
   12.26 +#include <string.h>
   12.27 +
   12.28 +/* Include the required CMPI data types, function headers, and macros */
   12.29 +#include "cmpidt.h"
   12.30 +#include "cmpift.h"
   12.31 +#include "cmpimacs.h"
   12.32 +
   12.33 +
   12.34 +// ----------------------------------------------------------------------------
   12.35 +// COMMON GLOBAL VARIABLES
   12.36 +// ----------------------------------------------------------------------------
   12.37 +
   12.38 +/* Handle to the CIM broker. Initialized when the provider lib is loaded. */
   12.39 +static CMPIBroker *_BROKER;
   12.40 +
   12.41 +/* Include utility functions */
   12.42 +#include "cmpiutil.h"
   12.43 +
   12.44 +/* Include _SBLIM_TRACE() logging support */
   12.45 +#include "cmpitrace.h"
   12.46 +
   12.47 +
   12.48 +// ============================================================================
   12.49 +// CMPI ASSOCIATION PROVIDER FUNCTION TABLE
   12.50 +// ============================================================================
   12.51 +
   12.52 +// ----------------------------------------------------------------------------
   12.53 +// Info for the class supported by the association provider
   12.54 +// ----------------------------------------------------------------------------
   12.55 +                                                                                                                                 
   12.56 +/* Name of the left and right hand side classes of this association. */
   12.57 +static char * _ASSOCCLASS = "Xen_ElementConformsToVSProfile";
   12.58 +static char * _LHSCLASSNAME = "Xen_RegisteredVSProfile";
   12.59 +static char * _RHSCLASSNAME = "Xen_ComputerSystem";
   12.60 +static char * _LHSPROPERTYNAME = "ConformantStandard"; 
   12.61 +static char * _RHSPROPERTYNAME = "ManagedElement";
   12.62 +static char * _LHSNAMESPACE = "Interop";
   12.63 +static char * _RHSNAMESPACE = "root/cimv2";
   12.64 +
   12.65 +// ----------------------------------------------------------------------------
   12.66 +// AssociationCleanup()
   12.67 +// Perform any necessary cleanup immediately before this provider is unloaded.
   12.68 +// ----------------------------------------------------------------------------
   12.69 +static CMPIStatus AssociationCleanup(
   12.70 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
   12.71 +		CMPIContext * context)		/* [in] Additional context info, if any. */
   12.72 +{
   12.73 +   CMPIStatus status = { CMPI_RC_OK, NULL };	/* Return status of CIM operations. */
   12.74 +
   12.75 +   _SBLIM_ENTER("AssociationCleanup");
   12.76 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   12.77 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   12.78 +
   12.79 +   /* Nothing needs to be done for cleanup. */
   12.80 +
   12.81 +exit:
   12.82 +   _SBLIM_RETURNSTATUS(status);
   12.83 +}
   12.84 +
   12.85 +
   12.86 +// ----------------------------------------------------------------------------
   12.87 +// AssociatorNames()
   12.88 +// ----------------------------------------------------------------------------
   12.89 +static CMPIStatus AssociatorNames(
   12.90 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
   12.91 +		CMPIContext * context,		/* [in] Additional context info, if any. */
   12.92 +		CMPIResult * results,		/* [out] Results of this operation. */
   12.93 +		CMPIObjectPath * reference,	/* [in] Contains source namespace, classname and object path. */
   12.94 +		const char * assocClass,
   12.95 +		const char * resultClass,
   12.96 +		const char * role,
   12.97 +		const char * resultRole)
   12.98 +{
   12.99 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
  12.100 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
  12.101 +   char *targetclass; 				/* Class of the target object(s). */
  12.102 +   char *targetnamespace;
  12.103 +
  12.104 +   _SBLIM_ENTER("AssociatorNames");
  12.105 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  12.106 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  12.107 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  12.108 +   _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
  12.109 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
  12.110 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
  12.111 +   _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
  12.112 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
  12.113 +
  12.114 +   /* Determine the target class and namespace from the source class. */
  12.115 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
  12.116 +      targetclass = _RHSCLASSNAME;
  12.117 +      targetnamespace = _RHSNAMESPACE;
  12.118 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
  12.119 +      targetclass = _LHSCLASSNAME;
  12.120 +      targetnamespace = _LHSNAMESPACE;
  12.121 +   } else {
  12.122 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
  12.123 +      goto exit;
  12.124 +   } 
  12.125 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
  12.126 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
  12.127 + 
  12.128 +   /* Check that the requested association class, if any, is supported. */
  12.129 +   if (assocClass != NULL) {
  12.130 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, targetnamespace, _ASSOCCLASS, NULL);
  12.131 +      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
  12.132 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
  12.133 +         goto exit;
  12.134 +      }
  12.135 +   }
  12.136 +
  12.137 +   /* Check that the reference matches the required role, if any. */
  12.138 +   /* TODO: Not sure about this check.  IIRC 'role' is a property name. */
  12.139 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
  12.140 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
  12.141 +      goto exit;
  12.142 +   }
  12.143 +
  12.144 +   /* Create an object path for the result class. */
  12.145 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
  12.146 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
  12.147 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  12.148 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  12.149 +      goto exit;
  12.150 +   }
  12.151 +
  12.152 +   /* Get the list of all target class object paths from the CIMOM. */
  12.153 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
  12.154 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
  12.155 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
  12.156 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
  12.157 +      goto exit;
  12.158 +   }
  12.159 +
  12.160 +   /* Return all object paths that match resultClass, if specified. */
  12.161 +   while (CMHasNext(objectpaths, NULL)) {
  12.162 +      CMPIData data = CMGetNext(objectpaths, NULL);
  12.163 +      char *class = CMGetCharPtr(CMGetClassName(data.value.ref, NULL));
  12.164 +      
  12.165 +      _SBLIM_TRACE(2, ("--- returning object path = \"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
  12.166 +
  12.167 +      /* Ignore possible instances of source class. */
  12.168 +      if (strcmp(class,sourceclass) &&
  12.169 +          (resultClass == NULL || CMClassPathIsA(_BROKER, data.value.ref, resultClass, NULL))) {
  12.170 +         _SBLIM_TRACE(2, ("--- returning object path = \"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.ref, NULL))));
  12.171 +         CMReturnObjectPath(results, data.value.ref);
  12.172 +      }
  12.173 +   }
  12.174 +
  12.175 +   CMReturnDone(results);
  12.176 +exit:
  12.177 +   _SBLIM_RETURNSTATUS(status);
  12.178 +}
  12.179 +
  12.180 +
  12.181 +// ----------------------------------------------------------------------------
  12.182 +// Associators()
  12.183 +// ----------------------------------------------------------------------------
  12.184 +static CMPIStatus Associators(
  12.185 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
  12.186 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  12.187 +		CMPIResult * results,		/* [out] Results of this operation. */
  12.188 +		CMPIObjectPath * reference,	/* [in] Contains the source namespace, classname and object path. */
  12.189 +		const char *assocClass,
  12.190 +		const char *resultClass,
  12.191 +		const char *role,
  12.192 +		const char *resultRole,
  12.193 +		char ** properties)		/* [in] List of desired properties (NULL=all). */
  12.194 +{
  12.195 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
  12.196 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
  12.197 +   char *targetclass;                           /* Class of the target object(s). */
  12.198 +   char *targetnamespace;
  12.199 +
  12.200 +   _SBLIM_ENTER("Associators");
  12.201 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  12.202 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  12.203 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  12.204 +   _SBLIM_TRACE(2, ("--- assocClass=\"%s\"", assocClass));
  12.205 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
  12.206 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
  12.207 +   _SBLIM_TRACE(2, ("--- resultRole=\"%s\"", resultRole));
  12.208 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
  12.209 +
  12.210 +   /* Determine the target class from the source class. */
  12.211 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
  12.212 +      targetclass = _RHSCLASSNAME;
  12.213 +      targetnamespace = _RHSNAMESPACE;
  12.214 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
  12.215 +      targetclass = _LHSCLASSNAME;
  12.216 +      targetnamespace = _LHSNAMESPACE;
  12.217 +   } else {
  12.218 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
  12.219 +      goto exit;
  12.220 +   } 
  12.221 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
  12.222 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
  12.223 +
  12.224 +   /* Check that the requested association class, if any, is supported. */
  12.225 +   if (assocClass != NULL) {
  12.226 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, targetnamespace, _ASSOCCLASS, NULL);
  12.227 +      if (!CMClassPathIsA(_BROKER, assoc, assocClass, NULL)) {
  12.228 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
  12.229 +         goto exit;
  12.230 +      }
  12.231 +   }
  12.232 +
  12.233 +   /* Check that the reference matches the required role, if any. */
  12.234 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
  12.235 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
  12.236 +      goto exit;
  12.237 +   }
  12.238 +
  12.239 +   /* Create an object path for the result class. */
  12.240 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
  12.241 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
  12.242 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  12.243 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  12.244 +      goto exit;
  12.245 +   }
  12.246 +
  12.247 +   /* Get the list of all target class instances from the CIMOM. */
  12.248 +   CMPIEnumeration * instances = CBEnumInstances(_BROKER, context, objectpath, NULL, &status);
  12.249 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instances)) {
  12.250 +      _SBLIM_TRACE(1,("--- CBEnumInstances() failed - %s", CMGetCharPtr(status.msg)));
  12.251 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
  12.252 +      goto exit;
  12.253 +   }
  12.254 +
  12.255 +   /* Return all instances that match the resultClass, if specified. */
  12.256 +   while (CMHasNext(instances, NULL)) {
  12.257 +      CMPIData data = CMGetNext(instances, NULL);
  12.258 +      CMPIObjectPath *op = CMGetObjectPath(data.value.inst,NULL);
  12.259 +      char *class = CMGetCharPtr(CMGetClassName(op, NULL));
  12.260 +
  12.261 +      _SBLIM_TRACE(2, ("--- got inst with object path = \"%s\"", CMGetCharPtr(CDToString(_BROKER, op, NULL))));
  12.262 +
  12.263 +      /* Ignore possible instances of source class. */
  12.264 +      if (strcmp(class,sourceclass) &&
  12.265 +          (resultClass == NULL || CMClassPathIsA(_BROKER, op, resultClass, NULL))) {
  12.266 +         _SBLIM_TRACE(2, ("--- data.value.inst=\"%s\"", CMGetCharPtr(CDToString(_BROKER, data.value.inst, NULL))));
  12.267 +         
  12.268 +         CMReturnInstance(results, data.value.inst);
  12.269 +      }
  12.270 +   }
  12.271 +   
  12.272 +   CMReturnDone(results);
  12.273 +
  12.274 +exit:
  12.275 +   _SBLIM_RETURNSTATUS(status);
  12.276 +}
  12.277 +
  12.278 +
  12.279 +// ----------------------------------------------------------------------------
  12.280 +// ReferenceNames()
  12.281 +// ----------------------------------------------------------------------------
  12.282 +static CMPIStatus ReferenceNames(
  12.283 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
  12.284 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  12.285 +		CMPIResult * results,		/* [out] Results of this operation. */
  12.286 +		CMPIObjectPath * reference,	/* [in] Contains the source namespace, classname and object path. */
  12.287 +		const char *resultClass, 
  12.288 +		const char *role)
  12.289 +{
  12.290 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
  12.291 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
  12.292 +   char *targetclass;                           /* Class of the target object(s). */
  12.293 +   char *targetnamespace;
  12.294 +
  12.295 +   _SBLIM_ENTER("ReferenceNames");
  12.296 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  12.297 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  12.298 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  12.299 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
  12.300 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
  12.301 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
  12.302 +
  12.303 +   /* Need to have object paths for objects on both sides of the returned
  12.304 +    * association names.  We are given one in the reference parameter.  Need to
  12.305 +    * fetch the others from cimom.
  12.306 +    */
  12.307 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
  12.308 +      targetclass = _RHSCLASSNAME;
  12.309 +      targetnamespace = _RHSNAMESPACE;
  12.310 +      /* Refences of LHS class should always be in LHS namespace. */
  12.311 +      CMSetNameSpace(reference, _LHSNAMESPACE);
  12.312 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
  12.313 +      targetclass = _LHSCLASSNAME;
  12.314 +      targetnamespace = _LHSNAMESPACE;
  12.315 +   } else {
  12.316 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
  12.317 +      goto exit;
  12.318 +   } 
  12.319 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
  12.320 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
  12.321 +
  12.322 +   /* If resultClass is specified, it should be a Xen_HostedComputerSystem.
  12.323 +    * Otherwise caller is looking for a different association than what this
  12.324 +    * code implements.
  12.325 +    */
  12.326 +   if (resultClass != NULL) {
  12.327 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, NULL);
  12.328 +      if (!CMClassPathIsA(_BROKER, assoc, resultClass, NULL)) {
  12.329 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
  12.330 +         goto exit;
  12.331 +      }
  12.332 +   }
  12.333 +
  12.334 +   /* Check that the reference matches the required role, if any. */
  12.335 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
  12.336 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
  12.337 +      goto exit;
  12.338 +   }
  12.339 +
  12.340 +   /* Retrieve object paths of objects on other side of association. */
  12.341 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
  12.342 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
  12.343 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  12.344 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  12.345 +      goto exit;
  12.346 +   }
  12.347 +
  12.348 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
  12.349 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
  12.350 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
  12.351 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
  12.352 +      goto exit;
  12.353 +   }
  12.354 +
  12.355 +   /* Already made it past the filters so return an association name
  12.356 +    * (object path) for each association that exists to the source object.
  12.357 +    */
  12.358 +   while (CMHasNext(objectpaths, NULL)) {
  12.359 +      CMPIData data = CMGetNext(objectpaths, NULL);
  12.360 +      
  12.361 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
  12.362 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {
  12.363 +         /* Create an object path for the association. Note that the association
  12.364 +          * objects should exist in 'virt namespace' not the host namespace.
  12.365 +          */
  12.366 +         CMPIObjectPath * refobjectpath = CMNewObjectPath(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, &status);
  12.367 +         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refobjectpath)) {
  12.368 +            _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  12.369 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  12.370 +            goto exit;
  12.371 +         }
  12.372 +      
  12.373 +         /* Assign the references in the association appropriately. */
  12.374 +         if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
  12.375 +            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref);
  12.376 +            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &reference, CMPI_ref);
  12.377 +         } else {
  12.378 +            CMAddKey(refobjectpath, _RHSPROPERTYNAME, &reference, CMPI_ref);
  12.379 +            CMAddKey(refobjectpath, _LHSPROPERTYNAME, &data.value.ref, CMPI_ref);
  12.380 +         }
  12.381 +         
  12.382 +         CMReturnObjectPath(results, refobjectpath);
  12.383 +      }
  12.384 +   }
  12.385 +   
  12.386 +exit:
  12.387 +   _SBLIM_RETURNSTATUS(status);
  12.388 +}
  12.389 +
  12.390 +
  12.391 +// ----------------------------------------------------------------------------
  12.392 +// References()
  12.393 +// ----------------------------------------------------------------------------
  12.394 +static CMPIStatus References(
  12.395 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
  12.396 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  12.397 +		CMPIResult * results,		/* [out] Results of this operation. */
  12.398 +		CMPIObjectPath * reference,	/* [in] Contains the namespace, classname and desired object path. */
  12.399 +		const char *resultClass,
  12.400 +		const char *role,
  12.401 +		char **properties)		/* [in] List of desired properties (NULL=all). */
  12.402 +{
  12.403 +   CMPIStatus status = { CMPI_RC_OK, NULL };    /* Return status of CIM operations. */
  12.404 +   char *sourceclass = CMGetCharPtr(CMGetClassName(reference, &status)); /* Class of the source reference object */
  12.405 +   char *targetclass;                           /* Class of the target object(s). */
  12.406 +   char *targetnamespace;
  12.407 +
  12.408 +   _SBLIM_ENTER("References");
  12.409 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  12.410 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  12.411 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  12.412 +   _SBLIM_TRACE(2, ("--- resultClass=\"%s\"", resultClass));
  12.413 +   _SBLIM_TRACE(2, ("--- role=\"%s\"", role));
  12.414 +   _SBLIM_TRACE(2, ("--- sourceclass=\"%s\"", sourceclass));
  12.415 +
  12.416 +   /* Need to have object paths for objects on both sides of the returned
  12.417 +    * associations.  We are given one in the reference parameter.  Need to
  12.418 +    * fetch the others from cimom.
  12.419 +    */
  12.420 +   if (CMClassPathIsA(_BROKER, reference, _LHSCLASSNAME, NULL)) {
  12.421 +      targetclass = _RHSCLASSNAME;
  12.422 +      targetnamespace = _RHSNAMESPACE;
  12.423 +      /* Refences of LHS class should always be in LHS namespace. */
  12.424 +      CMSetNameSpace(reference, _LHSNAMESPACE);
  12.425 +   } else if (CMClassPathIsA(_BROKER, reference, _RHSCLASSNAME, NULL)) {
  12.426 +      targetclass = _LHSCLASSNAME;
  12.427 +      targetnamespace = _LHSNAMESPACE;
  12.428 +   } else {
  12.429 +      _SBLIM_TRACE(2, ("--- Unrecognized source class. Ignoring request."));
  12.430 +      goto exit;
  12.431 +   } 
  12.432 +   _SBLIM_TRACE(2, ("--- targetclass=\"%s\"", targetclass));
  12.433 +   _SBLIM_TRACE(2, ("--- targetnamespace=\"%s\"", targetnamespace));
  12.434 +
  12.435 +   /* If resultClass is specified, it should be a Xen_HostedComputerSystem.
  12.436 +    * Otherwise caller is looking for a different association than what this
  12.437 +    * code implements.
  12.438 +    */
  12.439 +   if (resultClass != NULL) {
  12.440 +      CMPIObjectPath * assoc = CMNewObjectPath(_BROKER, targetnamespace, _ASSOCCLASS, NULL);
  12.441 +      if (!CMClassPathIsA(_BROKER, assoc, resultClass, NULL)) {
  12.442 +         _SBLIM_TRACE(2, ("--- Unrecognized association class. Ignoring request."));
  12.443 +         goto exit;
  12.444 +      }
  12.445 +   }
  12.446 +
  12.447 +   /* Check that the reference matches the required role, if any. */
  12.448 +   if ((role != NULL) && strcmp(role, sourceclass) != 0) {
  12.449 +      _SBLIM_TRACE(2, ("--- Reference does not match required role. Ignoring request."));
  12.450 +      goto exit;
  12.451 +   }
  12.452 +
  12.453 +   /* Create an object path for the result class. */
  12.454 +   CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, targetnamespace, targetclass, &status);
  12.455 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
  12.456 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
  12.457 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIObjectPath");
  12.458 +      goto exit;
  12.459 +   }
  12.460 +
  12.461 +   /* Retrieve object paths of objects on other side of association. */
  12.462 +   CMPIEnumeration * objectpaths = CBEnumInstanceNames(_BROKER, context, objectpath, &status);
  12.463 +   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpaths)) {
  12.464 +      _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
  12.465 +      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot enumerate target class");
  12.466 +      goto exit;
  12.467 +   }
  12.468 +
  12.469 +   /* Already made it past the filters so return an association instance
  12.470 +    * for each association that exists to the source object.
  12.471 +    */
  12.472 +   while (CMHasNext(objectpaths, NULL)) {
  12.473 +      CMPIData data = CMGetNext(objectpaths, NULL);
  12.474 +       
  12.475 +      if((CMClassPathIsA(_BROKER, data.value.ref, targetclass, NULL)) &&
  12.476 +         (!CMClassPathIsA(_BROKER, data.value.ref, sourceclass, NULL))) {  
  12.477 +         /* Create an instance for the association. Note that the association
  12.478 +          * objects should exist in 'virt namespace' not the host namespace.
  12.479 +          */
  12.480 +         CMPIInstance * refinstance = _CMNewInstance(_BROKER, _LHSNAMESPACE, _ASSOCCLASS, &status);
  12.481 +         if ((status.rc != CMPI_RC_OK) || CMIsNullObject(refinstance)) {
  12.482 +            _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
  12.483 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
  12.484 +            goto exit;
  12.485 +         }
  12.486 +         
  12.487 +         /* Assign the references in the association appropriately. */
  12.488 +         if (strcmp(sourceclass, _LHSCLASSNAME) == 0) {
  12.489 +            CMSetProperty(refinstance, _RHSPROPERTYNAME, &data.value.ref, CMPI_ref);
  12.490 +            CMSetProperty(refinstance, _LHSPROPERTYNAME, &reference, CMPI_ref);
  12.491 +         } else {
  12.492 +            CMSetProperty(refinstance, _RHSPROPERTYNAME, &reference, CMPI_ref);
  12.493 +            CMSetProperty(refinstance, _LHSPROPERTYNAME, &data.value.ref, CMPI_ref);
  12.494 +         }
  12.495 +         CMReturnInstance(results, refinstance);
  12.496 +      }
  12.497 +   }
  12.498 +   
  12.499 +exit:
  12.500 +   _SBLIM_RETURNSTATUS(status);
  12.501 +}
  12.502 +
  12.503 +
  12.504 +// ----------------------------------------------------------------------------
  12.505 +// AssociationInitialize()
  12.506 +// Perform any necessary initialization immediately after this provider is
  12.507 +// first loaded.
  12.508 +// ----------------------------------------------------------------------------
  12.509 +static void AssociationInitialize(
  12.510 +		CMPIAssociationMI * self,	/* [in] Handle to this provider (i.e. 'self'). */
  12.511 +		CMPIContext * context)		/* [in] Additional context info, if any. */
  12.512 +{
  12.513 +   _SBLIM_ENTER("AssociationInitialize");
  12.514 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  12.515 +   //   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  12.516 +
  12.517 +   /* Nothing needs to be done to initialize this provider */
  12.518 +
  12.519 +exit:
  12.520 +   _SBLIM_RETURN();
  12.521 +}
  12.522 +
  12.523 +
  12.524 +// ============================================================================
  12.525 +// CMPI ASSOCIATION PROVIDER FUNCTION TABLE SETUP
  12.526 +// ============================================================================
  12.527 +CMAssociationMIStub( , Xen_ElementConformsToVSProfile, _BROKER, AssociationInitialize(&mi, ctx));
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/Xen_RegisteredProfiles.c	Fri Aug 25 11:31:36 2006 -0600
    13.3 @@ -0,0 +1,414 @@
    13.4 +// Copyright (C) 2006 IBM Corporation
    13.5 +//
    13.6 +//    This library is free software; you can redistribute it and/or
    13.7 +//    modify it under the terms of the GNU Lesser General Public
    13.8 +//    License as published by the Free Software Foundation; either
    13.9 +//    version 2.1 of the License, or (at your option) any later version.
   13.10 +//
   13.11 +//    This library is distributed in the hope that it will be useful,
   13.12 +//    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.13 +//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.14 +//    Lesser General Public License for more details.
   13.15 +//
   13.16 +//    You should have received a copy of the GNU Lesser General Public
   13.17 +//    License along with this library; if not, write to the Free Software
   13.18 +//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.19 +// ============================================================================
   13.20 +// Authors:       Dr. Gareth S. Bestor, <bestor@us.ibm.com>
   13.21 +//                Tokunbo Adeshiyan, <tokunbo@us.ibm.com>
   13.22 +// Contributors:
   13.23 +// Description:
   13.24 +// ============================================================================
   13.25 +
   13.26 +#include <string.h>
   13.27 +
   13.28 +#include "provider_common.h"
   13.29 +
   13.30 +/* Include the required CMPI data types, function headers, and macros */
   13.31 +#include "cmpidt.h"
   13.32 +#include "cmpift.h"
   13.33 +#include "cmpimacs.h"
   13.34 +
   13.35 +// ----------------------------------------------------------------------------
   13.36 +// COMMON GLOBAL VARIABLES
   13.37 +// ----------------------------------------------------------------------------
   13.38 +
   13.39 +/* Handle to the CIM broker. Initialized when the provider lib is loaded. */
   13.40 +static CMPIBroker *_BROKER;
   13.41 +
   13.42 +/* Include utility functions */
   13.43 +#include "cmpiutil.h"
   13.44 +
   13.45 +/* Include _SBLIM_TRACE() logging support */
   13.46 +#include "cmpitrace.h"
   13.47 +
   13.48 +
   13.49 +// ============================================================================
   13.50 +// CMPI INSTANCE PROVIDER FUNCTION TABLE
   13.51 +// ============================================================================
   13.52 +
   13.53 +// ----------------------------------------------------------------------------
   13.54 +// Info for the class supported by the instance provider
   13.55 +// ----------------------------------------------------------------------------
   13.56 +
   13.57 +/* Name of the class implemented by this instance provider. */
   13.58 +/*** CUSTOMIZE FOR EACH PROVIDER ***/
   13.59 +static char * SVP_CLASSNAME = "Xen_RegisteredSVProfile";
   13.60 +static char * VSP_CLASSNAME = "Xen_RegisteredVSProfile";
   13.61 +static char * _NAMESPACE = "Interop";
   13.62 +
   13.63 +/* NULL terminated list of key properties of this class. */
   13.64 +/*** CUSTOMIZE FOR EACH PROVIDER ***/
   13.65 +const static char * _KEYNAMES[] = {"InstanceID", NULL};
   13.66 +
   13.67 +/* Additional static class data */
   13.68 +const static char * SVP_NAME = "System Virtualization Profile";
   13.69 +const static char * SVP_INST_ID = "Xen:SystemVirtualizationProfile";
   13.70 +const static char * SVP_VERSION = "0.7.2";
   13.71 +const static char * VSP_NAME = "Virtual System Profile";
   13.72 +const static char * VSP_INST_ID = "Xen:VirtualSystemProfile";
   13.73 +const static char * VSP_VERSION = "0.7.2";
   13.74 +
   13.75 +
   13.76 +static int generateObjectPath(const char *className,
   13.77 +                              CMPIObjectPath **op,
   13.78 +                              CMPIStatus *status)
   13.79 +{
   13.80 +   const char *instId;
   13.81 +   
   13.82 +   if (strcmp(className, SVP_CLASSNAME) == 0)
   13.83 +      instId = SVP_INST_ID;
   13.84 +   else if (strcmp(className, VSP_CLASSNAME) == 0)
   13.85 +      instId = VSP_INST_ID;
   13.86 +   else {
   13.87 +      _SBLIM_TRACE(1,("--- Invalid class - %s", className));
   13.88 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR, "Invalid class");
   13.89 +      return 1;
   13.90 +   }
   13.91 +      
   13.92 +   *op = CMNewObjectPath(_BROKER, _NAMESPACE, className, status);
   13.93 +   if ((status->rc != CMPI_RC_OK) || CMIsNullObject(*op)) {
   13.94 +      _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status->msg)));
   13.95 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR, "Cannot create new CMPIOjbectPath");
   13.96 +      return 1;
   13.97 +   }
   13.98 +      
   13.99 +   CMAddKey(*op, "InstanceID", (CMPIValue *)instId, CMPI_chars);
  13.100 +   return 0;
  13.101 +}
  13.102 +
  13.103 +static int generateInstance(const char *className,
  13.104 +                            CMPIInstance **inst,
  13.105 +                            const char ** properties,
  13.106 +                            CMPIStatus *status)
  13.107 +{
  13.108 +   const char *instId;
  13.109 +   const char *profileName;
  13.110 +   const char *profileVersion;
  13.111 +   
  13.112 +   if (strcmp(className, SVP_CLASSNAME) == 0) {
  13.113 +      instId = SVP_INST_ID;
  13.114 +      profileName = SVP_NAME;
  13.115 +      profileVersion = SVP_VERSION;
  13.116 +   }
  13.117 +   else if (strcmp(className, VSP_CLASSNAME) == 0) {
  13.118 +      instId = VSP_INST_ID;
  13.119 +      profileName = VSP_NAME;
  13.120 +      profileVersion = VSP_VERSION;
  13.121 +   }
  13.122 +   else {
  13.123 +      _SBLIM_TRACE(1,("--- Invalid class - %s", className));
  13.124 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR, "Invalid class");
  13.125 +      return 1;
  13.126 +   }
  13.127 +   
  13.128 +   *inst = _CMNewInstance(_BROKER, _NAMESPACE, (char *)className, status);
  13.129 +   if ((status->rc != CMPI_RC_OK) || CMIsNullObject(*inst)) {
  13.130 +      _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status->msg)));
  13.131 +      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
  13.132 +      return 1;
  13.133 +   }
  13.134 +      
  13.135 +   /* Setup a filter to only return the desired properties. */
  13.136 +   CMSetPropertyFilter(*inst, properties, _KEYNAMES);
  13.137 +   
  13.138 +   CMSetProperty(*inst, "InstanceID",(CMPIValue *)instId, CMPI_chars);
  13.139 +   CMSetProperty(*inst, "RegisteredName",(CMPIValue *)profileName, CMPI_chars);
  13.140 +   
  13.141 +   int registeredOrg = 2; // "DMTF"
  13.142 +   CMSetProperty(*inst, "RegisteredOrganization",(CMPIValue *)&registeredOrg, CMPI_uint16);
  13.143 +   
  13.144 +   CMSetProperty(*inst, "RegisteredVersion",(CMPIValue *)profileVersion, CMPI_chars);
  13.145 +   return 0;
  13.146 +}
  13.147 +
  13.148 +
  13.149 +// ----------------------------------------------------------------------------
  13.150 +// Cleanup()
  13.151 +// Perform any necessary cleanup immediately before this provider is unloaded.
  13.152 +// ----------------------------------------------------------------------------
  13.153 +static CMPIStatus Cleanup(
  13.154 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.155 +		CMPIContext * context)		/* [in] Additional context info, if any. */
  13.156 +{
  13.157 +   CMPIStatus status = { CMPI_RC_OK, NULL };	/* Return status of CIM operations. */
  13.158 +
  13.159 +   _SBLIM_ENTER("Cleanup");
  13.160 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  13.161 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  13.162 +
  13.163 +   /* Nothing needs to be done for cleanup. */
  13.164 +
  13.165 +exit:
  13.166 +   _SBLIM_RETURNSTATUS(status);
  13.167 +}
  13.168 +
  13.169 +// ----------------------------------------------------------------------------
  13.170 +// EnumInstanceNames()
  13.171 +// Return a list of all the instances names (return their object paths only).
  13.172 +// ----------------------------------------------------------------------------
  13.173 +static CMPIStatus EnumInstanceNames(
  13.174 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.175 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  13.176 +		CMPIResult * results,		/* [out] Results of this operation. */
  13.177 +		CMPIObjectPath * reference) 	/* [in] Contains target namespace and classname. */
  13.178 +{
  13.179 +   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
  13.180 +   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
  13.181 +   char * className = CMGetCharPtr(CMGetClassName(reference, NULL));
  13.182 +  
  13.183 +   _SBLIM_ENTER("EnumInstanceNames");
  13.184 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  13.185 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  13.186 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  13.187 +   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
  13.188 +   _SBLIM_TRACE(2, ("--- class name=\"%s\"", className));
  13.189 +
  13.190 +   /* Should only exist in Interop namespace */
  13.191 +   if (strcmp(namespace, "Interop") != 0) {
  13.192 +      _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for System Virtualization Profile", namespace));
  13.193 +      goto exit;
  13.194 +   }
  13.195 +   
  13.196 +   CMPIObjectPath *op = NULL;
  13.197 +   if (generateObjectPath(className, &op, &status))
  13.198 +      goto exit;
  13.199 +   
  13.200 +   _SBLIM_TRACE(2, ("--- returning object path=\"%s\"", CMGetCharPtr(CDToString(_BROKER, op, NULL))));
  13.201 +
  13.202 +   CMReturnObjectPath(results, op);
  13.203 +
  13.204 +exit:
  13.205 +   CMReturnDone(results);
  13.206 +   _SBLIM_RETURNSTATUS(status);
  13.207 +}
  13.208 +
  13.209 +// ----------------------------------------------------------------------------
  13.210 +// EnumInstances()
  13.211 +// Return a list of all the instances (return all the instance data).
  13.212 +// ----------------------------------------------------------------------------
  13.213 +static CMPIStatus EnumInstances(
  13.214 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.215 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  13.216 +		CMPIResult * results,		/* [out] Results of this operation. */
  13.217 +		CMPIObjectPath * reference,	/* [in] Contains target namespace and classname. */
  13.218 +		const char ** properties)	/* [in] List of desired properties (NULL=all). */
  13.219 +{
  13.220 +   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
  13.221 +   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
  13.222 +   char * className = CMGetCharPtr(CMGetClassName(reference, NULL));
  13.223 +
  13.224 +   _SBLIM_ENTER("EnumInstances");
  13.225 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  13.226 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  13.227 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  13.228 +   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
  13.229 +   _SBLIM_TRACE(2, ("--- class name=\"%s\"", className));
  13.230 +
  13.231 +   /* Should only exist in Interop namespace */
  13.232 +   if (strcmp(namespace, "Interop") != 0) {
  13.233 +      _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for System Virtualization Profile", namespace));
  13.234 +      goto exit;
  13.235 +   }
  13.236 +
  13.237 +   CMPIInstance *instance = NULL;
  13.238 +   if (generateInstance(className, &instance, properties, &status))
  13.239 +         goto exit;
  13.240 +   
  13.241 +   CMReturnInstance(results, instance);
  13.242 +   
  13.243 + exit:
  13.244 +   CMReturnDone(results);
  13.245 +   _SBLIM_RETURNSTATUS(status);
  13.246 +}
  13.247 +
  13.248 +// ----------------------------------------------------------------------------
  13.249 +// GetInstance()
  13.250 +// Return the instance data for the specified instance only.
  13.251 +// ----------------------------------------------------------------------------
  13.252 +static CMPIStatus GetInstance(
  13.253 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.254 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  13.255 +		CMPIResult * results,		/* [out] Results of this operation. */
  13.256 +		CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
  13.257 +		const char ** properties)		/* [in] List of desired properties (NULL=all). */
  13.258 +{
  13.259 +   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
  13.260 +   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
  13.261 +   char * className = CMGetCharPtr(CMGetClassName(reference, NULL));
  13.262 +
  13.263 +   _SBLIM_ENTER("GetInstance");
  13.264 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  13.265 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  13.266 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  13.267 +   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
  13.268 +   _SBLIM_TRACE(2, ("--- class name=\"%s\"", className));
  13.269 +
  13.270 +   /* Should only exist in Interop namespace */
  13.271 +   if (strcmp(namespace, "Interop") != 0) {
  13.272 +      _SBLIM_TRACE(1,("--- \"%s\" is not a valid namespace for System Virtualization Profile", namespace));
  13.273 +      goto exit;
  13.274 +   }
  13.275 +
  13.276 +   /* Verify InstanceID is what we expect. */
  13.277 +   CMPIData data = CMGetKey(reference, "InstanceID", &status);
  13.278 +   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) {
  13.279 +      _SBLIM_TRACE(1,("--- Unable to extract InstanceID key from object path"));
  13.280 +      goto exit;
  13.281 +   }
  13.282 +   
  13.283 +   char *instId = CMGetCharPtr(data.value.string);
  13.284 +   if (instId == NULL ||
  13.285 +       (strcmp(instId, SVP_INST_ID) && strcmp(instId, VSP_INST_ID))) {
  13.286 +      _SBLIM_TRACE(1,("--- \"%s\" is not a valid InstanceID value", (instId ? instId : "NULL")));
  13.287 +      goto exit;
  13.288 +   }
  13.289 +
  13.290 +   CMPIInstance *instance = NULL;
  13.291 +   if (generateInstance(className, &instance, properties, &status))
  13.292 +         goto exit;
  13.293 +
  13.294 +   CMReturnInstance(results, instance);
  13.295 +
  13.296 +   _SBLIM_TRACE(2,("--- instance found"));
  13.297 +
  13.298 +exit:
  13.299 +   CMReturnDone(results);
  13.300 +   _SBLIM_RETURNSTATUS(status);
  13.301 +}
  13.302 +
  13.303 +// ----------------------------------------------------------------------------
  13.304 +// SetInstance()
  13.305 +// Save modified instance data for the specified instance.
  13.306 +// ----------------------------------------------------------------------------
  13.307 +static CMPIStatus SetInstance(
  13.308 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.309 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  13.310 +		CMPIResult * results,		/* [out] Results of this operation. */
  13.311 +		CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
  13.312 +		CMPIInstance * newinstance)	/* [in] Contains the new instance data. */
  13.313 +{
  13.314 +   CMPIStatus status;	/* Return status of CIM operations. */
  13.315 +   
  13.316 +   CMSetStatus(&status, CMPI_RC_ERR_NOT_SUPPORTED);
  13.317 +   CMReturnDone(results);
  13.318 +
  13.319 +   return (status);
  13.320 +}
  13.321 +
  13.322 +// ----------------------------------------------------------------------------
  13.323 +// CreateInstance()
  13.324 +// Create a new instance from the specified instance data.
  13.325 +// ----------------------------------------------------------------------------
  13.326 +static CMPIStatus CreateInstance(
  13.327 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.328 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  13.329 +		CMPIResult * results,		/* [out] Results of this operation. */
  13.330 +		CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
  13.331 +		CMPIInstance * newinstance)	/* [in] Contains the new instance data. */
  13.332 +{
  13.333 +   CMPIStatus status;	/* Return status of CIM operations. */
  13.334 +   
  13.335 +   CMSetStatus(&status, CMPI_RC_ERR_NOT_SUPPORTED);
  13.336 +   CMReturnDone(results);
  13.337 +
  13.338 +   return (status);
  13.339 +}
  13.340 +
  13.341 +// ----------------------------------------------------------------------------
  13.342 +// DeleteInstance()
  13.343 +// Delete or remove the specified instance from the system.
  13.344 +// ----------------------------------------------------------------------------
  13.345 +static CMPIStatus DeleteInstance(
  13.346 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.347 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  13.348 +		CMPIResult * results,		/* [out] Results of this operation. */
  13.349 +		CMPIObjectPath * reference)	/* [in] Contains the target namespace, classname and object path. */
  13.350 +{
  13.351 +   CMPIStatus status;	/* Return status of CIM operations. */
  13.352 +   
  13.353 +   CMSetStatus(&status, CMPI_RC_ERR_NOT_SUPPORTED);
  13.354 +   CMReturnDone(results);
  13.355 +
  13.356 +   return (status);
  13.357 +}
  13.358 +
  13.359 +
  13.360 +// ----------------------------------------------------------------------------
  13.361 +// ExecQuery()
  13.362 +// Return a list of all the instances that satisfy the specified query filter.
  13.363 +// ----------------------------------------------------------------------------
  13.364 +static CMPIStatus ExecQuery(
  13.365 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.366 +		CMPIContext * context,		/* [in] Additional context info, if any. */
  13.367 +		CMPIResult * results,		/* [out] Results of this operation. */
  13.368 +		CMPIObjectPath * reference,	/* [in] Contains the target namespace and classname. */
  13.369 +		char * language,		/* [in] Name of the query language. */
  13.370 +		char * query)			/* [in] Text of the query written in the query language. */
  13.371 +{
  13.372 +   CMPIStatus status = {CMPI_RC_OK, NULL};      /* Return status of CIM operations. */
  13.373 +   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
  13.374 +
  13.375 +   _SBLIM_ENTER("ExecQuery");
  13.376 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  13.377 +   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  13.378 +   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
  13.379 +   _SBLIM_TRACE(2, ("--- language=\"%s\"", language));
  13.380 +   _SBLIM_TRACE(2, ("--- query=\"%s\"", query));
  13.381 +   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
  13.382 +
  13.383 +   /* EXECQUERY() IS NOT YET SUPPORTED FOR THIS CLASS */
  13.384 +   CMSetStatus(&status, CMPI_RC_ERR_NOT_SUPPORTED);
  13.385 +
  13.386 +   CMReturnDone(results);
  13.387 +
  13.388 +exit:
  13.389 +   _SBLIM_RETURNSTATUS(status);
  13.390 +}
  13.391 +
  13.392 +// ----------------------------------------------------------------------------
  13.393 +// Initialize()
  13.394 +// Perform any necessary initialization immediately after this provider is
  13.395 +// first loaded.
  13.396 +// ----------------------------------------------------------------------------
  13.397 +static void Initialize(
  13.398 +		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
  13.399 +		CMPIContext * context)		/* [in] Additional context info, if any. */
  13.400 +{
  13.401 +   CMPIString *temp;
  13.402 +   
  13.403 +   _SBLIM_ENTER("Initialize");
  13.404 +   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
  13.405 +   //   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
  13.406 +
  13.407 +   /* Nothing needs to be done to initialize this provider */
  13.408 +
  13.409 +exit:
  13.410 +   _SBLIM_RETURN();
  13.411 +}
  13.412 +
  13.413 +// ============================================================================
  13.414 +// CMPI INSTANCE PROVIDER FUNCTION TABLE SETUP
  13.415 +// ============================================================================
  13.416 +CMInstanceMIStub( , Xen_RegisteredProfiles, _BROKER, Initialize(&mi, ctx));
  13.417 +