os-cmpi-xen

changeset 128:0bf03964b16c

Ported Xen_ComputerSystemCapabilities to 'Cmpilify' interface.
Removed corresponding resource files that are no longer used.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Jim Fehlig <jfehlig@novell.com>
date Mon Jul 16 12:33:53 2007 -0600 (2007-07-16)
parents 152ceecb9f39
children 6494910456a8
files ChangeLog src/Makefile.am src/Xen_ComputerSystemCapabilities.c src/Xen_ComputerSystemCapabilities_Resource.c src/Xen_ComputerSystemCapabilities_Resource.h
line diff
     1.1 --- a/ChangeLog	Mon Jul 16 12:15:30 2007 -0600
     1.2 +++ b/ChangeLog	Mon Jul 16 12:33:53 2007 -0600
     1.3 @@ -1,3 +1,10 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Mon Jul 16 12:31:38 MDT 2007 - jfehlig@novell.com
     1.6 +
     1.7 +         - Ported Xen_ComputerSystemCapabilities to 'Cmpilify'
     1.8 +           interface.  Removed corresponding resource files that
     1.9 +           are no longer used.
    1.10 +
    1.11  -------------------------------------------------------------------
    1.12  Mon Jul 16 12:09:50 MDT 2007 - jfehlig@novell.com
    1.13  
     2.1 --- a/src/Makefile.am	Mon Jul 16 12:15:30 2007 -0600
     2.2 +++ b/src/Makefile.am	Mon Jul 16 12:33:53 2007 -0600
     2.3 @@ -365,7 +365,7 @@ libXen_RegisteredProfiles_la_SOURCES = X
     2.4  libXen_RegisteredProfiles_la_LIBADD = libXen_ProviderCommon.la
     2.5  libXen_RegisteredProfiles_la_LDFLAGS = -module -avoid-version -no-undefined
     2.6  
     2.7 -libXen_ComputerSystemCapabilities_la_SOURCES = Xen_ComputerSystemCapabilities.c Xen_ComputerSystemCapabilities_Resource.c
     2.8 +libXen_ComputerSystemCapabilities_la_SOURCES = Xen_ComputerSystemCapabilities.c
     2.9  libXen_ComputerSystemCapabilities_la_CFLAGS = -I../ @LIBXEN_CFLAGS@
    2.10  libXen_ComputerSystemCapabilities_la_LIBADD = libXen_ProviderCommon.la
    2.11  libXen_ComputerSystemCapabilities_la_LDFLAGS = -module -avoid-version -no-undefined
     3.1 --- a/src/Xen_ComputerSystemCapabilities.c	Mon Jul 16 12:15:30 2007 -0600
     3.2 +++ b/src/Xen_ComputerSystemCapabilities.c	Mon Jul 16 12:33:53 2007 -0600
     3.3 @@ -1,4 +1,4 @@
     3.4 -// Copyright (C) 2006 Novell, Inc.
     3.5 +// Copyright (C) 2007 Novell, Inc.
     3.6  //
     3.7  //    This library is free software; you can redistribute it and/or
     3.8  //    modify it under the terms of the GNU Lesser General Public
     3.9 @@ -15,442 +15,277 @@
    3.10  //    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.11  // ============================================================================
    3.12  // Authors:       Jim Fehlig, <jfehlig@novell.com>
    3.13 -// Contributors:
    3.14 +// Contributors:  
    3.15  // Description:   A class used to represent the capabilities of a
    3.16  //                Xen_ComputerSystem, i.e. a virtual computer system.
    3.17  // ============================================================================
    3.18  
    3.19 -/* Include the required CMPI data types, function headers, and macros */
    3.20 -#include "cmpidt.h"
    3.21 -#include "cmpift.h"
    3.22 -#include "cmpimacs.h"
    3.23 +/* Common declarations for each CMPI "Cimpler" instance provider */
    3.24 +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    3.25 +#include <cmpidt.h>
    3.26 +#include <cmpimacs.h>
    3.27 +
    3.28 +#include "cmpilify.h"
    3.29 +
    3.30 +
    3.31 +static const CMPIInstanceMI* mi;
    3.32 +
    3.33  
    3.34 -/* Include utility functions */
    3.35 -#include "cmpiutil.h"
    3.36 +#define _BROKER (((CMPILIFYInstanceMI*)(mi->hdl))->brkr)
    3.37 +#define _CLASS (((CMPILIFYInstanceMI*)(mi->hdl))->cn)
    3.38 +#define _KEYS (((CMPILIFYInstanceMI*)(mi->hdl))->kys)
    3.39 +
    3.40 +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    3.41  
    3.42 -/* Include _SBLIM_TRACE() logging support */
    3.43 +#include <stdlib.h>
    3.44 +#include <assert.h>
    3.45 +
    3.46 +#include <xen_common.h>
    3.47 +
    3.48  #include "cmpitrace.h"
    3.49 -
    3.50 -/* Include Xen utilities */
    3.51  #include "xen_utils.h"
    3.52  
    3.53 -/* Include the abstract resource access functions and abstracted _RESOURCES and _RESOURCE data types. */
    3.54 -#include "Xen_ComputerSystemCapabilities_Resource.h"
    3.55 -
    3.56 -
    3.57 -// ----------------------------------------------------------------------------
    3.58 -// COMMON GLOBAL VARIABLES
    3.59 -// ----------------------------------------------------------------------------
    3.60 -
    3.61 -/* Handle to the CIM broker. Initialized when the provider lib is loaded. */
    3.62 -static const CMPIBroker *_BROKER;
    3.63  
    3.64  /* Xen session object.  Initialize when the provider is loaded, close when
    3.65   * provider unloaded. */
    3.66  static xen_utils_session *session = NULL;
    3.67  
    3.68  
    3.69 -// ============================================================================
    3.70 -// CMPI INSTANCE PROVIDER FUNCTION TABLE
    3.71 -// ============================================================================
    3.72 -
    3.73 -// ----------------------------------------------------------------------------
    3.74 -// Info for the class supported by the instance provider
    3.75 -// ----------------------------------------------------------------------------
    3.76 -
    3.77 -/* Name of the class implemented by this instance provider. */
    3.78 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    3.79 -static char * _CLASSNAME = "Xen_ComputerSystemCapabilities";
    3.80 -
    3.81 -/* NULL terminated list of key properties of this class. */
    3.82 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    3.83 -const static char * _KEYNAMES[] = {"InstanceID", NULL};
    3.84 +static CMPIrc load()
    3.85 +{
    3.86 +   /* Initialized Xen session object. */
    3.87 +   if (!session)
    3.88 +      xen_utils_xen_init(&session);
    3.89  
    3.90 -// ----------------------------------------------------------------------------
    3.91 -// Cleanup()
    3.92 -// Perform any necessary cleanup immediately before this provider is unloaded.
    3.93 -// ----------------------------------------------------------------------------
    3.94 -static CMPIStatus Cleanup(
    3.95 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
    3.96 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
    3.97 -        CMPIBoolean terminating)   /* [in] True if MB is terminating */
    3.98 +   return CMPI_RC_OK;
    3.99 +}
   3.100 +
   3.101 +
   3.102 +static CMPIrc unload(const int terminating)
   3.103  {
   3.104 -   CMPIStatus status = { CMPI_RC_OK, NULL };	/* Return status of CIM operations. */
   3.105 -
   3.106 -   _SBLIM_ENTER("Cleanup");
   3.107 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.108 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.109 -
   3.110 +   (void)terminating;
   3.111 +   
   3.112 +   /* Close Xen session object. */
   3.113     if (session) {
   3.114        xen_utils_xen_close(session);
   3.115        session = NULL;
   3.116     }
   3.117 -   _SBLIM_RETURNSTATUS(status);
   3.118 +
   3.119 +   return CMPI_RC_OK;
   3.120  }
   3.121  
   3.122 -// ----------------------------------------------------------------------------
   3.123 -// EnumInstanceNames()
   3.124 -// Return a list of all the instances names (return their object paths only).
   3.125 -// ----------------------------------------------------------------------------
   3.126 -static CMPIStatus EnumInstanceNames(
   3.127 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.128 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.129 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.130 -		const CMPIObjectPath * reference) 	/* [in] Contains target namespace and classname. */
   3.131 +
   3.132 +static CMPIrc begin(void **res_list, const char **properties)
   3.133  {
   3.134 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.135 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.136 -   _RESOURCE * resource;			/* Handle to each system resource. */
   3.137 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.138 -   int found = 0;				/* Found any instances? */
   3.139 -  
   3.140 -   _SBLIM_ENTER("EnumInstanceNames");
   3.141 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.142 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.143 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.144 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.145 -
   3.146 +   xen_domain_resources *resources;
   3.147 +   
   3.148 +   (void)properties;
   3.149 +   
   3.150     if (!xen_utils_validate_session(&session)) {
   3.151 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.152 -      goto exit;
   3.153 -   }
   3.154 -
   3.155 -   /* Get a handle to the list of system resources. */
   3.156 -   if (!Xen_ComputerSystemCapabilities_getResources(session, &resources)) {
   3.157 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.158 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.159 -      goto exit;
   3.160 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.161 +                   ("--- Unable to establish connection with Xend"));
   3.162 +      return CMPI_RC_ERR_FAILED;
   3.163     }
   3.164  
   3.165 -   /* Enumerate thru the list of system resources and return a CMPIInstance for each. */
   3.166 -   while (Xen_ComputerSystemCapabilities_getNextResource(session, resources, &resource)) {
   3.167 -      /* Create a new CMPIInstance to store this resource. */
   3.168 -      CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.169 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.170 -         _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.171 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.172 -         goto exit;
   3.173 -      }
   3.174 -
   3.175 -      /* Set the instance property values from the resource data. */
   3.176 -      if (!Xen_ComputerSystemCapabilities_setInstanceFromResource(resource, instance, _BROKER)) {
   3.177 -         _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.178 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.179 -         goto exit;
   3.180 -      }
   3.181 -
   3.182 -      /* Free the resource data. */
   3.183 -      if (!Xen_ComputerSystemCapabilities_freeResource(resource)) {
   3.184 -         _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.185 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.186 -         goto exit;
   3.187 -      }
   3.188 -
   3.189 -      /* Return the CMPIObjectPath for this instance. */
   3.190 -      CMPIObjectPath * objectpath = CMGetObjectPath(instance, &status);
   3.191 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
   3.192 -         _SBLIM_TRACE(1,("--- CMGetObjectPath() failed - %s", CMGetCharPtr(status.msg)));
   3.193 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot get CMPIObjectPath for instance");
   3.194 -         goto exit;
   3.195 -      }
   3.196 -      CMSetNameSpace(objectpath, namespace); /* Note - CMGetObjectPath() does not preserve the namespace! */
   3.197 -     
   3.198 -      _SBLIM_TRACE(3,("--- objectpath=\"%s\"", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL))));
   3.199 -      CMReturnObjectPath(results, objectpath);
   3.200 -      found++;
   3.201 -   }
   3.202 -
   3.203 -   _SBLIM_TRACE(2,("--- %d object paths found", found));
   3.204 -   CMReturnDone(results);
   3.205 -
   3.206 -exit:
   3.207 -   /* Free the list of system resources. */
   3.208 -   if (!Xen_ComputerSystemCapabilities_freeResources(resources)) {
   3.209 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.210 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.211 -   }
   3.212 -  
   3.213 -   _SBLIM_RETURNSTATUS(status);
   3.214 -}
   3.215 -
   3.216 -// ----------------------------------------------------------------------------
   3.217 -// EnumInstances()
   3.218 -// Return a list of all the instances (return all the instance data).
   3.219 -// ----------------------------------------------------------------------------
   3.220 -static CMPIStatus EnumInstances(
   3.221 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.222 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.223 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.224 -		const CMPIObjectPath * reference,	/* [in] Contains target namespace and classname. */
   3.225 -		const char ** properties)	/* [in] List of desired properties (NULL=all). */
   3.226 -{
   3.227 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.228 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.229 -   _RESOURCE * resource;			/* Handle to each system resource. */
   3.230 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.231 -   int found = 0;				/* Found any resource instances? */
   3.232 -
   3.233 -   _SBLIM_ENTER("EnumInstances");
   3.234 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.235 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.236 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.237 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.238 -
   3.239 -   if (!xen_utils_validate_session(&session)) {
   3.240 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.241 -      goto exit;
   3.242 -   }
   3.243 -
   3.244 -   /* Get a handle to the list of system resources. */
   3.245 -   if (!Xen_ComputerSystemCapabilities_getResources(session, &resources)) {
   3.246 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.247 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.248 -      goto exit;
   3.249 +   if (!xen_utils_get_domain_resources(session, &resources)) {
   3.250 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.251 +                   ("--- failed to retrieve domain resources from Xend:"));
   3.252 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.253 +                            xen_utils_trace_error(session->xen));
   3.254 +      return CMPI_RC_ERR_FAILED;
   3.255     }
   3.256  
   3.257 -   /* Enumerate thru the list of system resources and return a CMPIInstance for each. */
   3.258 -   while (Xen_ComputerSystemCapabilities_getNextResource(session, resources, &resource)) {
   3.259 -      /* Create a new CMPIInstance to store this resource. */
   3.260 -      CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.261 -      if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.262 -         _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.263 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.264 -         goto exit;
   3.265 -      }
   3.266 +   *res_list = (void *)resources;
   3.267 +   return CMPI_RC_OK;
   3.268 +}
   3.269  
   3.270 -      /* Setup a filter to only return the desired properties. */
   3.271 -      status = CMSetPropertyFilter(instance, properties, _KEYNAMES);
   3.272 -      if (status.rc != CMPI_RC_OK) {
   3.273 -         _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg)));
   3.274 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter");
   3.275 -         goto exit;
   3.276 -      }
   3.277 -
   3.278 -      /* Set the instance property values from the resource data. */
   3.279 -      if (!Xen_ComputerSystemCapabilities_setInstanceFromResource(resource, instance, _BROKER)) {
   3.280 -         _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.281 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.282 -         goto exit;
   3.283 -      }
   3.284  
   3.285 -      /* Free the resource data. */
   3.286 -      if (!Xen_ComputerSystemCapabilities_freeResource(resource)) {
   3.287 -         _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.288 -         CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.289 -         goto exit;
   3.290 -      }
   3.291 -
   3.292 -      /* Return the CMPIInstance for this instance. */
   3.293 -      _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
   3.294 -      CMReturnInstance(results, instance);
   3.295 -      found++;
   3.296 -   }
   3.297 -
   3.298 -   _SBLIM_TRACE(2,("--- %d instances found", found));
   3.299 -   CMReturnDone(results);
   3.300 -
   3.301 -exit:
   3.302 -   /* Free the list of system resources. */
   3.303 -   if (!Xen_ComputerSystemCapabilities_freeResources(resources)) {
   3.304 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.305 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.306 -   }
   3.307 -
   3.308 -   _SBLIM_RETURNSTATUS(status);
   3.309 +static void end(void *res_list)
   3.310 +{
   3.311 +   if (res_list)
   3.312 +      xen_utils_free_domain_resources((xen_domain_resources *)res_list);
   3.313  }
   3.314  
   3.315 -// ----------------------------------------------------------------------------
   3.316 -// GetInstance()
   3.317 -// Return the instance data for the specified instance only.
   3.318 -// ----------------------------------------------------------------------------
   3.319 -static CMPIStatus GetInstance(
   3.320 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.321 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.322 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.323 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.324 -		const char ** properties)		/* [in] List of desired properties (NULL=all). */
   3.325 +
   3.326 +static CMPIrc getnext(void *res_list, void **res, const char **properties)
   3.327  {
   3.328 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
   3.329 -   _RESOURCES * resources = NULL;			/* Handle to the list of system resources. */
   3.330 -   _RESOURCE * resource;			/* Handle to the system resource. */
   3.331 -   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
   3.332 -   int found = 0;				/* Found the target instance? */
   3.333 +   xen_domain_resources *resources = (xen_domain_resources *)res_list;
   3.334 +   xen_vm_record *vm_rec;
   3.335 +   
   3.336 +   (void)properties;
   3.337 +   
   3.338 +   if (resources == NULL || res == NULL)
   3.339 +      return CMPI_RC_ERR_FAILED;
   3.340 +   
   3.341 +   session->xen->ok = true;
   3.342 +   
   3.343 +   if (!xen_utils_get_next_domain_resource(session, resources, &vm_rec)) {
   3.344 +      _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
   3.345 +                   ("--- failed to retrieve domain resource from Xend:"));
   3.346 +      _SBLIM_TRACE_FUNCTION(_SBLIM_TRACE_LEVEL_ERROR,
   3.347 +                            xen_utils_trace_error(session->xen));
   3.348 +      return CMPI_RC_ERR_FAILED;
   3.349 +   }
   3.350 +      
   3.351 +   *res = (void *)vm_rec;
   3.352 +   return CMPI_RC_OK;
   3.353 +}
   3.354 +
   3.355  
   3.356 -   _SBLIM_ENTER("GetInstance");
   3.357 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.358 -   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.359 -   _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
   3.360 -   _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
   3.361 +static CMPIrc get(const void *res_id, void **res, const char **properties)
   3.362 +{
   3.363 +   CMPIInstance *inst = (CMPIInstance *)res_id;
   3.364 +   CMPIData data;
   3.365 +   CMPIStatus status = {CMPI_RC_OK, NULL};
   3.366 +   char *inst_id;
   3.367 +   xen_vm_record *vm_rec;
   3.368  
   3.369 -   if (!xen_utils_validate_session(&session)) {
   3.370 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to xen daemon");
   3.371 -      goto exit;
   3.372 -   }
   3.373 +   (void)properties;
   3.374 +   
   3.375 +   if (CMIsNullObject(inst) || res == NULL)
   3.376 +      return CMPI_RC_ERR_FAILED;
   3.377  
   3.378 -   /* Get a handle to the list of system resources. */
   3.379 -   if (!Xen_ComputerSystemCapabilities_getResources(session, &resources)) {
   3.380 -      _SBLIM_TRACE(1,("--- _getResources() failed"));
   3.381 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to get list of system resources");
   3.382 -      goto exit;
   3.383 -   }
   3.384 +   data = CMGetProperty(inst, "InstanceID", &status);
   3.385 +   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(data))
   3.386 +      return CMPI_RC_ERR_FAILED;
   3.387 +
   3.388 +   /* Extract the domain name string from the CMPIString. */
   3.389 +   inst_id = CMGetCharPtr(data.value.string);
   3.390 +   if ((inst_id == NULL) || (*inst_id == '\0'))
   3.391 +      return CMPI_RC_ERR_FAILED;
   3.392  
   3.393 -   /* Get the target resource. */
   3.394 -   found = Xen_ComputerSystemCapabilities_getResourceForObjectPath(session, resources, &resource, reference);
   3.395 -   if (!found || (resource == NULL)) {
   3.396 -      _SBLIM_TRACE(1,("--- Target instance not found"));
   3.397 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Target instance not found");
   3.398 -      goto exit;
   3.399 +   xen_vm_set *vms;
   3.400 +   if (!xen_vm_get_by_name_label(session->xen, &vms, inst_id))
   3.401 +      return CMPI_RC_ERR_FAILED;
   3.402 +
   3.403 +   assert(vms->size == 1);
   3.404 +   if (!xen_vm_get_record(session->xen, &vm_rec, vms->contents[0])) {
   3.405 +      /* Error description in session object! */
   3.406 +      xen_vm_set_free(vms);
   3.407 +      return CMPI_RC_ERR_FAILED;
   3.408     }
   3.409  
   3.410 -   /* Create a new CMPIInstance to store this resource. */
   3.411 -   CMPIInstance * instance = _CMNewInstance(_BROKER, namespace, _CLASSNAME, &status);
   3.412 -   if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instance)) {
   3.413 -      _SBLIM_TRACE(1,("--- CMNewInstance() failed - %s", CMGetCharPtr(status.msg)));
   3.414 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR, "Cannot create new CMPIInstance");
   3.415 -      goto exit;
   3.416 -   }
   3.417 -
   3.418 -   /* Setup a filter to only return the desired properties. */
   3.419 -   status = CMSetPropertyFilter(instance, properties, _KEYNAMES);
   3.420 -   if (status.rc != CMPI_RC_OK) {
   3.421 -      _SBLIM_TRACE(1, ("--- CMSetPropertyFilter() failed - %s", CMGetCharPtr(status.msg)));
   3.422 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Cannot set property filter");
   3.423 -      goto exit;
   3.424 -   }
   3.425 -
   3.426 -   /* Set the instance property values from the resource data. */
   3.427 -   if (!Xen_ComputerSystemCapabilities_setInstanceFromResource(resource, instance, _BROKER)) {
   3.428 -      _SBLIM_TRACE(1,("--- _setInstanceFromResource() failed"));
   3.429 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to set property values from resource data");
   3.430 -      goto exit;
   3.431 -   }
   3.432 -
   3.433 -   /* Free the resource data. */
   3.434 -   if (!Xen_ComputerSystemCapabilities_freeResource(resource)) {
   3.435 -      _SBLIM_TRACE(1,("--- _freeResource() failed"));
   3.436 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free resource data");
   3.437 -      goto exit;
   3.438 -   }
   3.439 -
   3.440 -   /* Return the CMPIInstance for this instance. */
   3.441 -   _SBLIM_TRACE(3,("--- instance=\"%s\"", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
   3.442 -   CMReturnInstance(results, instance);
   3.443 -
   3.444 -   _SBLIM_TRACE(2,("--- instance found"));
   3.445 -   CMReturnDone(results);
   3.446 -
   3.447 -exit:
   3.448 -   /* Free the list of system resources. */
   3.449 -   if (!Xen_ComputerSystemCapabilities_freeResources(resources)) {
   3.450 -      _SBLIM_TRACE(1,("--- _freeResources() failed"));
   3.451 -      CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Failed to free list of system resources");
   3.452 -   }
   3.453 -
   3.454 -   _SBLIM_RETURNSTATUS(status);
   3.455 +   xen_vm_set_free(vms);
   3.456 +   *res = (void *)vm_rec;
   3.457 +   return CMPI_RC_OK;
   3.458  }
   3.459  
   3.460 -// ----------------------------------------------------------------------------
   3.461 -// SetInstance()
   3.462 -// Save modified instance data for the specified instance.
   3.463 -// ----------------------------------------------------------------------------
   3.464 -static CMPIStatus SetInstance(
   3.465 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.466 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.467 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.468 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.469 -		const CMPIInstance * newinstance,	/* [in] Contains the new instance data. */
   3.470 -        const char **properties)  /* [in] Contains list of modified properties. */
   3.471 +
   3.472 +static void release(void *res)
   3.473  {
   3.474 -   _SBLIM_ENTER("SetInstance");
   3.475 -
   3.476 -   /* Do not support modification of capabilities. */
   3.477 -   CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL};
   3.478 -   
   3.479 -   _SBLIM_RETURNSTATUS(status);
   3.480 -}
   3.481 -
   3.482 -// ----------------------------------------------------------------------------
   3.483 -// CreateInstance()
   3.484 -// Create a new instance from the specified instance data.
   3.485 -// ----------------------------------------------------------------------------
   3.486 -static CMPIStatus CreateInstance(
   3.487 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.488 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.489 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.490 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace, classname and object path. */
   3.491 -		const CMPIInstance * newinstance)	/* [in] Contains the new instance data. */
   3.492 -{
   3.493 -   _SBLIM_ENTER("CreateInstance");
   3.494 -
   3.495 -   /* Do not support explicit creation of capabilities. */
   3.496 -   CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL};
   3.497 -
   3.498 -   _SBLIM_RETURNSTATUS(status);
   3.499 -}
   3.500 -
   3.501 -// ----------------------------------------------------------------------------
   3.502 -// DeleteInstance()
   3.503 -// Delete or remove the specified instance from the system.
   3.504 -// ----------------------------------------------------------------------------
   3.505 -static CMPIStatus DeleteInstance(
   3.506 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.507 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.508 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.509 -		const CMPIObjectPath * reference)	/* [in] Contains the target namespace, classname and object path. */
   3.510 -{
   3.511 -   _SBLIM_ENTER("DeleteInstance");
   3.512 -
   3.513 -   /* Do not support explicit deletion of capabilities. */
   3.514 -   CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL};
   3.515 -
   3.516 -   _SBLIM_RETURNSTATUS(status);
   3.517 +   if (res)
   3.518 +      xen_vm_record_free((xen_vm_record *)res);
   3.519  }
   3.520  
   3.521  
   3.522 -// ----------------------------------------------------------------------------
   3.523 -// ExecQuery()
   3.524 -// Return a list of all the instances that satisfy the specified query filter.
   3.525 -// ----------------------------------------------------------------------------
   3.526 -static CMPIStatus ExecQuery(
   3.527 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.528 -		const CMPIContext * context,		/* [in] Additional context info, if any. */
   3.529 -		const CMPIResult * results,		/* [out] Results of this operation. */
   3.530 -		const CMPIObjectPath * reference,	/* [in] Contains the target namespace and classname. */
   3.531 -		const char * language,		/* [in] Name of the query language. */
   3.532 -		const char * query)			/* [in] Text of the query written in the query language. */
   3.533 +static CMPIrc add(const void *res_id, const void *res)
   3.534  {
   3.535 -   _SBLIM_ENTER("ExecQuery");
   3.536 +   (void)res_id;
   3.537 +   (void)res;
   3.538 +   
   3.539 +   return CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */
   3.540 +}
   3.541  
   3.542 -   /* 
   3.543 -    * TODO:
   3.544 -    * Currently not supported.
   3.545 -    */
   3.546 -   CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL};
   3.547  
   3.548 -   _SBLIM_RETURNSTATUS(status);
   3.549 +static CMPIrc delete(const void *res_id)
   3.550 +{
   3.551 +   (void)res_id;
   3.552 +   
   3.553 +   return  CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */
   3.554  }
   3.555  
   3.556 -// ----------------------------------------------------------------------------
   3.557 -// Initialize()
   3.558 -// Perform any necessary initialization immediately after this provider is
   3.559 -// first loaded.
   3.560 -// ----------------------------------------------------------------------------
   3.561 -static void Initialize(
   3.562 -		CMPIInstanceMI * self,		/* [in] Handle to this provider (i.e. 'self'). */
   3.563 -		const CMPIContext * context)		/* [in] Additional context info, if any. */
   3.564 +
   3.565 +static CMPIrc modify(const void *res_id, const void *modified_res,
   3.566 +                     const char **properties)
   3.567 +{
   3.568 +   (void)res_id;
   3.569 +   (void)modified_res;
   3.570 +   (void)properties;
   3.571 +   
   3.572 +   return  CMPI_RC_ERR_NOT_SUPPORTED; /* unsupported */
   3.573 +}
   3.574 +  
   3.575 +
   3.576 +/* Set CMPIInstance properties from the resource data. */
   3.577 +static CMPIrc setproperties(CMPIInstance *inst, const void *res,
   3.578 +                            const char **properties)
   3.579  {
   3.580 -   _SBLIM_ENTER("Initialize");
   3.581 -   _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
   3.582 -   //   _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
   3.583 +   xen_vm_record *vm_rec = (xen_vm_record *)res;
   3.584 +   CMPIArray *statesSupported = CMNewArray(_BROKER, 6, CMPI_uint16, NULL);
   3.585 +   
   3.586 +   (void)properties;
   3.587 +   
   3.588 +   if (vm_rec == NULL)
   3.589 +      return CMPI_RC_ERR_FAILED;
   3.590 +
   3.591 +   if (CMIsNullObject(inst))
   3.592 +      return CMPI_RC_ERR_FAILED;
   3.593 +
   3.594 +  /* Set the CMPIInstance properties from the resource data. */
   3.595 +   CMSetProperty(inst, "InstanceID", (CMPIValue *)vm_rec->name_label, CMPI_chars);
   3.596 +   CMSetProperty(inst, "ElementName", (CMPIValue *)vm_rec->name_label, CMPI_chars);
   3.597  
   3.598 -   /* Initialized Xen session object. */
   3.599 -   if (session == NULL)
   3.600 -      xen_utils_xen_init(&session);
   3.601 +   /*
   3.602 +    * TODO:
   3.603 +    * Do we want to support changing the name of a domain?
   3.604 +    */
   3.605 +   int nameEditSupported = 0;
   3.606 +   CMSetProperty(inst, "ElementNameEditSupported",
   3.607 +                 (CMPIValue *)&nameEditSupported, CMPI_boolean);
   3.608  
   3.609 -   _SBLIM_RETURN();
   3.610 +   int state = 2; /* 'Enabled' */
   3.611 +   CMSetArrayElementAt(statesSupported, 0, (CMPIValue *)&state, CMPI_uint16);
   3.612 +   state = 3; /* 'Disabled' */
   3.613 +   CMSetArrayElementAt(statesSupported, 1, (CMPIValue *)&state, CMPI_uint16);
   3.614 +   state = 6; /* 'Offline' aka 'Suspend' */
   3.615 +   CMSetArrayElementAt(statesSupported, 2, (CMPIValue *)&state, CMPI_uint16);
   3.616 +   state = 9; /* 'Quiesce' */
   3.617 +   CMSetArrayElementAt(statesSupported, 3, (CMPIValue *)&state, CMPI_uint16);
   3.618 +   state = 10; /* 'Reboot' */
   3.619 +   CMSetArrayElementAt(statesSupported, 4, (CMPIValue *)&state, CMPI_uint16);
   3.620 +   state = 11; /* 'Reset' */
   3.621 +   CMSetArrayElementAt(statesSupported, 5, (CMPIValue *)&state, CMPI_uint16);
   3.622 +
   3.623 +   CMSetProperty(inst, "RequestedStatesSupported",
   3.624 +                 (CMPIValue *)&statesSupported, CMPI_uint16A);
   3.625 +
   3.626 +   return CMPI_RC_OK;
   3.627  }
   3.628  
   3.629 -// ============================================================================
   3.630 -// CMPI INSTANCE PROVIDER FUNCTION TABLE SETUP
   3.631 -// ============================================================================
   3.632 -CMInstanceMIStub( , Xen_ComputerSystemCapabilities, _BROKER, Initialize(&mi, ctx));
   3.633 +
   3.634 +/*
   3.635 + * Set resource data from the CMPIInstance properties.  Only needs to
   3.636 + * be implemented if add() and/or modify() are supported.
   3.637 + */
   3.638 +static CMPIrc extract(void **res, const CMPIInstance *inst,
   3.639 +                      const char **properties)
   3.640 +{
   3.641 +   (void)res;
   3.642 +   (void)inst;
   3.643 +   (void)properties;
   3.644 +   
   3.645 +   return CMPI_RC_ERR_NOT_SUPPORTED;  /* unsupported */
   3.646 +}
   3.647 +
   3.648 +
   3.649 +/* Get resource id from CMPIInstance properties. */
   3.650 +static CMPIrc extractid(void **res_id, const CMPIInstance* inst)
   3.651 +{
   3.652 +   *res_id = (void *)inst;
   3.653 +   return CMPI_RC_OK;
   3.654 +}
   3.655 +
   3.656 +
   3.657 +/* Release resource id created in resId4inst(). */
   3.658 +static void releaseid(void* res_id)
   3.659 +{
   3.660 +   (void)res_id;
   3.661 +}
   3.662 +
   3.663 +
   3.664 +/* NULL-terminated list of keys for this class. */
   3.665 +static char * keys[] = {"InstanceID", NULL};
   3.666 +
   3.667 +/* Setup CMPILIFY function tables and instance provider entry point.*/
   3.668 +/* CMPILIFYInstance1ROMIStub(<CLASS>,<PROVIDERNAME>,<KEYS>,<MIHANDLE>) */
   3.669 +CMPILIFYInstanceMIStub(Xen_ComputerSystemCapabilities, Xen_ComputerSystemCapabilities, keys, mi)
     4.1 --- a/src/Xen_ComputerSystemCapabilities_Resource.c	Mon Jul 16 12:15:30 2007 -0600
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,189 +0,0 @@
     4.4 -// Copyright (C) 2006 Novell, Inc.
     4.5 -//
     4.6 -//    This library is free software; you can redistribute it and/or
     4.7 -//    modify it under the terms of the GNU Lesser General Public
     4.8 -//    License as published by the Free Software Foundation; either
     4.9 -//    version 2.1 of the License, or (at your option) any later version.
    4.10 -//
    4.11 -//    This library is distributed in the hope that it will be useful,
    4.12 -//    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.13 -//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.14 -//    Lesser General Public License for more details.
    4.15 -//
    4.16 -//    You should have received a copy of the GNU Lesser General Public
    4.17 -//    License along with this library; if not, write to the Free Software
    4.18 -//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.19 -// ============================================================================
    4.20 -// Authors:       Jim Fehlig, <jfehlig@novell.com>
    4.21 -// Contributors:
    4.22 -// Description:   Encapsulates the resources used instrument
    4.23 -//                Xen_ComputerSystemCapabilities.
    4.24 -// ============================================================================
    4.25 -
    4.26 -#include <string.h>
    4.27 -#include <stdlib.h>
    4.28 -#include <unistd.h>
    4.29 -#include <assert.h>
    4.30 -
    4.31 -#include <xen_common.h>
    4.32 -#include <xen_vm.h>
    4.33 -
    4.34 -#include "Xen_ComputerSystemCapabilities_Resource.h"
    4.35 -
    4.36 -/* Include the required CMPI data types, function headers, and macros. */
    4.37 -#include "cmpidt.h"
    4.38 -#include "cmpift.h"
    4.39 -#include "cmpimacs.h"
    4.40 -
    4.41 -#include "xen_utils.h"
    4.42 -
    4.43 -// ----------------------------------------------------------------------------
    4.44 -
    4.45 -/* Get a handle to the list of all system resources for this class. */
    4.46 -int Xen_ComputerSystemCapabilities_getResources(xen_utils_session *session,
    4.47 -                                                _RESOURCES ** resources)
    4.48 -{
    4.49 -   return xen_utils_get_domain_resources(session, resources);
    4.50 -}
    4.51 -
    4.52 -// ----------------------------------------------------------------------------
    4.53 -
    4.54 -/* Free/deallocate/cleanup the resources list after use. */
    4.55 -int Xen_ComputerSystemCapabilities_freeResources(_RESOURCES * resources)
    4.56 -{
    4.57 -   return xen_utils_free_domain_resources(resources);
    4.58 -}
    4.59 -
    4.60 -// ----------------------------------------------------------------------------
    4.61 -
    4.62 -/* Iterator to get the next resource from the resources list. */
    4.63 -int Xen_ComputerSystemCapabilities_getNextResource(xen_utils_session *session,
    4.64 -                                                   _RESOURCES * resources,
    4.65 -                                                   _RESOURCE ** resource)
    4.66 -{
    4.67 -   return xen_utils_get_next_domain_resource(session, resources, resource);
    4.68 -}
    4.69 -
    4.70 -// ----------------------------------------------------------------------------
    4.71 -
    4.72 -/* Get the specific resource that matches the CMPI object path. */
    4.73 -int Xen_ComputerSystemCapabilities_getResourceForObjectPath(xen_utils_session *session,
    4.74 -                                                            _RESOURCES * resources,
    4.75 -                                                            _RESOURCE ** resource,
    4.76 -                                                            const CMPIObjectPath * objectpath)
    4.77 -{
    4.78 -   CMPIStatus status = {CMPI_RC_OK, NULL};	/* Return status of CIM operations. */
    4.79 -
    4.80 -   if (resources == NULL) return 0;
    4.81 -   if (CMIsNullObject(objectpath)) return 0;
    4.82 -
    4.83 -   /* Obtain the target domain name from the CMPIObjectPath "Name" key. */
    4.84 -   CMPIData namedata = CMGetKey(objectpath, "InstanceID", &status);
    4.85 -   if ((status.rc != CMPI_RC_OK) || CMIsNullValue(namedata)) return 0;
    4.86 -
    4.87 -   /* Extract the domain name string from the CMPIString. */
    4.88 -   char * domainname = CMGetCharPtr(namedata.value.string);
    4.89 -   if ((domainname == NULL) || (*domainname == '\0')) return 0;
    4.90 -
    4.91 -   /* Get the domain data for the target domain name. */
    4.92 -   xen_vm_set *vms;
    4.93 -   if (!xen_vm_get_by_name_label(session->xen, &vms, domainname)) {
    4.94 -      /* Error is in session object! */
    4.95 -      *resource = NULL;
    4.96 -      return 0;
    4.97 -   }
    4.98 -
    4.99 -   assert(vms->size == 1);
   4.100 -   if (!xen_vm_get_record(session->xen, resource, vms->contents[0])) {
   4.101 -      /* Error description in session object! */
   4.102 -      xen_vm_set_free(vms);
   4.103 -      return 0;
   4.104 -   }
   4.105 -
   4.106 -   xen_vm_set_free(vms);
   4.107 -
   4.108 -   return 1;
   4.109 -}
   4.110 -
   4.111 -// ----------------------------------------------------------------------------
   4.112 -
   4.113 -/* Free/deallocate/cleanup the resource after use. */
   4.114 -int Xen_ComputerSystemCapabilities_freeResource(_RESOURCE * resource)
   4.115 -{
   4.116 -   return xen_utils_free_domain_resource(resource);
   4.117 -}
   4.118 -
   4.119 -// ---------------------------------------------------------------------------- 
   4.120 -
   4.121 -/* Set the property values of a CMPI instance from a specific resource. */
   4.122 -int Xen_ComputerSystemCapabilities_setInstanceFromResource(_RESOURCE * resource,
   4.123 -                                                           const CMPIInstance * instance,
   4.124 -                                                           const CMPIBroker * broker)
   4.125 -{
   4.126 -   CMPIArray *statesSupported = CMNewArray(broker, 6, CMPI_uint16, NULL);
   4.127 -  
   4.128 -   if (resource == NULL) return 0;
   4.129 -   if (CMIsNullObject(instance)) return 0;
   4.130 -
   4.131 -   /* Set the CMPIInstance properties from the resource data. */
   4.132 -   CMSetProperty(instance, "InstanceID",(CMPIValue *)resource->name_label, CMPI_chars);
   4.133 -   CMSetProperty(instance, "ElementName",(CMPIValue *)resource->name_label, CMPI_chars);
   4.134 -
   4.135 -   /*
   4.136 -    * TODO:
   4.137 -    * Do we want to support changing the name of a domain?
   4.138 -    */
   4.139 -   int nameEditSupported = 0;
   4.140 -   CMSetProperty(instance, "ElementNameEditSupported",(CMPIValue *)&nameEditSupported, CMPI_boolean);
   4.141 -
   4.142 -   int state = 2; /* 'Enabled' */
   4.143 -   CMSetArrayElementAt(statesSupported, 0, (CMPIValue *)&state, CMPI_uint16);
   4.144 -   state = 3; /* 'Disabled' */
   4.145 -   CMSetArrayElementAt(statesSupported, 1, (CMPIValue *)&state, CMPI_uint16);
   4.146 -   state = 6; /* 'Offline' aka 'Suspend' */
   4.147 -   CMSetArrayElementAt(statesSupported, 2, (CMPIValue *)&state, CMPI_uint16);
   4.148 -   state = 9; /* 'Quiesce' */
   4.149 -   CMSetArrayElementAt(statesSupported, 3, (CMPIValue *)&state, CMPI_uint16);
   4.150 -   state = 10; /* 'Reboot' */
   4.151 -   CMSetArrayElementAt(statesSupported, 4, (CMPIValue *)&state, CMPI_uint16);
   4.152 -   state = 11; /* 'Reset' */
   4.153 -   CMSetArrayElementAt(statesSupported, 5, (CMPIValue *)&state, CMPI_uint16);
   4.154 -
   4.155 -   CMSetProperty(instance, "RequestedStatesSupported",(CMPIValue *)&statesSupported, CMPI_uint16A);
   4.156 -
   4.157 -   return 1;
   4.158 -}
   4.159 -
   4.160 -// ----------------------------------------------------------------------------
   4.161 -
   4.162 -/* Delete the specified resource from the system. */
   4.163 -int Xen_ComputerSystemCapabilities_deleteResource(_RESOURCES * resources,
   4.164 -                                                  _RESOURCE * resource)
   4.165 -{
   4.166 -   /* Unsupported. */
   4.167 -   return -1;
   4.168 -}
   4.169 -
   4.170 -// ----------------------------------------------------------------------------
   4.171 -
   4.172 -/* Modify the specified resource using the property values of a CMPI instance. */
   4.173 -int Xen_ComputerSystemCapabilities_setResourceFromInstance(_RESOURCE * resource,
   4.174 -                                                           const CMPIInstance * instance,
   4.175 -                                                           const CMPIBroker * broker)
   4.176 -{
   4.177 -   /* Unsupported. */
   4.178 -   return -1;
   4.179 -}
   4.180 -
   4.181 -// ----------------------------------------------------------------------------
   4.182 -
   4.183 -/* Create a new resource using the property values of a CMPI instance. */
   4.184 -int Xen_ComputerSystemCapabilities_createResourceFromInstance(_RESOURCES * resources,
   4.185 -                                                              _RESOURCE ** resource,
   4.186 -                                                              const CMPIInstance * instance,
   4.187 -                                                              const CMPIBroker * broker)
   4.188 -{
   4.189 -   /* Unsupported. */
   4.190 -   return -1;
   4.191 -}
   4.192 -
     5.1 --- a/src/Xen_ComputerSystemCapabilities_Resource.h	Mon Jul 16 12:15:30 2007 -0600
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,102 +0,0 @@
     5.4 -// Copyright (C) 2006 Novell, Inc.
     5.5 -//
     5.6 -//    This library is free software; you can redistribute it and/or
     5.7 -//    modify it under the terms of the GNU Lesser General Public
     5.8 -//    License as published by the Free Software Foundation; either
     5.9 -//    version 2.1 of the License, or (at your option) any later version.
    5.10 -//
    5.11 -//    This library is distributed in the hope that it will be useful,
    5.12 -//    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.13 -//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.14 -//    Lesser General Public License for more details.
    5.15 -//
    5.16 -//    You should have received a copy of the GNU Lesser General Public
    5.17 -//    License along with this library; if not, write to the Free Software
    5.18 -//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.19 -// ============================================================================
    5.20 -// Authors:       Jim Fehlig, <jfehlig@novell.com>
    5.21 -// Contributors:
    5.22 -// Description:   Encapsulates the resources used to instrument
    5.23 -//                Xen_ComputerSystemCapabilities.
    5.24 -// ============================================================================
    5.25 -
    5.26 -/* Include required libxen headers. */
    5.27 -#include <xen_common.h>
    5.28 -#include <xen_vm.h>
    5.29 -
    5.30 -#include "xen_utils.h"
    5.31 -
    5.32 -
    5.33 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    5.34 -/* DEFINE A HANDLE TO REPRESENT THE 'LIST' OF ALL SYSTEM RESOURCES.
    5.35 -   THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW THIS
    5.36 -   LIST IS IMPLEMENTED - IT MAY BE AN ARRAY, LINKED LIST, FILE, ETC.
    5.37 -   THIS HANDLE IS PASSED INTO THE APPROPRIATE RESOURCE ACCESS METHODS WHEN
    5.38 -   ACCESSING/ITERATING/ADDING/REMOVING RESOURCES INSTANCES. */
    5.39 -typedef xen_domain_resources  _RESOURCES;
    5.40 -
    5.41 -
    5.42 -/*** CUSTOMIZE FOR EACH PROVIDER ***/
    5.43 -/* DEFINE A HANDLE TO BE USED FOR EACH INSTANCE OF A SYSTEM RESOURCE.
    5.44 -   THE MAIN PROVIDER CODE DOES NOT NEED TO KNOW THE PARTICULARS OF HOW EACH
    5.45 -   RESOURCE IS REPRESENTED, BUT TYPICALLY IT IS A STRUCTURE MIRRORING THE
    5.46 -   PROPERTIES IN THE CIM CLASS. THIS HANDLE IS PASSED BETWEEN THE RESOURCE
    5.47 -   ACCESS METHODS WHEN MANIPULATING SPECIFIC RESOURCE INSTANCES. */
    5.48 -typedef xen_vm_record  _RESOURCE;
    5.49 -
    5.50 -/* NOTHING BELOW THIS LINE SHOULD NEED TO BE CHANGED. */
    5.51 -
    5.52 -/* Include the required CMPI data types. */
    5.53 -#include "cmpidt.h"
    5.54 -
    5.55 -// ----------------------------------------------------------------------------
    5.56 -// Generic resource access methods for CMPI providers.
    5.57 -// Return value:
    5.58 -//	-1 = Unsupported
    5.59 -//	 0 = Failed
    5.60 -//	 1 = OK
    5.61 -// ----------------------------------------------------------------------------
    5.62 -
    5.63 -/* Get a handle to the list of all system resources for this class. */
    5.64 -int Xen_ComputerSystemCapabilities_getResources(xen_utils_session *session,
    5.65 -                                                _RESOURCES ** resources);
    5.66 -
    5.67 -/* Free/deallocate/cleanup the resources list after use. */
    5.68 -int Xen_ComputerSystemCapabilities_freeResources(_RESOURCES * resources);
    5.69 -
    5.70 -/* Iterator to get the next resource from the resources list. */
    5.71 -int Xen_ComputerSystemCapabilities_getNextResource(xen_utils_session *session,
    5.72 -                                                   _RESOURCES * resources,
    5.73 -                                                   _RESOURCE ** resource);
    5.74 -
    5.75 -/* Get the specific resource that matches the CMPI object path. */
    5.76 -int Xen_ComputerSystemCapabilities_getResourceForObjectPath(xen_utils_session *session,
    5.77 -                                                            _RESOURCES * resources,
    5.78 -                                                            _RESOURCE ** resource,
    5.79 -                                                            const CMPIObjectPath * objectpath);
    5.80 -
    5.81 -/* Free/deallocate/cleanup a resource after use. */
    5.82 -int Xen_ComputerSystemCapabilities_freeResource(_RESOURCE * resource);
    5.83 -
    5.84 -/* Set the property values of a CMPI instance from a specific resource. */
    5.85 -int Xen_ComputerSystemCapabilities_setInstanceFromResource(_RESOURCE * resource,
    5.86 -                                                           const CMPIInstance * instance,
    5.87 -                                                           const CMPIBroker * broker);
    5.88 -
    5.89 -// THE FOLLOWING METHODS MAY/NOT BE SUPPORTED BY THE SYSTEM FOR THIS CLASS
    5.90 -
    5.91 -/* Delete the specified resource from the system. */
    5.92 -int Xen_ComputerSystemCapabilities_deleteResource(_RESOURCES * resources,
    5.93 -                                                  _RESOURCE * resource);
    5.94 -
    5.95 -/* Modify the specified resource using the property values of a CMPI instance. */
    5.96 -int Xen_ComputerSystemCapabilities_setResourceFromInstance(_RESOURCE * resource,
    5.97 -                                                           const CMPIInstance * instance,
    5.98 -                                                           const CMPIBroker * broker);
    5.99 -
   5.100 -/* Create a new resource using the property values of a CMPI instance. */
   5.101 -int Xen_ComputerSystemCapabilities_createResourceFromInstance(_RESOURCES * resources,
   5.102 -                                                              _RESOURCE ** resource,
   5.103 -                                                              const CMPIInstance * instance,
   5.104 -                                                              const CMPIBroker * broker);
   5.105 -