CMPIInstance * _makeInst_ServiceProcess( const CMPIBroker * _broker, const CMPIObjectPath * service, CMPIObjectPath * process, CMPIStatus * rc) { CMPIObjectPath * op = NULL; CMPIInstance * ci = NULL; _OSBASE_TRACE(4,("--- _makeInst_ServiceProcess() called")); /* create CMPIObjectPath of this association <_ClassName> */ op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(service,rc)), _ClassName, rc ); if( CMIsNullObject(op) ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); goto exit; } ci = CMNewInstance( _broker, op, rc); if( CMIsNullObject(ci) ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIInstance failed." ); _OSBASE_TRACE(4,("--- _makeInst_ServiceProcess() failed : %s",CMGetCharPtr(rc->msg))); goto exit; } CMSetProperty( ci, _RefLeft, (CMPIValue*)&(service), CMPI_ref ); CMSetProperty( ci, _RefRight, (CMPIValue*)&(process), CMPI_ref ); exit: _OSBASE_TRACE(4,("--- _makeInst_ServiceProcess() exited")); return ci; }
CMPIObjectPath * _makePath_TestClass( const CMPIBroker * _broker, const CMPIContext * ctx, const CMPIObjectPath * ref, CMPIStatus * rc, unsigned int theKey) { CMPIObjectPath * op = NULL; op = CMNewObjectPath( _broker, CMGetCharsPtr(CMGetNameSpace(ref,rc), NULL), _ClassName, rc ); if (CMIsNullObject(op)) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); goto exit; } CMAddKey(op, "theKey", &theKey, CMPI_uint32); exit: return op; }
CMPIStatus get_profile(const CMPIBroker *broker, const CMPIObjectPath *reference, const char **properties, const char* pfx, struct reg_prof *profile, CMPIInstance **_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance = NULL; CMPIArray *array; instance = get_typed_instance(broker, pfx, "RegisteredProfile", CIM_INTEROP_NS, false); if (instance == NULL) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Can't create RegisteredProfile instance"); goto out; } if (properties) { const char *keys[] = {"InstanceID", NULL}; CMSetPropertyFilter(instance, properties, keys); } CMSetProperty(instance, "InstanceID", (CMPIValue *)profile->reg_id, CMPI_chars); CMSetProperty(instance, "RegisteredOrganization", (CMPIValue *)&profile->reg_org, CMPI_uint16); CMSetProperty(instance, "RegisteredName", (CMPIValue *)profile->reg_name, CMPI_chars); CMSetProperty(instance, "RegisteredVersion", (CMPIValue *)profile->reg_version, CMPI_chars); array = CMNewArray(broker, 1, CMPI_uint16, &s); if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(array))) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to create CMPIArray object"); goto out; } CMSetArrayElementAt(array, 0, &profile->ad_types, CMPI_uint16); CMSetProperty(instance, "AdvertiseTypes", (CMPIValue *)&array, CMPI_uint16A); *_inst = instance; out: return s; }
CMPIStatus CWS_DirectoryGetInstance( CMPIInstanceMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * cop, const char ** properties) { CMPIInstance *in = NULL; CMPIStatus st = {CMPI_RC_OK,NULL}; CMPIData nd = CMGetKey(cop,"Name",&st); CWS_FILE filebuf; if (!silentMode()) fprintf(stderr,"--- CWS_DirectoryGetInstance() \n"); if (st.rc == CMPI_RC_OK && nd.type == CMPI_string && CWS_Get_File(CMGetCharsPtr(nd.value.string, NULL),&filebuf)) in = makeInstance(_broker, LOCALCLASSNAME, CMGetCharsPtr(CMGetNameSpace(cop,NULL), NULL), &filebuf); if (CMIsNullObject(in)) { CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED, "Could not find or construct instance"); } else { CMReturnInstance(rslt,in); CMReturnDone(rslt); } return st; }
static CMPIrc hostcomputer_capabilities_set_properties( const CMPIBroker *broker, provider_resource *resource, CMPIInstance *inst ) { xen_host_record *host_rec = ((local_host_resource *)resource->ctx)->host_rec; if(host_rec == NULL) return CMPI_RC_ERR_FAILED; if(CMIsNullObject(inst)) return CMPI_RC_ERR_FAILED; /* Set the CMPIInstance properties from the resource data. */ char buf[MAX_INSTANCEID_LEN]; _CMPICreateNewSystemInstanceID(buf, MAX_INSTANCEID_LEN, host_rec->uuid); CMSetProperty(inst, "InstanceID", (CMPIValue *)buf, CMPI_chars); CMSetProperty(inst, "ElementName", (CMPIValue *)host_rec->name_label, CMPI_chars); int nameEditSupported = 0; CMSetProperty(inst, "ElementNameEditSupported", (CMPIValue *)&nameEditSupported, CMPI_boolean); _set_allowed_operations(broker, host_rec, inst, "RequestedStatesSupported"); return CMPI_RC_OK; }
CMPIInstance *SoftwareIdentityCreateElementAssocInstance( const char *ns, const char *siname, const char *name, const char ** properties, CMPIStatus *pStatus) { const char* classKeys[] = { AntecedentName, DependentName, NULL }; CMPIStatus status = {CMPI_RC_OK, NULL}; _SMI_TRACE(1,("SoftwareIdentityCreateElementAssocInstance() called")); // Create software identity object path (LEFT) CMPIObjectPath *antcop; antcop = SoftwareIdentityCreateObjectPath(ns, siname, &status); if (CMIsNullObject(antcop)) { CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Could not create SoftwareIdentity cop"); return NULL; } // Create registered profile object path (RIGHT) CMPIObjectPath *depcop = RegisteredProfileCreateObjectPath(ns, name, &status); if (CMIsNullObject(depcop)) { CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Could not create RegisteredProfile cop"); return NULL; } CMPIInstance *assocInst = cmpiutilCreateAssociationInst(_BROKER, ns, ElementSoftwareIdentityName, classKeys, properties, AntecedentName, DependentName, antcop, depcop, pStatus); _SMI_TRACE(1,("Leaving SoftwareIdentityCreateElementAssocInstance(): %s", (pStatus->rc == CMPI_RC_OK)? "succeeded":"failed")); return assocInst; }
CMPIInstance *RegisteredProfileCreateSubProfileRequiresAssocInstance( const char *ns, const char *profName, const char *subProfName, const char ** properties, CMPIStatus *pStatus) { const char* classKeys[] = { DependentName, AntecedentName, NULL }; CMPIStatus status = {CMPI_RC_OK, NULL}; _SMI_TRACE(1,("RegisteredProfileCreateSubProfileRequiresAssocInstance() called")); // Create registered sub-profile object path (LEFT) CMPIObjectPath *rspcop = RegisteredProfileCreateObjectPath(ns, subProfName, &status); if (CMIsNullObject(rspcop)) { CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Could not create RegisteredSubProfile cop"); return NULL; } // Create registered profile object path (RIGHT) CMPIObjectPath *rpcop = RegisteredProfileCreateObjectPath(ns, profName, &status); if (CMIsNullObject(rpcop)) { CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Could not create RegisteredProfile cop"); return NULL; } CMPIInstance *assocInst = cmpiutilCreateAssociationInst(_BROKER, ns, SubProfileRequiresProfileName, classKeys, properties, DependentName, AntecedentName, rspcop, rpcop, pStatus); _SMI_TRACE(1,("Leaving RegisteredProfileCreateSubProfileRequiresAssocInstance(): %s", (pStatus->rc == CMPI_RC_OK)? "succeeded":"failed")); return assocInst; }
CMPIInstance *makeInstance(const CMPIBroker *broker, const char * classname, const char * Namespace, CWS_FILE *cwsf) { CMPIInstance *in = NULL; CMPIValue val; CMPIObjectPath *op = CMNewObjectPath(broker, (char*)Namespace, (char*)classname, NULL); CMSetHostname(op,CSName()); if (!CMIsNullObject(op)) { in = CMNewInstance(broker,op,NULL); if (!CMIsNullObject(in)) { CMSetProperty(in,"CSCreationClassName",CSCreationClassName(),CMPI_chars); CMSetProperty(in,"CSName",CSName(),CMPI_chars); CMSetProperty(in,"FSCreationClassName",FSCreationClassName(),CMPI_chars); CMSetProperty(in,"FSName",FSName(),CMPI_chars); CMSetProperty(in,"CreationClassName",classname,CMPI_chars); CMSetProperty(in,"Name",cwsf->cws_name,CMPI_chars); CMSetProperty(in,"FileSize",(CMPIValue*)&cwsf->cws_size,CMPI_uint64); #ifndef SIMULATED /* We don't want this code in the simulated env - time is dynamic (diff timezones) and the testing system might using a diff timezone and report failure */ val.uint64 = cwsf->cws_ctime; val.dateTime = CMNewDateTimeFromBinary(broker,val.uint64*1000000,0,NULL); CMSetProperty(in,"CreationDate",&val,CMPI_dateTime); val.uint64 = cwsf->cws_mtime; val.dateTime = CMNewDateTimeFromBinary(broker,val.uint64*1000000,0,NULL); CMSetProperty(in,"LastModified",&val,CMPI_dateTime); val.uint64 = cwsf->cws_atime; val.dateTime = CMNewDateTimeFromBinary(broker,val.uint64*1000000,0,NULL); CMSetProperty(in,"LastAccessed",&val,CMPI_dateTime); #endif val.uint64=0L; val.boolean=(cwsf->cws_mode & 0400) != 0; CMSetProperty(in,"Readable",&val,CMPI_boolean); val.boolean=(cwsf->cws_mode & 0200) != 0; CMSetProperty(in,"Writeable",&val,CMPI_boolean); val.boolean=(cwsf->cws_mode & 0100) != 0; CMSetProperty(in,"Executable",&val,CMPI_boolean); } } return in; }
/***************************************************************************** * Modify a backend xen resource identified by the the CIM instance based * on the instance's properties * * @param in broker - CMPI factory service broker * @param in ft - xen backend provider function table * @param in res_id - opaque data identifying the CIM object being modified * @param in caller_id - CIM caller's credentials * @param in modified_res - modifed version of the xen resource * @param in properties - CIM properties that caller cares about * @return CMPIrc error codes *****************************************************************************/ CMPIrc prov_pxy_modify( const CMPIBroker *broker, const XenProviderInstanceFT* ft, const void *res_id, struct xen_call_context *caller_id, const void *modified_res, const char **properties) { (void)properties; CMPIData data; CMPIStatus status = {CMPI_RC_OK, NULL}; char *inst_id; xen_utils_session *session = NULL; _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO,("Modify an Instance")); CMPIInstance *inst = (CMPIInstance *)res_id; if(CMIsNullObject(inst)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("input parameter res_id is invalid")); return CMPI_RC_ERR_FAILED; } CMPIObjectPath *op = CMGetObjectPath(inst, &status); CMPIString *cn = CMGetClassName(op, &status); /* Get target resource */ const char *key_prop = ft->xen_resource_get_key_property(broker, CMGetCharPtr(cn)); data = CMGetProperty(inst, key_prop, &status); if((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Could not get target resource")); return CMPI_RC_ERR_FAILED; } inst_id = CMGetCharPtr(data.value.string); if((inst_id == NULL) || (*inst_id == '\0')) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Could not get inst id")); return CMPI_RC_ERR_FAILED; } if(!xen_utils_validate_session(&session, caller_id)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("--- Unable to establish connection with Xen")); return CMPI_RC_ERR_FAILED; } /* Call the target provider */ status.rc = ft->xen_resource_modify(broker, res_id, modified_res, properties, status, inst_id, session); xen_utils_cleanup_session(session); return status.rc; }
CMPIObjectPath *makePath( const CMPIBroker *broker, const char * classname, const char * Namespace, CWS_FILE *cwsf) { CMPIObjectPath *op; op = CMNewObjectPath(broker, (char*)Namespace, (char*)classname, NULL); CMSetHostname(op,CSName()); if (!CMIsNullObject(op)) { CMAddKey(op,"CSCreationClassName",CSCreationClassName(),CMPI_chars); CMAddKey(op,"CSName",CSName(),CMPI_chars); CMAddKey(op,"FSCreationClassName",FSCreationClassName(),CMPI_chars); CMAddKey(op,"FSName",FSName(),CMPI_chars); CMAddKey(op,"CreationClassName",classname,CMPI_chars); CMAddKey(op,"Name",cwsf->cws_name,CMPI_chars); } return op; }
/***************************************************************************** * Delete a backend xen resource identified by the the CIM instance * * @param in broker - CMPI factory service broker * @param in ft - xen backend provider function table * @param in res_id - opaque data identifying the CIM object being deleted * @param in caller_id - CIM caller's credentials * @return CMPIrc error codes *****************************************************************************/ CMPIrc prov_pxy_delete( const CMPIBroker *broker, const XenProviderInstanceFT* ft, const void *res_id, struct xen_call_context *caller_id ) { CMPIInstance *inst = (CMPIInstance *)res_id; CMPIData data; CMPIStatus status = {CMPI_RC_OK, NULL}; _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO, ("Delete an instance")); CMPIObjectPath *op = CMGetObjectPath(inst, &status); CMPIString *cn = CMGetClassName(op, &status); xen_utils_session *session = NULL; if(CMIsNullObject(inst)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Invalid parameter")); return CMPI_RC_ERR_FAILED; } const char *key_prop = ft->xen_resource_get_key_property(broker, CMGetCharPtr(cn)); data = CMGetProperty(inst, key_prop ,&status); if((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Could not get property")); return CMPI_RC_ERR_FAILED; } char *inst_id = CMGetCharPtr(data.value.string); if((inst_id == NULL) || (*inst_id == '\0')) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Could not get inst id")); return CMPI_RC_ERR_FAILED; } if(!xen_utils_validate_session(&session, caller_id)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,("Unable to establish connection with Xen")); return CMPI_RC_ERR_FAILED; } /* get the object and delete it */ status.rc = ft->xen_resource_delete(broker, session, inst_id); xen_utils_cleanup_session(session); return status.rc; }
CMPIObjectPath *RegisteredProfileCreateObjectPath( const char *ns, const char *name, CMPIStatus *status) { CMPIObjectPath *cop; char buf[256]; _SMI_TRACE(1,("RegisteredProfileCreateObjectPath() called")); if (strcasecmp(name, VolumeManagementName) == 0 || strcasecmp(name, ArrayName) == 0 || strcasecmp(name, ServerName) == 0) { cop = CMNewObjectPath( _BROKER, ns, RegisteredProfileName, status); } else { cop = CMNewObjectPath( _BROKER, ns, RegisteredSubProfileName, status); } if ((status->rc != CMPI_RC_OK) || CMIsNullObject(cop)) { _SMI_TRACE(1,("RegisteredProfileCreateObjectPath(): CMNewObjectPath() failed - %s", CMGetCharPtr(status->msg))); CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Cannot create new objectpath"); goto exit; } CMAddKey(cop, InstanceIDName, cmpiutilMakeInstanceID(name, buf, 256), CMPI_chars); /* *buf = 0; strncat(buf, "SNIA:", 256); strncat(buf, name , 256); CMAddKey(cop, "InstanceID", buf , CMPI_chars); */ exit: _SMI_TRACE(1,("RegisteredProfileCreateObjectPath() done")); return cop; }
/***************************************************************************** * Set CIM instance properties based on backend xen resource data * * @param in ft - xen backend provider function table * @param in/out inst - CIM instance whose properties are to be set * @param in res - xen resource * @param in properties - CIM properties that caller cares about * @return CMPIrc error codes *****************************************************************************/ CMPIrc prov_pxy_setproperties( const XenProviderInstanceFT* ft, CMPIInstance *inst, const void *res, const char **properties) { provider_resource *resource = (provider_resource *) res; if(res == NULL || CMIsNullObject(inst)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Invalid input parameter")); return CMPI_RC_ERR_FAILED; } RESET_XEN_ERROR(resource->session->xen); /* Setup a filter to only return the desired properties. */ const char **keys = ft->xen_resource_get_keys(resource->broker, resource->classname); CMSetPropertyFilter(inst, properties, keys); return ft->xen_resource_set_properties(resource, inst); }
CMPIStatus CWS_DirectoryEnumInstances( CMPIInstanceMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * ref, const char ** properties) { CMPIInstance *in; CMPIStatus st = {CMPI_RC_OK,NULL}; void *enumhdl; CWS_FILE filebuf; if (!silentMode()) fprintf(stderr,"--- CWS_DirectoryEnumInstances() \n"); enumhdl = CWS_Begin_Enum(CWS_FILEROOT,CWS_TYPE_DIR); if (enumhdl == NULL) { CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED, "Could not begin file enumeration"); return st; } else { while (CWS_Next_Enum(enumhdl,&filebuf)) { /* build instance from file buffer */ in = makeInstance(_broker, LOCALCLASSNAME, CMGetCharsPtr(CMGetNameSpace(ref,NULL), NULL), &filebuf); if (CMIsNullObject(in)) { CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED, "Could not construct instance"); break; } CMReturnInstance(rslt,in); } CMReturnDone(rslt); CWS_End_Enum(enumhdl); } return st; }
CMPIObjectPath *SoftwareIdentityCreateObjectPath( const char *ns, const char *name, CMPIStatus *status) { CMPIObjectPath *cop; char buf[256]; _SMI_TRACE(1,("SoftwareIdentityCreateObjectPath() called")); if (strcasecmp(name, SMIArrayName) == 0) { cop = CMNewObjectPath( _BROKER, ns, ArraySoftwareName, status); } else if (strcasecmp(name, SMIVolumeManagementName) == 0) { cop = CMNewObjectPath( _BROKER, ns, VolumeManagementSoftwareName, status); } if ((status->rc != CMPI_RC_OK) || CMIsNullObject(cop)) { _SMI_TRACE(1,("SoftwareIdentityCreateObjectPath(): CMNewObjectPath() failed - %s", CMGetCharPtr(status->msg))); CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Cannot create new objectpath"); goto exit; } CMAddKey(cop, InstanceIDName, cmpiutilMakeInstanceID(name, buf, 256), CMPI_chars); exit: _SMI_TRACE(1,("SoftwareIdentityCreateObjectPath() done")); return cop; }
CMPIObjectPath * _makePath_Service( const CMPIBroker * _broker, const CMPIContext * ctx, const CMPIObjectPath * ref, LXS_Service * lxssvc, CMPIStatus * rc) { CMPIObjectPath * op = NULL; _OSBASE_TRACE(2,("--- _makePath_Service() called")); /* the sblim-cmpi-base package offers some tool methods to get common * system data */ if( !get_system_name() ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "no host name found" ); _OSBASE_TRACE(2,("--- _makePath_Service() failed : %s",CMGetCharPtr(rc->msg))); goto exit; } op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(ref,rc)), _ClassName, rc ); if( CMIsNullObject(op) ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); _OSBASE_TRACE(2,("--- _makePath_Service() failed : %s",CMGetCharPtr(rc->msg))); goto exit; } CMAddKey(op, "SystemCreationClassName", CSCreationClassName, CMPI_chars); CMAddKey(op, "SystemName", get_system_name(), CMPI_chars); CMAddKey(op, "CreationClassName", _ClassName, CMPI_chars); CMAddKey(op, "Name", lxssvc->svName, CMPI_chars); exit: _OSBASE_TRACE(2,("--- _makePath_Service() exited")); return op; }
/** initialize function will create three instances and add them to array. "numOfInst" will represent the number of instances in the array. */ static void initialize() { CMPIStatus rc = { CMPI_RC_OK, NULL}; CMPIArray *arr_ptr; CMPIValue value1, value2, value_inst1, value_inst2; CMPIInstance *instance1, *instance2, *instance3; CMPIObjectPath *cop1, *cop2, *cop3; CMPIObjectPath *embeddedObjPath; CMPIInstance *emInst1; CMPIValue valueEmInst; value1.uint8 = 1; value2.string = CMNewString(_broker, "\\x0C9C\\x0CA8\\x0CCD\\x0CAE" "\\x0CA6\\x0CBF\\x0CA8\\x0CA6 \\x0CB6\\x0CC1\\x0CAD\\x0CBE" "\\x0CB6\\x0CAF\\x0C97\\x0CB3\\x0CC1", &rc); /* Create an embedded instance to be returned as embedded object This is an instance of a class that does not exist which is legal in DMTF specs. */ embeddedObjPath = CMNewObjectPath ( _broker, "test/TestProvider", "TestCMPI_EmbeddedNoClass", &rc); assert(rc.rc == CMPI_RC_OK); valueEmInst.uint32 = 1; rc = CMAddKey(embeddedObjPath,"id",&valueEmInst, CMPI_uint32); assert(rc.rc == CMPI_RC_OK); emInst1 = CMNewInstance(_broker, embeddedObjPath, &rc); assert(rc.rc == CMPI_RC_OK); valueEmInst.uint32 = 1999; rc = CMSetProperty(emInst1, "id", &valueEmInst, CMPI_uint32); assert(rc.rc == CMPI_RC_OK); // set the new instance into a value container valueEmInst.inst = emInst1; /* create a new array to hold the instances created */ arr_ptr = CMNewArray(_broker, initArraySize, CMPI_instance, &rc); /* create object path for instance1 */ cop1 = CMNewObjectPath( _broker, "root/SampleProvider", _ClassName, &rc); /* add key (with its value) to object path to recognize instance uniquely */ CMAddKey(cop1, "Identifier", (CMPIValue *)&value1, CMPI_uint8); /* if created object path is not null then create new instance */ if(!CMIsNullObject(cop1)) { instance1 = CMNewInstance(_broker, cop1, &rc); /* set the properties for newly created instance */ CMSetProperty(instance1, "Identifier",&value1, CMPI_uint8); CMSetProperty(instance1, "Message", &value2, CMPI_string); CMSetProperty(instance1, "emObject", &valueEmInst, CMPI_instance); value_inst1.inst = instance1; /* assign the created instance to array created */ rc = CMSetArrayElementAt( arr_ptr, numOfInst, &value_inst1, CMPI_instance); /* set the validity of instance to be true. Validity gets false if instance gets deleted using deleteInstance(). */ valid[numOfInst] = 1; numOfInst++; } /* create instance 2 and add to array */ value1.uint8 = 2; value2.string = CMNewString(_broker, "\\x0CA8\\x0CBE\\x0CB3" "\\x0CC6\\x0CA6\\x0CBF\\x0CA8", &rc); cop2 = CMNewObjectPath( _broker, "root/SampleProvider", _ClassName, &rc); CMAddKey(cop2, "Identifier", (CMPIValue *)&value1, CMPI_uint8); if(!CMIsNullObject(cop2)) { instance2 = CMNewInstance(_broker, cop2, &rc); CMSetProperty(instance2, "Identifier", &value1, CMPI_uint8); CMSetProperty(instance2, "Message", &value2, CMPI_string); value_inst2.inst = instance2; rc = CMSetArrayElementAt(arr_ptr, numOfInst, &value_inst2, CMPI_instance); valid[numOfInst] = 1; numOfInst++; } /* create instance 3 and add to array */ value1.uint8 = 3; value2.string = CMNewString(_broker, "\\x0C9C", &rc); cop3 = CMNewObjectPath( _broker, "root/SampleProvider", _ClassName, &rc); CMAddKey(cop3, "Identifier", (CMPIValue *)&value1, CMPI_uint8); if(!CMIsNullObject(cop3)) { instance3 = CMNewInstance(_broker, cop3, &rc); CMSetProperty(instance3, "Identifier", &value1, CMPI_uint8); CMSetProperty(instance3, "Message", &value2, CMPI_string); CMSetProperty(instance3, "emObject", &valueEmInst, CMPI_instance); value_inst2.inst = instance3; rc = CMSetArrayElementAt(arr_ptr, numOfInst, &value_inst2, CMPI_instance); valid[numOfInst] = 1; numOfInst++; } /* clone the array which contains instances. */ clone_arr_ptr = arr_ptr->ft->clone(arr_ptr, &rc); }
CMPIInstance *SoftwareIdentityCreateInstance( const char *ns, const char *name, CMPIStatus *status) { CMPIInstance *ci; char buf[256]; CMPIValue val; _SMI_TRACE(1,("SoftwareIdentityCreateInstance() called")); if (strcasecmp(name, SMIVolumeManagementName) == 0) { ci = CMNewInstance( _BROKER, CMNewObjectPath(_BROKER, ns, VolumeManagementSoftwareName, status), status); if ((status->rc != CMPI_RC_OK) || CMIsNullObject(ci)) { _SMI_TRACE(1,("SoftwareIdentityCreateInstance(): CMNewInstance() failed - %s", CMGetCharPtr(status->msg))); CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Cannot create new instance"); goto exit; } CMSetProperty(ci, InstanceIDName, cmpiutilMakeInstanceID(name, buf, 256), CMPI_chars); CMSetProperty(ci, ElementName, VMProfileName, CMPI_chars); CMSetProperty(ci, ParamName, VMProfileName, CMPI_chars); CMSetProperty(ci, Caption, VMProfileName, CMPI_chars); CMSetProperty(ci, Description, VMProfileName, CMPI_chars); CMSetProperty(ci, VersionString, VersionStringValue, CMPI_chars); CMSetProperty(ci, Manufacturer, ManufacturerName, CMPI_chars); CMSetProperty(ci, Status, OK, CMPI_chars); val.uint16 = 5; CMSetProperty(ci, HealthState, &val, CMPI_uint16); CMPIArray *arr = CMNewArray(_BROKER, 2, CMPI_uint16, NULL); val.uint16 = 3; CMSetArrayElementAt(arr, 0, &val, CMPI_uint16); val.uint16 = 5; CMSetArrayElementAt(arr, 1, &val, CMPI_uint16); val.array = arr; CMSetProperty(ci, Classifications, &val, CMPI_uint16A); arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL); val.uint16 = 2; CMSetArrayElementAt(arr, 0, &val, CMPI_uint16); val.array = arr; CMSetProperty(ci, OperationalStatus, &val, CMPI_uint16A); } else if (strcasecmp(name, SMIArrayName) == 0) { ci = CMNewInstance( _BROKER, CMNewObjectPath(_BROKER, ns, ArraySoftwareName, status), status); if ((status->rc != CMPI_RC_OK) || CMIsNullObject(ci)) { _SMI_TRACE(1,("SoftwareIdentityCreateInstance(): CMNewInstance() failed - %s", CMGetCharPtr(status->msg))); CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Cannot create new instance"); goto exit; } CMSetProperty(ci, InstanceIDName, cmpiutilMakeInstanceID(name, buf, 256), CMPI_chars); CMSetProperty(ci, ElementName, ArrayProfileName, CMPI_chars); CMSetProperty(ci, ParamName, ArrayProfileName, CMPI_chars); CMSetProperty(ci, Caption, ArrayProfileName, CMPI_chars); CMSetProperty(ci, Description, ArrayProfileName, CMPI_chars); CMSetProperty(ci, VersionString, VersionStringValue, CMPI_chars); CMSetProperty(ci, Manufacturer, ManufacturerName, CMPI_chars); CMSetProperty(ci, Status, OK, CMPI_chars); val.uint16 = 5; CMSetProperty(ci, HealthState, &val, CMPI_uint16); CMPIArray *arr = CMNewArray(_BROKER, 2, CMPI_uint16, NULL); val.uint16 = 3; CMSetArrayElementAt(arr, 0, &val, CMPI_uint16); val.uint16 = 5; CMSetArrayElementAt(arr, 1, &val, CMPI_uint16); val.array = arr; CMSetProperty(ci, Classifications, &val, CMPI_uint16A); arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL); val.uint16 = 2; CMSetArrayElementAt(arr, 0, &val, CMPI_uint16); val.array = arr; CMSetProperty(ci, OperationalStatus, &val, CMPI_uint16A); } exit: _SMI_TRACE(1,("SoftwareIdentityCreateInstance() done")); return ci; }
CMPIObjectPath *RegisteredProfileCreateElementConformsAssocObjectPath( const CMPIContext * ctx, const char *ns, const char *name, CMPIStatus *pStatus) { CMPIStatus status = {CMPI_RC_OK, NULL}; CMPIObjectPath *mecop; _SMI_TRACE(1,("RegisteredProfileCreateElementConformsAssocObjectPath() called")); if (strcasecmp(name, ServerName) == 0) { // For Server profile ManagedElement is the Object Manager _SMI_TRACE(1,("GetOMObjectPath() called")); mecop = GetObjectManagerObjectPath(ctx, ns); if (CMIsNullObject(mecop)) { CMSetStatusWithChars(_BROKER, pStatus, CMPI_RC_ERR_FAILED, "Could not create ObjectManager cop"); return NULL; } _SMI_TRACE(1,("GetOMObjectPath() done")); } else { // For all other profiles ManagedElement is the Computer System _SMI_TRACE(1,("CreateCSObjectPath() called")); mecop = cmpiutilCreateCSObjectPath( _BROKER, ns, pStatus); if (CMIsNullObject(mecop)) { CMSetStatusWithChars(_BROKER, pStatus, CMPI_RC_ERR_FAILED, "Could not create ComputerSystem cop"); return NULL; } _SMI_TRACE(1,("CreateCSObjectPath() done")); } // Create RegisteredProfile object path (RIGHT) CMPIObjectPath *cscop = RegisteredProfileCreateObjectPath(ns, name, &status); if (CMIsNullObject(cscop)) { CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "Could not create RegisteredProfile cop"); return NULL; } CMPIObjectPath *assocCop = cmpiutilCreateAssociationPath(_BROKER, ns, ElementConformsToProfileName, ManagedElementName, ConformantStandardName, mecop, cscop, pStatus); _SMI_TRACE(1,("Leaving RegisteredProfileCreateElementConformsAssocObjectPath(): %s", (pStatus->rc == CMPI_RC_OK)? "succeeded":"failed")); return assocCop; }
CMPIInstance *RegisteredProfileCreateInstance( const char *ns, const char *name, CMPIStatus *status) { CMPIInstance *ci; char buf[256]; CMPIValue val; _SMI_TRACE(1,("RegisteredProfileCreateInstance() called")); if (strcasecmp(name, ArrayName) == 0 || strcasecmp(name, VolumeManagementName) == 0 || strcasecmp(name, ServerName) == 0) { ci = CMNewInstance( _BROKER, CMNewObjectPath(_BROKER, ns, RegisteredProfileName, status), status); } else { ci = CMNewInstance( _BROKER, CMNewObjectPath(_BROKER, ns, RegisteredSubProfileName, status), status); } if ((status->rc != CMPI_RC_OK) || CMIsNullObject(ci)) { _SMI_TRACE(1,("RegisteredProfileCreateInstance(): CMNewInstance() failed - %s", CMGetCharPtr(status->msg))); CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Cannot create new instance"); goto exit; } CMSetProperty(ci, InstanceIDName, cmpiutilMakeInstanceID(name, buf, 256), CMPI_chars); CMSetProperty(ci, ElementName, name, CMPI_chars); CMSetProperty(ci, ParamName, name, CMPI_chars); CMSetProperty(ci, Caption, name, CMPI_chars); CMSetProperty(ci, RegisteredName, name, CMPI_chars); val.uint16 = 11; CMSetProperty(ci, RegisteredOrg, &val, CMPI_uint16); CMSetProperty(ci, RegisteredVersion, RegisteredVersionValue, CMPI_chars); CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL); val.uint16 = 2; CMSetArrayElementAt(arr, 0, &val, CMPI_uint16); val.array = arr; CMSetProperty(ci, AdvertiseTypes, &val, CMPI_uint16A); arr = CMNewArray(_BROKER, 1, CMPI_string, NULL); val.string = CMNewString(_BROKER, NotAdvertised, NULL); CMSetArrayElementAt(arr, 0, &val, CMPI_string); val.array = arr; CMSetProperty(ci, AdvertiseTypeDesc, &val, CMPI_stringA); exit: _SMI_TRACE(1,("RegisteredProfileCreateInstance() done")); return ci; }
/***************************************************************************** * Gets a specific xen resource identified by the CIM Instance passed in * * @param in broker - CMPI Broker services * @param in ft - xen backend provider function table * @param in res_id - resource identifying xen object being requested * @param in caller_id - CIM Caller's credentials * @param in properties - CIM properties caller's interested in * @param out res - xen provider resource * @return CMPIrc error codes *****************************************************************************/ CMPIrc prov_pxy_get( const CMPIBroker *broker, const XenProviderInstanceFT* ft, const void *res_id, struct xen_call_context * caller_id, const char **properties, void **res ) { CMPIInstance *inst = (CMPIInstance *)res_id; xen_utils_session *session = NULL; CMPIData data; static CMPIrc rc = CMPI_RC_OK; char *res_uuid=NULL; CMPIStatus status = {CMPI_RC_OK, NULL}; (void)properties; CMPIObjectPath *op = CMGetObjectPath(inst, &status); CMPIString *cn = CMGetClassName(op, &status); if(CMIsNullObject(inst) || res == NULL) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,("Error get(): inst or res is NULL")); return CMPI_RC_ERR_FAILED; } const char *key_prop = ft->xen_resource_get_key_property(broker, CMGetCharPtr(cn)); data = CMGetProperty(inst, key_prop ,&status); if((status.rc != CMPI_RC_OK) || CMIsNullValue(data)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Error key_property %s couldnt be found for class %s", key_prop, CMGetCharPtr(cn))); return CMPI_RC_ERR_INVALID_PARAMETER; } /* Extract the resource identifier string from the CMPIString. */ res_uuid = CMGetCharPtr(data.value.string); if(res_uuid == NULL) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Unable to extrace resource identifier string")); return CMPI_RC_ERR_FAILED; } if(!xen_utils_validate_session(&session, caller_id)) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Unable to establish connection with Xen")); return CMPI_RC_ERR_FAILED; } provider_resource *prov_res = calloc(1, sizeof(provider_resource)); if(prov_res == NULL) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("Out of memory")); return CMPI_RC_ERR_FAILED; } prov_res->broker = broker; prov_res->classname = CMGetCharPtr(cn); prov_res->session = session; prov_res->cleanupsession = true; rc = ft->xen_resource_record_get_from_id(res_uuid, session, prov_res); if(rc != CMPI_RC_OK) { _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,("Error get(): get_xen_resource_record_from_id failed")); ft->xen_resource_record_cleanup(prov_res); xen_utils_cleanup_session(session); free(prov_res); return rc; } *res = (void *)prov_res; rc = CMPI_RC_OK; return rc; }
int assoc_ServiceProcess( const CMPIBroker * _broker, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * ref, int assocType, CMPIStatus * rc ) { CMPIString * sourceClass = NULL; CMPIData serviceName; CMPIObjectPath * op = NULL; CMPIObjectPath * rop = NULL; CMPIInstance * rci = NULL; CMPIInstance * sci = NULL; LXS_Handle lhdl; LXS_Service * lxssvc = NULL; int i = 0; _OSBASE_TRACE(2,("--- assoc_ServiceProcess() called")); /* check if source instance does exist */ sci = CBGetInstance(_broker, ctx, ref, NULL, rc); if( sci == NULL ) { if( rc->rc == CMPI_RC_ERR_FAILED ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "GetInstance of source object failed."); } if( rc->rc == CMPI_RC_ERR_NOT_FOUND ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_NOT_FOUND, "Source object not found."); } _OSBASE_TRACE(2,("--- assoc_ServiceProcess() failed : %s",CMGetCharPtr(rc->msg))); return -1; } sourceClass = CMGetClassName(ref, rc); if (CMGetCharPtr(sourceClass) == NULL) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Could not get source class name."); _OSBASE_TRACE(2,("--- assoc_ServiceProcess() failed : %s",CMGetCharPtr(rc->msg))); return -1; } /* source class is Linux_UnixProcess; target class is Linux_Service */ if( strcasecmp(CMGetCharPtr(sourceClass),_RefRightClass) == 0 ) { /* NOT_SUPPORTED - association is uni-directional */ } /* source class is Linux_Service; target class is Linux_UnixProcess */ else if( strcasecmp(CMGetCharPtr(sourceClass),_RefLeftClass) == 0 ) { serviceName = CMGetKey(ref, "Name", rc); if( serviceName.value.string == NULL ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Could not get Name of Service" ); _OSBASE_TRACE(2,("--- assoc_ServiceProcess() failed : %s",CMGetCharPtr(rc->msg))); return -1; } lhdl=LXS_InitFiltered(CMGetCharPtr(serviceName.value.string)); if (lhdl==NULL) { _OSBASE_TRACE(2,("--- assoc_ServiceProcess() exited : Could not find associated Service.")); return 0; } lxssvc=LXS_Next(lhdl); if (lxssvc==NULL) { _OSBASE_TRACE(2,("--- assoc_ServiceProcess() exited : Could not find associated Service.")); return 0; } /* get the list of associated processe */ for (i=0;lxssvc->svProcesses[i]!=NULL;i++) { op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(ref,rc)), _RefRightClass, rc ); if( CMIsNullObject(op) ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); _OSBASE_TRACE(2,("--- assoc_ServiceProcess() failed : %s",CMGetCharPtr(rc->msg))); return -1; } CMAddKey(op, "CSCreationClassName", CSCreationClassName, CMPI_chars); CMAddKey(op, "CSName", get_system_name(), CMPI_chars); CMAddKey(op, "OSCreationClassName", OSCreationClassName, CMPI_chars); CMAddKey(op, "OSName", get_os_name(), CMPI_chars); CMAddKey(op, "CreationClassName", _RefRightClass, CMPI_chars); CMAddKey(op, "Handle", lxssvc->svProcesses[i], CMPI_chars); if (assocType&ATYPE_ASSOC) { /* the process (name) */ if (assocType&ATYPE_NAME) { CMReturnObjectPath(rslt, op); } else { rci = CBGetInstance(_broker, ctx, op, NULL, rc); if(rci==NULL) { return -1; } CMReturnInstance( rslt, rci ); } } else { /* the reference object (name) */ if (assocType&ATYPE_NAME) { rop = _makePath_ServiceProcess(_broker, ref, op, rc); CMReturnObjectPath(rslt, rop); } else { rci = _makeInst_ServiceProcess(_broker, ref, op, rc); CMReturnInstance( rslt, rci ); } } } LXS_Term(lhdl); } _OSBASE_TRACE(2,("--- assoc_ServiceProcess() exited")); return 0; }
CMPIInstance * _makeInst_TestClass( const CMPIBroker * _broker, const CMPIContext * ctx, const CMPIObjectPath * ref, const char ** properties, CMPIStatus * rc, unsigned int theKey) { CMPIValue opstatus; CMPIValue status; CMPIObjectPath * op = NULL; CMPIInstance * ci = NULL; char * theName = NULL; CMPIArray *array = NULL; char **keys = NULL; int keyCount = 0; opstatus.uint16 = 0; /* Unknown */ status.uint16 = 2; /* Enabled */ // // Initialize Name // theName = calloc(1,20); sprintf(theName, "%u", theKey); // // Construct ObjectPath // op = CMNewObjectPath( _broker, CMGetCharsPtr(CMGetNameSpace(ref,rc), NULL), _ClassName, rc); if (CMIsNullObject(op)) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); goto exit; } // // Create a new instance and fill it's properties // ci = CMNewInstance( _broker, op, rc); if (CMIsNullObject(ci)) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIInstance failed." ); goto exit; } // // Set property filter // keys = calloc(2,sizeof(char*)); keys[0] = strdup("theKey"); CMSetPropertyFilter(ci,properties,(const char**)keys); for (;keys[keyCount]!=NULL;keyCount++) { free((char*)keys[keyCount]); } free(keys); // // Properties of CIM_ManagedElement // CMSetProperty(ci,"Caption","Performance Test class",CMPI_chars); CMSetProperty( ci, "Description", "Test class used for all kinds of testing", CMPI_chars); CMSetProperty(ci,"ElementName",theName,CMPI_chars); // // Properties of CIM_ManagedSystemElement // // TBD: InstallDate array = CMNewArray(_broker,1,CMPI_uint16,rc); CMSetArrayElementAt(array,0,&opstatus,CMPI_uint16); CMSetProperty(ci,"OperationalStatus",(CMPIValue*)&(array),CMPI_uint16A); // // Properties of CIM_EnabledLogicalElement // CMSetProperty( ci, "EnabledState", &status, CMPI_uint16); CMSetProperty( ci, "RequestedState", &status, CMPI_uint16); CMSetProperty( ci, "EnabledDefault", &status, CMPI_uint16); // // Properties of CIM_TestClass // CMSetProperty(ci,"theKey",&theKey , CMPI_uint32 ); CMSetProperty(ci,"theData",&theKey , CMPI_uint32 ); CMSetProperty(ci,"theString0","Test Data Number Zero",CMPI_chars); CMSetProperty(ci,"theString1","Test Data Number One",CMPI_chars); CMSetProperty(ci,"theString2","Test Data Number Two",CMPI_chars); CMSetProperty(ci,"theString3","Test Data Number Three",CMPI_chars); CMSetProperty(ci,"theString4","Test Data Number Four",CMPI_chars); CMSetProperty(ci,"theString5","Test Data Number Five",CMPI_chars); CMSetProperty(ci,"theString6","Test Data Number Six",CMPI_chars); CMSetProperty(ci,"theString7","Test Data Number Seven",CMPI_chars); CMSetProperty(ci,"theString8","Test Data Number Eight",CMPI_chars); CMSetProperty(ci,"theString9","Test Data Number Nine",CMPI_chars); exit: free(theName); return ci; }
CMPIInstance * _makeInst_Service( const CMPIBroker * _broker, const CMPIContext * ctx, const CMPIObjectPath * ref, const char ** properties, LXS_Service * lxssvc, CMPIStatus * rc) { CMPIObjectPath * op = NULL; CMPIInstance * ci = NULL; const char ** keys = NULL; int keyCount = 0; _OSBASE_TRACE(2,("--- _makeInst_Service() called")); /* the sblim-cmpi-base package offers some tool methods to get common * system data */ if( !get_system_name() ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "no host name found" ); _OSBASE_TRACE(2,("--- _makeInst_Service() failed : %s",CMGetCharPtr(rc->msg))); goto exit; } op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(ref,rc)), _ClassName, rc ); if( CMIsNullObject(op) ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); _OSBASE_TRACE(2,("--- _makeInst_Service() failed : %s",CMGetCharPtr(rc->msg))); goto exit; } ci = CMNewInstance( _broker, op, rc); if( CMIsNullObject(ci) ) { CMSetStatusWithChars( _broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIInstance failed." ); _OSBASE_TRACE(2,("--- _makeInst_Service() failed : %s",CMGetCharPtr(rc->msg))); goto exit; } /* set property filter */ keys = calloc(5,sizeof(char*)); keys[0] = strdup("SystemCreationClassName"); keys[1] = strdup("SystemName"); keys[2] = strdup("CreationClassName"); keys[3] = strdup("Name"); CMSetPropertyFilter(ci,properties,keys); for( ;keys[keyCount]!=NULL;keyCount++) { free((char*)keys[keyCount]); } free(keys); CMSetProperty( ci, "SystemCreationClassName", CSCreationClassName, CMPI_chars ); CMSetProperty( ci, "SystemName", get_system_name(), CMPI_chars ); CMSetProperty( ci, "CreationClassName", _ClassName, CMPI_chars ); CMSetProperty( ci, "Name", lxssvc->svName, CMPI_chars ); CMSetProperty( ci, "Caption", "Linux (/etc/init.d) Service", CMPI_chars); CMSetProperty( ci, "Description", "Instances of this class represents the /etc/init.d managed Services.", CMPI_chars); CMSetProperty( ci, "Status", lxssvc->svStatus, CMPI_chars); CMSetProperty( ci, "Started", (CMPIValue*)&(lxssvc->svStarted), CMPI_boolean); exit: _OSBASE_TRACE(2,("--- _makeInst_Service() exited")); return ci; }
static void initialize() { CMPIStatus rc = { CMPI_RC_OK, NULL}; CMPIArray *arr_ptr; CMPIValue value1, value2, value_inst1, value_inst2; CMPIInstance *instance1, *instance2, *instance3; CMPIObjectPath *cop1, *cop2, *cop3; value1.uint8 = 1; value2.string = CMNewString(_broker, "Hello World", &rc); /* create a new array to hold the instances created */ arr_ptr = CMNewArray(_broker, initArraySize, CMPI_instance, &rc); /* create object path for instance1 */ cop1 = CMNewObjectPath( _broker, "root/cimv2", _ClassName, &rc); /* add key (with its value) to object path to recognize instance uniquely */ CMAddKey(cop1, "Identifier", (CMPIValue *)&value1, CMPI_uint8); /* if created object path is not null then create new instance */ if(!CMIsNullObject(cop1)) { instance1 = CMNewInstance(_broker, cop1, &rc); /* set the properties for newly created instance */ CMSetProperty(instance1, "Identifier",&value1, CMPI_uint8); CMSetProperty(instance1, "Message", &value2, CMPI_string); value_inst1.inst = instance1; /* assign the created instance to array created */ rc = CMSetArrayElementAt( arr_ptr, numOfInst, &value_inst1, CMPI_instance); /* set the validity of instance to be true. Validity gets false if instance gets deleted using deleteInstance(). */ valid[numOfInst] = 1; numOfInst++; } /* create instance 2 and add to array */ value1.uint8 = 2; value2.string = CMNewString(_broker, "Yo Planet", &rc); cop2 = CMNewObjectPath( _broker, "root/cimv2", _ClassName, &rc); CMAddKey(cop2, "Identifier", (CMPIValue *)&value1, CMPI_uint8); if(!CMIsNullObject(cop2)) { instance2 = CMNewInstance(_broker, cop2, &rc); CMSetProperty(instance2, "Identifier", &value1, CMPI_uint8); CMSetProperty(instance2, "Message", &value2, CMPI_string); value_inst2.inst = instance2; rc = CMSetArrayElementAt(arr_ptr, numOfInst, &value_inst2, CMPI_instance); valid[numOfInst] = 1; numOfInst++; } /* create instance 3 and add to array */ value1.uint8 = 3; value2.string = CMNewString(_broker, "Hey Earth", &rc); cop3 = CMNewObjectPath( _broker, "root/cimv2", _ClassName, &rc); CMAddKey(cop3, "Identifier", (CMPIValue *)&value1, CMPI_uint8); if(!CMIsNullObject(cop3)) { instance3 = CMNewInstance(_broker, cop3, &rc); CMSetProperty(instance3, "Identifier", &value1, CMPI_uint8); CMSetProperty(instance3, "Message", &value2, CMPI_string); value_inst2.inst = instance3; rc = CMSetArrayElementAt(arr_ptr, numOfInst, &value_inst2, CMPI_instance); valid[numOfInst] = 1; numOfInst++; } /* clone the array which contains instances. */ clone_arr_ptr = arr_ptr->ft->clone(arr_ptr, &rc); }