CMPIStatus TestCMPIAssociationProviderAssociators(
    CMPIAssociationMI* mi,
    const CMPIContext* ctx,
    const CMPIResult* rslt,
    const CMPIObjectPath* ref,
    const char* _RefLeftClass,
    const char* _RefRightClass,
    const char* role,
    const char* resultRole,
    const char** properties)
{
    CMPIObjectPath * op = NULL;
    CMPIEnumeration * en = NULL;
    CMPIData data ;
    CMPIStatus rc = { CMPI_RC_OK, NULL };

    CMPIString * sourceClass = NULL;

    PROV_LOG_OPEN (_ClassName, _ProviderLocation);
    PROV_LOG ("\n\n********************* %s CMPI Associators() called",
        _ClassName);

    sourceClass = CMGetClassName(ref,&rc);

    /* get object path of the target class */
    op = get_assoc_targetClass_ObjectPath(
        _broker,
        ref,
        _RefLeftClass,
        _RefRightClass,
        &rc);

    sourceClass = CMGetClassName(op,&rc);
    PROV_LOG(" target class: %s ",CMGetCharsPtr(sourceClass,NULL));

    PROV_LOG (" New Object Path [%s]",
                CMGetCharsPtr (CMGetNameSpace (ref, &rc),NULL));

    /* Call to Associators */
    /* upcall to CIMOM; call enumInstances() of the target class */
    en = CBEnumInstances( _broker, ctx, op, NULL, &rc);

    /* as long as instance entries are found in the enumeration */
    while( CMHasNext( en, &rc) )
    {
        /* get the instance */
        data = CMGetNext( en, &rc);

        /* and return the target class instance as result of the
         * associators() call
        */
        CMReturnInstance( rslt, data.value.inst );
    }
    PROV_LOG ("\n\n********************* %s CMPI Associators exited",
        _ClassName);
    PROV_LOG_CLOSE ();
    return rc;
}
CMPIStatus
TestAssociationProviderAssociators(CMPIAssociationMI * mi,
                                   const CMPIContext *ctx,
                                   const CMPIResult *rslt,
                                   const CMPIObjectPath * ref,
                                   const char *_RefLeftClass,
                                   const char *_RefRightClass,
                                   const char *role,
                                   const char *resultRole,
                                   const char **properties)
{
  CMPIObjectPath *op = NULL;
  CMPIEnumeration *en = NULL;
  CMPIData        data;
  CMPIStatus      rc = { CMPI_RC_OK, NULL };

  CMPIString     *sourceClass = NULL;

  sourceClass = CMGetClassName(ref, &rc);

  /*
   * get object path of the target class 
   */
  op = get_assoc_targetClass_ObjectPath(_broker,
                                        ref,
                                        _RefLeftClass,
                                        _RefRightClass, &rc);

  sourceClass = CMGetClassName(op, &rc);

  /*
   * Call to Associators 
   */
  /*
   * upcall to CIMOM; call enumInstances() of the target class 
   */
  en = CBEnumInstances(_broker, ctx, op, NULL, &rc);

  /*
   * as long as instance entries are found in the enumeration 
   */
  if (!rc.rc)
    while (CMHasNext(en, &rc)) {
      /*
       * get the instance 
       */
      data = CMGetNext(en, &rc);

      /*
       * and return the target class instance as result of the
       * associators() call 
       */
      CMReturnInstance(rslt, data.value.inst);
    }
  return rc;
}
CMPIInstance   *
internalProviderGetInstance(const CMPIObjectPath * cop, CMPIStatus *rc)
{
  int             len;
  CMPIString     *cn = CMGetClassName(cop, NULL);
  CMPIString     *ns = CMGetNameSpace(cop, NULL);
  char           *key = normalizeObjectPathCharsDup(cop);
  CMPIInstance   *ci = NULL;
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);
  CMPIStatus      st = { CMPI_RC_OK, NULL };

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "internalProviderGetInstance");
  _SFCB_TRACE(1, ("--- Get instance for %s %s %s", nss, cns, key));

  if (testNameSpace(bnss, rc) == 0) {
    _SFCB_TRACE(1, ("--- Invalid namespace %s", nss));
    free(key);
    _SFCB_RETURN(NULL);
  }

  ci = ipGetBlob(bnss, cns, key, &len);

  if (ci == NULL) {
    _SFCB_TRACE(1, ("--- Instance not found"));
    st.rc = CMPI_RC_ERR_NOT_FOUND;
  }

  *rc = st;
  free(key);
  _SFCB_RETURN(ci);
}
const char     *
get_assoc_targetClass_Name(const CMPIBroker * broker,
                           const CMPIObjectPath * ref,
                           const char *_RefLeftClass,
                           const char *_RefRightClass, CMPIStatus *rc)
{
  CMPIString     *sourceClass = NULL;
  CMPIObjectPath *op = NULL;

  /*
   * get name of source class 
   */
  sourceClass = CMGetClassName(ref, rc);

  op = CMNewObjectPath(broker,
                       CMGetCharsPtr(CMGetNameSpace(ref, rc), NULL),
                       _RefLeftClass, rc);

  if (strcmp(CMGetCharsPtr(sourceClass, NULL), "CMPI_TEST_Person") == 0) {
    return "CMPI_TEST_Vehicle";
  } else if (strcmp(CMGetCharsPtr(sourceClass, NULL),
                    "CMPI_TEST_Vehicle") == 0) {
    return "CMPI_TEST_Person";
  } else {
    return NULL;
  }
}
CMPIStatus
InternalProviderDeleteInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIString     *cn = CMGetClassName(cop, NULL);
  CMPIString     *ns = CMGetNameSpace(cop, NULL);
  char           *key = normalizeObjectPathCharsDup(cop);
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderDeleteInstance");

  if (testNameSpace(bnss, &st) == 0) {
    free(key);
    _SFCB_RETURN(st);
  }

  if (existingBlob(bnss, cns, key) == 0) {
    CMPIStatus      st = { CMPI_RC_ERR_NOT_FOUND, NULL };
    free(key);
    _SFCB_RETURN(st);
  }

  deleteBlob(bnss, cns, key);

  free(key);
  _SFCB_RETURN(st);
}
CMPIStatus
IndCIMXMLHandlerGetInstance(CMPIInstanceMI * mi,
                            const CMPIContext *ctx,
                            const CMPIResult *rslt,
                            const CMPIObjectPath * cop,
                            const char **properties)
{
  CMPIStatus      st;
  CMPIInstance*   ci;
  const char** keyList;
  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerGetInstance");
  
  ci = internalProviderGetInstance(cop, &st);

  if (st.rc == CMPI_RC_OK) {
    if (isa("root/interop", CMGetCharPtr(CMGetClassName(cop,NULL)), "cim_indicationhandler")) {
      filterInternalProps(ci);
    }
    if (properties) {
      keyList = getKeyList(ci->ft->getObjectPath(ci, NULL));
      ci->ft->setPropertyFilter(ci, properties, keyList);
      if (keyList) {
        free(keyList);
      }
    }
    CMReturnInstance(rslt, ci);
  }

  _SFCB_RETURN(st);
}
Example #7
0
CMPIStatus KBase_FromObjectPath(KBase* self, const CMPIObjectPath* cop)
{
    CMPIString* cn;
    CMPIString* ns;
    CMPIStatus st = KSTATUS_INIT;
    CMPICount count;
    CMPICount i;
    KValue* kv;

    if (!self || self->magic != KMAGIC)
        KReturn(ERR_FAILED);

    /* Set namespace */

    if (!(ns = CMGetNameSpace(cop, &st)))
        return st;

    self->ns = ns;

    /* Get classname */

    if (!(cn = CMGetClassName(cop, &st)))
        return st;

    /* For each property */

    count = CMGetKeyCount(cop, &st); 

    if (!KOkay(st))
        return st;

    for (i = 0; i < count; i++)
    {
        CMPIData cd;
        CMPIString* pn = NULL;
        KTag tag;

        /* Get i-th property */

        cd = CMGetKeyAt(cop, i, &pn, &st);

        if (!KOkay(st))
            return st;

        if (!pn)
            KReturn(ERR_FAILED);

        /* Find the given property */

        if ((kv = _find_property(self, KChars(pn), &tag)))
        {
            _set_key_value(kv, tag, &cd);
        }
    }

    KReturn(OK);
}
Example #8
0
CMPIStatus IndCIMXMLHandlerEnumInstanceNames(CMPIInstanceMI * mi,
                                             const CMPIContext * ctx,
                                             const CMPIResult * rslt,
                                             const CMPIObjectPath * ref)
{
   CMPIStatus st;
   CMPIEnumeration *enm;
   CMPIContext *ctxLocal;

   _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerEnumInstanceNames");
   if (interOpNameSpace(ref,&st)!=1) _SFCB_RETURN(st);
   ctxLocal = prepareUpcall((CMPIContext *)ctx);

#ifdef HAVE_OPTIMIZED_ENUMERATION
   CMPIString* cn;
   CMPIObjectPath* refLocal;
   cn = CMGetClassName(ref, &st);

   if (strcasecmp(CMGetCharPtr(cn), "cim_listenerdestination") == 0) {
     enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st);
     while(enm && enm->ft->hasNext(enm, &st)) {
       CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref);
     }
     refLocal = CMNewObjectPath(_broker,"root/interop","cim_listenerdestinationcimxml",&st);
     enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, refLocal, &st);
     while(enm && enm->ft->hasNext(enm, &st)) {
       CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref);
     }
     refLocal = CMNewObjectPath(_broker,"root/interop","cim_indicationhandlercimxml",&st);
     enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, refLocal, &st);
     while(enm && enm->ft->hasNext(enm, &st)) {
       CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref);
     }
     CMRelease(refLocal);
   }
   else {
     enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st);
     while(enm && enm->ft->hasNext(enm, &st)) {
       CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref);
     }
   }
#else
   enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st);

   while(enm && enm->ft->hasNext(enm, &st)) {
       CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref);
   }
#endif

   CMRelease(ctxLocal);
   if(enm) CMRelease(enm);

   _SFCB_RETURN(st);
}
CMPIStatus
InternalProviderModifyInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci,
                               const char **properties)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  unsigned long   len;
  void           *blob;
  CMPIString     *cn = CMGetClassName(cop, NULL);
  CMPIString     *ns = CMGetNameSpace(cop, NULL);
  char           *key = normalizeObjectPathCharsDup(cop);
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);
  const char    **keyList;

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderSetInstance");

  if (testNameSpace(bnss, &st) == 0) {
    free(key);
    _SFCB_RETURN(st);
  }

  if (existingBlob(bnss, cns, key) == 0) {
    CMPIStatus      st = { CMPI_RC_ERR_NOT_FOUND, NULL };
    free(key);
    _SFCB_RETURN(st);
  }

  if (properties) {
    keyList = getKeyList(ci->ft->getObjectPath(ci, NULL));
    ci->ft->setPropertyFilter((CMPIInstance *) ci, properties, keyList);
    if (keyList) {
      free(keyList);
    }
  }

  len = getInstanceSerializedSize(ci);
  blob = malloc(len + 64);
  getSerializedInstance(ci, blob);
  addBlob(bnss, cns, key, blob, (int) len);
  free(blob);
  free(key);
  _SFCB_RETURN(st);
}
Example #10
0
static CMPIStatus
ClassProviderGetClass(CMPIClassMI * mi,
                      const CMPIContext *ctx,
                      const CMPIResult *rslt,
                      const CMPIObjectPath * ref, const char **properties)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIString     *cn = CMGetClassName(ref, NULL);
  CMPIConstClass *cl,
                 *clLocal;
  ClassRegister  *cReg;
  int             rc;
  ReadCtl         ctl;

  _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderGetClass");
  _SFCB_TRACE(1, ("--- ClassName=\"%s\"", (char *) cn->hdl));

  cReg = getNsReg(ref, &rc);
  if (cReg == NULL) {
    CMPIStatus      st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL };
    _SFCB_RETURN(st);
  }

  cReg->ft->wLock(cReg);

  ctl = stdRead;
  clLocal = getResolvedClass(cReg, (char *) cn->hdl, NULL, &ctl);
  if (clLocal) {
    /*
     * Make a cloned copy of the cached results to prevent thread
     * interference. 
     */
    _SFCB_TRACE(1, ("--- Class found"));
    cl = clLocal->ft->clone(clLocal, NULL);
    memLinkInstance((CMPIInstance *) cl);
    CMReturnInstance(rslt, (CMPIInstance *) cl);
    if (ctl != cached)
      CMRelease(cl);
  } else {
    _SFCB_TRACE(1, ("--- Class not found"));
    st.rc = CMPI_RC_ERR_NOT_FOUND;
  }

  cReg->ft->wUnLock(cReg);

  _SFCB_RETURN(st);
}
Example #11
0
/*****************************************************************************
 * 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;
}
Example #12
0
/*****************************************************************************
 * 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;
}
static CMPIStatus 
ResourceGroupInvokeMethod(CMPIMethodMI * mi, CMPIContext * ctx, 
		CMPIResult * rslt, CMPIObjectPath * ref, 
		const char * method_name, CMPIArgs * in, CMPIArgs * out)
{
        CMPIString * 	classname = NULL;
        CMPIStatus 	rc = {CMPI_RC_OK, NULL};
	int 		ret = 0;
        
        classname = CMGetClassName(ref, &rc);
        if(strcasecmp(CMGetCharPtr(classname), ClassName) == 0 &&
           strcasecmp(METHOD_ADD_PRIMITIVE_RESOURCE, method_name) == 0){
		ret = resource_add_subrsc(Broker, ClassName, ctx, rslt, 
				ref, TID_RES_GROUP, in, out, &rc);
        }

        CMReturnData(rslt, &ret, CMPI_uint32);
        CMReturnDone(rslt);
        CMReturn(CMPI_RC_OK);
}
static CMPIStatus 
ResourceCloneInvokeMethod(CMPIMethodMI * mi, CMPIContext * ctx, 
		CMPIResult * rslt, CMPIObjectPath * ref, 
		const char * method_name, CMPIArgs * in, CMPIArgs * out)
{
        CMPIString * 	classname = NULL;
        CMPIStatus 	rc = {CMPI_RC_OK, NULL};
	int 		ret = 0;
       
	PROVIDER_INIT_LOGGER(); 
	DEBUG_ENTER();
        classname = CMGetClassName(ref, &rc);
        if(strcasecmp(CMGetCharPtr(classname), ClassName) == 0 &&
           strcasecmp(METHOD_ADD_RESOURCE, method_name) == 0 ){
		ret = resource_add_subrsc(Broker, ClassName, ctx, rslt, 
			ref, TID_RES_CLONE, in, out, &rc); 
        }

        CMReturnData(rslt, &ret, CMPI_uint32);
        CMReturnDone(rslt);
	DEBUG_LEAVE();
        CMReturn(CMPI_RC_OK);
}
static CMPIStatus 
PrimitiveResourceInvokeMethod(CMPIMethodMI * mi, CMPIContext * ctx, 
		CMPIResult * rslt, CMPIObjectPath * ref, 
		const char * method_name, CMPIArgs * in, CMPIArgs * out)
{
        CMPIString * 	classname = NULL;
        CMPIStatus 	rc = {CMPI_RC_OK, NULL};
	int 		ret = 0;
        
        classname = CMGetClassName(ref, &rc);
        if(strcasecmp(CMGetCharPtr(classname), ClassName) == 0 &&
           strcasecmp(METHOD_ADD_OPERATION, method_name) == 0 ){
#if 0
		ret = resource_add_operation(Broker, ClassName, ctx, rslt, 
			ref, TID_RES_PRIMITIVE, in, out, &rc);
#endif
		ret = HA_OK;
        }

        CMReturnData(rslt, &ret, CMPI_uint32);
        CMReturnDone(rslt);
        CMReturn(CMPI_RC_OK);
}
Example #16
0
static CMPIStatus
ClassProviderGetClass(CMPIClassMI * mi,
                      const CMPIContext *ctx,
                      const CMPIResult *rslt,
                      const CMPIObjectPath * ref, const char **properties)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIString     *cn = CMGetClassName(ref, NULL);
  CMPIConstClass *cl;
  ClassRegister  *cReg;
  int             rc;

  _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderGetClass");
  _SFCB_TRACE(1, ("--- ClassName=\"%s\"", (char *) cn->hdl));

  cReg = getNsReg(ref, &rc);
  if (cReg == NULL) {
    CMPIStatus      st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL };
    _SFCB_RETURN(st);
  }

  cReg->ft->rLock(cReg);

  cl = getClass(cReg, (char *) cn->hdl);
  if (cl) {
    _SFCB_TRACE(1, ("--- Class found"));
    CMReturnInstance(rslt, (CMPIInstance *) cl);
  } else {
    _SFCB_TRACE(1, ("--- Class not found"));
    st.rc = CMPI_RC_ERR_NOT_FOUND;
  }

  cReg->ft->rUnLock(cReg);

  _SFCB_RETURN(st);
}
Example #17
0
static CMPIStatus
ClassProviderInvokeMethod(CMPIMethodMI * mi,
                          const CMPIContext *ctx,
                          const CMPIResult *rslt,
                          const CMPIObjectPath * ref,
                          const char *methodName,
                          const CMPIArgs * in, CMPIArgs * out)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIArray      *ar;
  int             rc;
  ClassRegister  *cReg;

  _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderInvokeMethod");

  cReg = getNsReg(ref, &rc);
  if (cReg == NULL) {
    CMPIStatus      st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL };
    _SFCB_RETURN(st);
  }

  if (strcasecmp(methodName, "getchildren") == 0) {
    CMPIData        cn = CMGetArg(in, "class", NULL);
    _SFCB_TRACE(1, ("--- getchildren %s", (char *) cn.value.string->hdl));

    cReg->ft->wLock(cReg);

    if (cn.type == CMPI_string && cn.value.string && cn.value.string->hdl) {
      char           *child;
      int             l = 0,
          i = 0;
      UtilList       *ul =
          getChildren(cReg, (char *) cn.value.string->hdl);
      if (ul)
        l = ul->ft->size(ul);
      ar = CMNewArray(_broker, l, CMPI_string, NULL);
      if (ul)
        for (child = (char *) ul->ft->getFirst(ul); child; child = (char *)
             ul->ft->getNext(ul)) {
          CMSetArrayElementAt(ar, i++, child, CMPI_chars);
        }
      st = CMAddArg(out, "children", &ar, CMPI_stringA);
    } else {
    }

    cReg->ft->wUnLock(cReg);

  }

  else if (strcasecmp(methodName, "getallchildren") == 0) {
    int             ignprov = 0;
    CMPIStatus      st;
    CMPIData        cn = CMGetArg(in, "class", &st);

    cReg->ft->wLock(cReg);

    if (st.rc != CMPI_RC_OK) {
      cn = CMGetArg(in, "classignoreprov", NULL);
      ignprov = 1;
    }
    _SFCB_TRACE(1,
                ("--- getallchildren %s", (char *) cn.value.string->hdl));
    if (cn.type == CMPI_string && cn.value.string && cn.value.string->hdl) {
      int             n = 0,
          i = 0;
      loopOnChildCount(cReg, (char *) cn.value.string->hdl, &n, ignprov);
      _SFCB_TRACE(1, ("--- count %d", n));
      ar = CMNewArray(_broker, n, CMPI_string, NULL);
      if (n) {
        _SFCB_TRACE(1, ("--- loop %s", (char *) cn.value.string->hdl));
        loopOnChildChars(cReg, (char *) cn.value.string->hdl, ar, &i,
                         ignprov);
      }
      st = CMAddArg(out, "children", &ar, CMPI_stringA);
    } else {
    }

    cReg->ft->wUnLock(cReg);
  }

  else if (strcasecmp(methodName, "getassocs") == 0) {
    ar = CMNewArray(_broker, cReg->topAssocs, CMPI_string, NULL);
    ClassBase      *cb = (ClassBase *) (cReg + 1);
    UtilHashTable  *ct = cb->ht;
    HashTableIterator *i;
    char           *cn;
    ClassRecord    *crec;
    int             n;

    cReg->ft->wLock(cReg);

    for (n = 0, i = ct->ft->getFirst(ct, (void **) &cn, (void **) &crec);
         i; i = ct->ft->getNext(ct, i, (void **) &cn, (void **) &crec)) {
      if (crec->flags & CREC_isAssociation && crec->parent == NULL) {
        /*
         * add top-level association class 
         */
        CMSetArrayElementAt(ar, n++, cn, CMPI_chars);
      }
    }
    CMAddArg(out, "assocs", &ar, CMPI_stringA);

    cReg->ft->wUnLock(cReg);
  }

  else if (strcasecmp(methodName, "ischild") == 0) {
    char           *parent = (char *) CMGetClassName(ref, NULL)->hdl;
    char           *chldn =
        (char *) CMGetArg(in, "child", NULL).value.string->hdl;
    st.rc = traverseChildren(cReg, parent, chldn);
  }

  else if (strcasecmp(methodName, "_startup") == 0) {

    /* let providerMgr know that we're odne init'ing  */
    semRelease(sfcbSem,INIT_CLASS_PROV_ID);

    st.rc = CMPI_RC_OK;
  }

  else {
    mlogf(M_ERROR, M_SHOW,
          "--- ClassProvider: Invalid invokeMethod request %s\n",
          methodName);
    st.rc = CMPI_RC_ERR_METHOD_NOT_FOUND;
  }
  _SFCB_RETURN(st);
}
static int
_testArrayTypes()
{
  struct array_types {
    CMPIType        element_type;
    CMPIType        typeA;
    char           *typeName;
    char           *typeAName;
    char           *args_name;
  } types_arr[] = {
    {
    CMPI_uint32,
          CMPI_uint32A,
          "CMPI_uint32", "CMPI_uint32A", "CMPI_uint32_array"}, {
    CMPI_uint16,
          CMPI_uint16A,
          "CMPI_uint16", "CMPI_uint16A", "CMPI_uint16_array"}, {
    CMPI_uint8,
          CMPI_uint8A, "CMPI_uint8", "CMPI_uint8A", "CMPI_uint8_array"}, {
    CMPI_uint64,
          CMPI_uint64A,
          "CMPI_uint64", "CMPI_uint64A", "CMPI_uint64_array"}, {
    CMPI_sint32,
          CMPI_sint32A,
          "CMPI_sint32", "CMPI_sint32A", "CMPI_sint32_array"}, {
    CMPI_sint16,
          CMPI_sint16A,
          "CMPI_sint16", "CMPI_sint16A", "CMPI_sint16_array"}, {
    CMPI_sint8,
          CMPI_sint8A, "CMPI_sint8", "CMPI_sint8A", "CMPI_sint8_array"}, {
    CMPI_sint64,
          CMPI_sint64A,
          "CMPI_sint64", "CMPI_sint64A", "CMPI_sint64_array"}, {
    CMPI_real32,
          CMPI_real32A,
          "CMPI_real32", "CMPI_real32A", "CMPI_real32_array"}, {
    CMPI_real64,
          CMPI_real64A,
          "CMPI_real64", "CMPI_real64A", "CMPI_real64_array"}, {
    CMPI_char16,
          CMPI_char16A,
          "CMPI_char16", "CMPI_char16A", "CMPI_char16_array"}, {
    CMPI_boolean,
          CMPI_booleanA,
          "CMPI_boolean", "CMPI_booleanA", "CMPI_boolean_array"}, {
    CMPI_string,
          CMPI_stringA,
          "CMPI_string", "CMPI_stringA", "CMPI_string_array"}, {
    CMPI_dateTime,
          CMPI_dateTimeA,
          "CMPI_dateTime", "CMPI_dateTimeA", "CMPI_dateTime_array"}, {
    CMPI_ref, CMPI_refA, "CMPI_ref", "CMPI_refA", "CMPI_ref_array"}, {
    CMPI_instance,
          CMPI_instanceA,
          "CMPI_instance", "CMPI_instanceA", "CMPI_instance_array"}, {
  CMPI_null, CMPI_ARRAY, "Invalid", "InvalidArray", "Invalid_array"}};

  int             i,
                  flag,
                  size;
  CMPIStatus      rc = { CMPI_RC_OK, NULL };
  CMPIStatus      rc1 = { CMPI_RC_OK, NULL };
  CMPIArray      *arr = NULL;
  CMPIString     *retNamespace = NULL;
  CMPIString     *retClassname = NULL;
  CMPIValue       value,
                  value1;
  CMPIData        data;
  CMPIData        arr_data;
  CMPIData        dataInst;
  CMPIData        retDataInst;
  CMPIArgs       *args_ptr = NULL;
  CMPIObjectPath *objPath = make_ObjectPath(_broker,
                                            _Namespace,
                                            _ClassName);
  CMPIUint64      datetime1,
                  datetime2;
  const char     *str1;
  const char     *str2;

  size = 17;
  for (i = 0; i < size; i++) {
    args_ptr = CMNewArgs(_broker, &rc);
    switch (types_arr[i].element_type) {
    case CMPI_uint32:
      value.uint32 = 56;
      break;

    case CMPI_uint16:
      value.uint16 = 32;
      break;

    case CMPI_uint8:
      value.uint8 = 56;
      break;

    case CMPI_uint64:
      value.uint64 = 32;
      break;

    case CMPI_sint32:
      value.sint32 = -56;
      break;

    case CMPI_sint16:
      value.sint16 = -32;
      break;

    case CMPI_sint8:
      value.sint8 = -56;
      break;

    case CMPI_sint64:
      value.sint64 = -32;
      break;

    case CMPI_real32:
      value.real32 = (CMPIReal32) -32.78;
      break;

    case CMPI_real64:
      value.real64 = -899.32;
      break;

    case CMPI_char16:
      value.char16 = 'k';
      break;

    case CMPI_string:
      value.string = CMNewString(_broker, "string", &rc);
      break;

    case CMPI_boolean:
      value.boolean = 1;
      break;

    case CMPI_dateTime:
      value.dateTime = CMNewDateTime(_broker, &rc);
      break;

    case CMPI_ref:
      value.ref = CMNewObjectPath(_broker,
                                  "root/cimv2", "Sample_Instance", &rc);
      break;

    case CMPI_null:
      value.args = NULL;
      break;

    case CMPI_instance:
      value.inst = make_Instance(objPath);
      value1.uint32 = 20;
      rc = CMSetProperty(value.inst, "Property1", &value1, CMPI_uint32);
      break;
    }

    arr = NULL;
    rc = CMAddArg(args_ptr,
                  "EmptyArray", (CMPIValue *) & arr, types_arr[i].typeA);
    arr = CMNewArray(_broker, 1, types_arr[i].element_type, &rc);

    rc = CMSetArrayElementAt(arr, 0, &value, types_arr[i].element_type);

    rc = CMAddArg(args_ptr,
                  types_arr[i].args_name,
                  (CMPIValue *) & arr, types_arr[i].typeA);

    flag = 1;
    if ((types_arr[i].element_type) != CMPI_null) {
      data = CMGetArg(args_ptr, types_arr[i].args_name, &rc);

      arr_data = CMGetArrayElementAt(data.value.array, 0, &rc);

      switch (types_arr[i].element_type) {
      case CMPI_uint32:
        if (arr_data.value.uint32 != value.uint32) {
          flag = 0;
        }
        break;

      case CMPI_uint16:
        if (arr_data.value.uint16 != value.uint16) {
          flag = 0;
        }
        break;

      case CMPI_uint8:
        if (arr_data.value.uint8 != value.uint8) {
          flag = 0;
        }
        break;

      case CMPI_uint64:
        if (arr_data.value.uint64 != value.uint64) {
          flag = 0;
        }
        break;

      case CMPI_sint32:
        if (arr_data.value.sint32 != value.sint32) {
          flag = 0;
        }
        break;

      case CMPI_sint16:
        if (arr_data.value.sint16 != value.sint16) {
          flag = 0;
        }
        break;

      case CMPI_sint8:
        if (arr_data.value.sint8 != value.sint8) {
          flag = 0;
        }
        break;

      case CMPI_sint64:
        if (arr_data.value.sint64 != value.sint64) {
          flag = 0;
        }
        break;

      case CMPI_real32:
        if (arr_data.value.real32 != value.real32) {
          flag = 0;
        }
        break;

      case CMPI_real64:
        if (arr_data.value.real64 != value.real64) {
          flag = 0;
        }
        break;

      case CMPI_char16:
        if (arr_data.value.char16 != value.char16) {
          flag = 0;
        }
        break;

      case CMPI_string:
        str1 = CMGetCharsPtr(arr_data.value.string, &rc);
        str2 = CMGetCharsPtr(value.string, &rc1);
        if ((rc.rc != CMPI_RC_OK) ||
            (rc1.rc != CMPI_RC_OK) || strcmp(str1, str2)) {
          flag = 0;
        }
        break;

      case CMPI_boolean:
        if (arr_data.value.boolean != value.boolean) {
          flag = 0;
        }
        break;

      case CMPI_dateTime:
        datetime1 = CMGetBinaryFormat(arr_data.value.dateTime, &rc);
        datetime2 = CMGetBinaryFormat(value.dateTime, &rc1);
        if ((rc.rc != CMPI_RC_OK) ||
            (rc1.rc != CMPI_RC_OK) || (datetime1 != datetime2)) {
          flag = 0;
        }
        rc = CMRelease(value.dateTime);
        break;

      case CMPI_ref:
        retNamespace = CMGetNameSpace(arr_data.value.ref, &rc);
        retClassname = CMGetClassName(arr_data.value.ref, &rc1);
        if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) {
          str1 = CMGetCharsPtr(retNamespace, &rc);
          str2 = CMGetCharsPtr(retClassname, &rc1);
          if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) {
            if ((strcmp(str1, "root/cimv2")) ||
                (strcmp(str2, "TestCMPI_Instance"))) {
              flag = 0;
            }
          } else {
            flag = 0;
          }
        } else {
          flag = 0;
        }
        rc = CMRelease(value.ref);
        break;

      case CMPI_instance:
        retDataInst = CMGetProperty(arr_data.value.inst, "Property1", &rc);
        dataInst = CMGetProperty(value.inst, "Property1", &rc);
        if (retDataInst.value.uint32 != dataInst.value.uint32) {
          flag = 0;
        }
        rc = CMRelease(value.inst);
        break;
      }
      if (data.type == types_arr[i].typeA && flag) {
      }
    }
    rc = CMRelease(arr);
    rc = CMRelease(args_ptr);
  }
  return flag;
}
static int
_testSimpleTypes()
{
  CMPIArgs       *args_ptr = NULL;
  CMPIStatus      rc = { CMPI_RC_OK, NULL };
  CMPIStatus      rc1 = { CMPI_RC_OK, NULL };
  int             i,
                  flag,
                  size;
  CMPIValue       value;
  CMPIValue       value1;
  CMPIData        data;
  CMPIData        dataInst;
  CMPIData        retDataInst;
  CMPIString     *retNamespace = NULL;
  CMPIString     *retClassname = NULL;
  CMPIObjectPath *objPath = make_ObjectPath(_broker,
                                            _Namespace,
                                            _ClassName);
  const char     *str1;
  const char     *str2;

  struct array_types {
    CMPIType        element_type;
    char           *typeName;
    char           *args_name;
  } types_arr[] = {

    {
    CMPI_instance, "CMPI_instance", "CMPI_instance"}, {
  CMPI_ref, "CMPI_ref", "CMPI_ref"}};

  size = 2;

  flag = 1;
  for (i = 0; i < size; i++) {
    args_ptr = CMNewArgs(_broker, &rc);

    switch (types_arr[i].element_type) {
    case CMPI_ref:
      value.ref = CMNewObjectPath(_broker,
                                  "root/cimv2", "Sample_Instance", &rc);
      break;

    case CMPI_instance:
      value.inst = make_Instance(objPath);
      value1.uint32 = 20;
      rc = CMSetProperty(value.inst, "Property1", &value1, CMPI_uint32);
      break;
    }
    rc = CMAddArg(args_ptr,
                  types_arr[i].args_name,
                  (CMPIValue *) & value, types_arr[i].element_type);

    data = CMGetArg(args_ptr, types_arr[i].args_name, &rc);

    switch (types_arr[i].element_type) {
    case CMPI_ref:
      retNamespace = CMGetNameSpace(data.value.ref, &rc);
      retClassname = CMGetClassName(data.value.ref, &rc1);

      if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) {
        str1 = CMGetCharsPtr(retNamespace, &rc);
        str2 = CMGetCharsPtr(retClassname, &rc1);
        if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) {
          if ((strcmp(str1, "root/cimv2")) ||
              (strcmp(str2, "Sample_Instance"))) {
            flag = 0;
          }
        } else {
          flag = 0;
        }
      } else {
        flag = 0;
      }
      rc = CMRelease(value.ref);
      break;

    case CMPI_instance:
      retDataInst = CMGetProperty(data.value.inst, "Property1", &rc);
      dataInst = CMGetProperty(value.inst, "Property1", &rc);
      if (retDataInst.value.uint32 != dataInst.value.uint32) {
        flag = 0;
      }
      rc = CMRelease(value.inst);
      break;
    }
    if (data.type == types_arr[i].element_type && flag) {
    }
    rc = CMRelease(args_ptr);
  }
  return flag;
}
static int
_testCMPIObjectPath()
{
  CMPIStatus      rc = { CMPI_RC_OK, NULL };

  CMPIObjectPath *objPath = NULL;
  CMPIObjectPath *clonedObjPath = NULL;
  CMPIObjectPath *otherObjPath = NULL;
  CMPIObjectPath *fakeObjPath = NULL;

  const char     *hostName = "HOSTNAME";
  const char     *nameSpace = "root/dummy";
  const char     *className = "classname";

  CMPIString     *returnedHostname = NULL;
  CMPIBoolean     equalHostname = 0;
  CMPIString     *returnedNamespace = NULL;
  CMPIBoolean     equalNamespace = 0;
  CMPIString     *returnedClassName;
  CMPIBoolean     equalClassName = 0;
  CMPIString     *returnedObjectPath;
  CMPIBoolean     cloneSuccessful = 0;
  CMPIBoolean     getKeySuccessful = 0;
  CMPIBoolean     getKeyCountSuccessful = 0;
  CMPIBoolean     getKeyAtSuccessful = 0;
  const char     *objectPath1 = NULL;
  const char     *objectPath2 = NULL;
  CMPIData        data;
  CMPIValue       value;
  unsigned int    keyCount = 0;
  objPath = make_ObjectPath(_broker, _Namespace, _ClassName);
  rc = CMSetHostname(objPath, hostName);
  returnedHostname = CMGetHostname(objPath, &rc);
  if (strcmp(hostName, CMGetCharsPtr(returnedHostname, &rc)) == 0) {
    equalHostname = 1;
  }
  rc = CMSetNameSpace(objPath, nameSpace);
  returnedNamespace = CMGetNameSpace(objPath, &rc);
  if (strcmp(nameSpace, CMGetCharsPtr(returnedNamespace, &rc)) == 0) {
    equalNamespace = 1;
  }
  rc = CMSetClassName(objPath, className);
  returnedClassName = CMGetClassName(objPath, &rc);
  if (strcmp(className, CMGetCharsPtr(returnedClassName, &rc)) == 0) {
    equalClassName = 1;
  }
  otherObjPath = make_ObjectPath(_broker, _Namespace, _ClassName);
  returnedNamespace = CMGetNameSpace(otherObjPath, &rc);
  rc = CMSetNameSpaceFromObjectPath(otherObjPath, objPath);
  returnedNamespace = CMGetNameSpace(otherObjPath, &rc);
  if (strcmp(nameSpace, CMGetCharsPtr(returnedNamespace, &rc)) == 0) {
    equalNamespace = 1;
  }
  returnedHostname = CMGetHostname(otherObjPath, &rc);
  rc = CMSetHostAndNameSpaceFromObjectPath(otherObjPath, objPath);
  returnedHostname = CMGetHostname(otherObjPath, &rc);
  if (strcmp(hostName, CMGetCharsPtr(returnedHostname, &rc)) == 0) {
    equalHostname = 1;
  }
  returnedObjectPath = CMObjectPathToString(objPath, &rc);
  objectPath1 = CMGetCharsPtr(returnedObjectPath, &rc);
  clonedObjPath = objPath->ft->clone(objPath, &rc);
  returnedObjectPath = CMObjectPathToString(clonedObjPath, &rc);
  rc = clonedObjPath->ft->release(clonedObjPath);
  objectPath2 = CMGetCharsPtr(returnedObjectPath, &rc);
  if (strcmp(objectPath1, objectPath2) == 0) {
    cloneSuccessful = 1;
  } else {
    cloneSuccessful = 0;
  }
  fakeObjPath = CMNewObjectPath(_broker, "root#cimv2",
                                "Sample_Instance", &rc);
  rc = CMAddKey(fakeObjPath, "ElementName",
                (CMPIValue *) "Fake", CMPI_chars);
  rc = CMAddKey(otherObjPath, "ElementName1",
                (CMPIValue *) "otherObjPath", CMPI_chars);
  data = CMGetKey(fakeObjPath, "ElementName", &rc);
  if (strcmp(CMGetCharsPtr(data.value.string, &rc), "Fake") == 0) {
    getKeySuccessful = 1;
  }
  keyCount = CMGetKeyCount(fakeObjPath, &rc);
  if (keyCount == 1) {
    getKeyCountSuccessful = 1;
  }
  data = CMGetKeyAt(fakeObjPath, 0, NULL, &rc);
  if (rc.rc == 0) {
    getKeyAtSuccessful = 1;
  }
  value.uint16 = 67;
  rc = CMAddKey(fakeObjPath, "Numeric_key_unsigned",
                (CMPIValue *) & value, CMPI_uint16);
  data = CMGetKey(fakeObjPath, "Numeric_key_unsigned", &rc);
  value.sint16 = -67;
  rc = CMAddKey(fakeObjPath, "Numeric_key_signed",
                (CMPIValue *) & value, CMPI_sint16);
  data = CMGetKey(fakeObjPath, "Numeric_key_signed", &rc);
  value.boolean = 1;
  rc = CMAddKey(fakeObjPath, "Boolean_key",
                (CMPIValue *) & value, CMPI_boolean);
  data = CMGetKey(fakeObjPath, "Boolean_key", &rc);
  CMGetKeyAt(objPath, 500, NULL, &rc);
  if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) {
    return 1;
  }
  rc = objPath->ft->release(objPath);
  rc = fakeObjPath->ft->release(fakeObjPath);
  return 0;
}
Example #21
0
CMPIStatus TestMethodProviderInvokeMethod (
    CMPIMethodMI * mi,
    const CMPIContext * ctx,
    const CMPIResult * rslt,
    const CMPIObjectPath * ref,
    const char *methodName,
    const CMPIArgs * in,
    CMPIArgs * out)
{
    CMPIStatus rc = { CMPI_RC_OK, NULL };
    CMPIString *className;
    CMPIData data;
    char result[80] = "Hello,";
    const char *strCat;
    const char * name;
    char *argName = "Message";
    CMPIString * str1;
    CMPIString * str2;
    CMPIValue val1, val2;
    /* get the class name from object-path */
    className = CMGetClassName(ref, &rc);
    /* get a pointer to a C char* representation of this String. */
    name = CMGetCharsPtr(className, &rc);

    if(!strcmp(name, _ClassName))
    {
       if(!strcmp ("SayHello", methodName))
       {
            /* gets the number of arguments contained in "in" Args. */
            if(CMGetArgCount(in, &rc) > 0)
            {
                /* gets a Name argument value */
                data = CMGetArg(in, "Name", &rc);
                /*check for data type and not null value of argument value
                  recieved */
                if(data.type == CMPI_string &&  !(CMIsNullValue(data)))
                {
                    strCat = CMGetCharsPtr(data.value.string, &rc);
                    strcat(result, strCat);
//                    strcat(result, "!");
                    /* create the new string to return to client */
                    str1 = CMNewString(_broker, result, &rc);
                    val1.string = str1;
                }
            }
            else
            {
                str1 = CMNewString(_broker, result, &rc);
                val1.string = str1;
            }
            /* create string to add to an array */
            str2 = CMNewString(_broker,"Have a good day", &rc);
            val2.string = str2;
            /* Adds a value of str2 string to out array argument */
            rc = CMAddArg(out, argName, &val2, CMPI_string);
        } else if (!strcmp("CheckArrayNoType", methodName)) {
            data = CMGetArg(in, "IntArray", &rc);
            CMPIType atype=data.value.array->ft->getSimpleType(data.value.array,&rc); 
            sprintf(result,"Datatype is %s",paramType(atype));
            str1 = CMNewString(_broker, result, &rc);
            val1.string = str1;
        }

    }
    CMReturnData (rslt, (CMPIValue *) &val1, CMPI_string);
    CMReturnDone (rslt);
    return rc;
}
Example #22
0
CMPIStatus
TestCMPIErrorProviderInvokeMethod (CMPIMethodMI * mi,
                                    const CMPIContext * ctx,
                                    const CMPIResult * rslt,
                                    const CMPIObjectPath * ref,
                                    const char *methodName,
                                    const CMPIArgs * in, CMPIArgs * out)
{
  CMPIString *class_name = NULL;
  CMPIStatus rc = { CMPI_RC_OK, NULL };
  CMPIError *cmpiError;
  CMPIError *cmpiErrorClone;
  CMPICount i, arrSize;
  CMPIObjectPath *objPath = NULL;


  CMPIUint32 brokerCapabilities;
  /* CMPIError data */
  const char* inOwningEntity = "ACME";
  CMPIString* outOwningEntity;
  const char* inMsgID = "ACME0023";
  CMPIString* outMsgID;
  const char* inMsg = "ACME0023 Need to restock Road Runner bait and traps.";
  CMPIString* outMsg;
  const CMPIErrorSeverity inSev = ErrorSevMedium;
  CMPIErrorSeverity outSev;
  const CMPIErrorProbableCause inPc = Equipment_Malfunction;
  CMPIErrorProbableCause outPc;
  const CMPIrc inCIMStatusCode = CMPI_RC_ERR_FAILED;
  CMPIrc outCIMStatusCode;
  const char * inCIMStatusCodeDesc = "another failed attempt at road "
      "runner elimination";
  CMPIString* outCIMStatusCodeDesc;
  const CMPIErrorType inErrType = OtherErrorType;
  CMPIErrorType outErrType;
  const char* inOtherErrType = "Pervasive Coyote Incompetance";
  CMPIString* outOtherErrType;
  const char* inPcd = "Incorrect use of equipment";
  CMPIString* outPcd;
  CMPIArray *inRecActions;
  CMPIArray *outRecActions;
  CMPIArray *inMsgArgs;
  CMPIArray *outMsgArgs;
  CMPIValue raOne;
  CMPIValue raTwo;
  const char* inErrSource = "Acme bomb";
  CMPIString* outErrSource;
  const CMPIErrorSrcFormat inErrSourceFormat = CMPIErrSrcOther;
  CMPIErrorSrcFormat outErrSourceFormat;
  const char* inOtherErrSourceFormat = "no idea";
  CMPIString* outOtherErrSourceFormat;
  CMPIData retData;
  PROV_LOG_OPEN (_ClassName, _ProviderLocation);

  PROV_LOG ("Calling CBGetBrokerCapabilities");
  brokerCapabilities = CBGetBrokerCapabilities(_broker);
  if (brokerCapabilities & CMPI_MB_Supports_Extended_Error)
  {
      PROV_LOG("CMPI_MB_Supports_Extended_Error Support : True");
  }
  else
  {
      PROV_LOG("CMPI_MB_Supports_Extended_Error Support : False");
      CMReturnWithString(CMPI_RC_ERR_NOT_SUPPORTED, 
          CMNewString(_broker,
          "Extended error support not avilable", NULL));
  } 

  PROV_LOG ("--- %s CMPI InvokeMethod() called", _ClassName);

  class_name = CMGetClassName (ref, &rc);

  PROV_LOG ("InvokeMethod: checking for correct classname [%s]",
            CMGetCharsPtr (class_name,NULL));

  PROV_LOG ("Calling CMNewCMPIError");
  cmpiError = CMNewCMPIError(_broker, inOwningEntity, inMsgID, inMsg,
      inSev, inPc, inCIMStatusCode, &rc);
  PROV_LOG ("++++ (%s) CMNewCMPIError", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetErrorType");
  rc = CMSetErrorType(cmpiError, inErrType);
  PROV_LOG ("++++ (%s) CMSetErrorType", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetOtherErrorType");
  rc = CMSetOtherErrorType(cmpiError, inOtherErrType);
  PROV_LOG ("++++ (%s) CMSetOtherErrorType", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetProbableCauseDescription");
  rc = CMSetProbableCauseDescription(cmpiError, inPcd);
  PROV_LOG ("++++ (%s) CMSetProbableCauseDescription", strCMPIStatus (rc));

  inRecActions = CMNewArray(_broker, 2, CMPI_string, &rc);
  PROV_LOG ("++++ (%s) CMNewArray", strCMPIStatus (rc));
  raOne.string = CMNewString(_broker, "Fire coyote.", &rc);
  PROV_LOG ("++++ (%s) CMNewString", strCMPIStatus (rc));
  rc = CMSetArrayElementAt(inRecActions, 0, &raOne, CMPI_string);
  PROV_LOG ("++++ (%s) CMSetArrayElementAt [0]", strCMPIStatus (rc));
  raTwo.string = CMNewString(_broker, "Give peace a chance.", &rc);
  PROV_LOG ("++++ (%s) CMNewString", strCMPIStatus (rc));
  rc = CMSetArrayElementAt(inRecActions, 1, &raTwo, CMPI_string);
  PROV_LOG ("++++ (%s) CMSetArrayElementAt [1]", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetRecommendedActions");
  rc = CMSetRecommendedActions(cmpiError, inRecActions);
  PROV_LOG ("++++ (%s) CMSetRecommendedActions", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetErrorSource");
  rc = CMSetErrorSource(cmpiError, inErrSource);
  PROV_LOG ("++++ (%s) CMSetErrorSource", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetErrorSourceFormat");
  rc = CMSetErrorSourceFormat(cmpiError, inErrSourceFormat);
  PROV_LOG ("++++ (%s) CMSetErrorSourceFormat", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetOtherErrorSourceFormat");
  rc = CMSetOtherErrorSourceFormat(cmpiError, inOtherErrSourceFormat);
  PROV_LOG ("++++ (%s) CMSetOtherErrorSourceFormat", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetCIMStatusCodeDescription");
  rc = CMSetCIMStatusCodeDescription(cmpiError, inCIMStatusCodeDesc);
  PROV_LOG ("++++ (%s) CMSetCIMStatusCodeDescription", strCMPIStatus (rc));

  inMsgArgs = CMNewArray(_broker, 1, CMPI_string, &rc);
  PROV_LOG ("++++ (%s) CMNewArray", strCMPIStatus (rc));
  raOne.string = CMNewString(_broker, "no real inserts", &rc);
  PROV_LOG ("++++ (%s) CMNewString", strCMPIStatus (rc));
  rc = CMSetArrayElementAt(inMsgArgs, 0, &raOne, CMPI_string);
  PROV_LOG ("++++ (%s) CMSetArrayElementAt [0]", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetMessageArguments");
  rc = CMSetMessageArguments(cmpiError, inMsgArgs);
  PROV_LOG ("++++ (%s) CMSetMessageArguments", strCMPIStatus (rc));

  PROV_LOG ("First clone the CMPIError.");
  cmpiErrorClone = CMClone(cmpiError, &rc);
  PROV_LOG ("++++ (%s) CMClone", strCMPIStatus (rc));

  PROV_LOG ("Ok, reading back fields to verify");
  
  PROV_LOG ("Calling CMGetErrorType");
  outErrType = CMGetErrorType(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetErrorType (%d)", strCMPIStatus (rc), outErrType);

  PROV_LOG ("Calling CMGetOtherErrorType");
  outOtherErrType = CMGetOtherErrorType(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetOtherErrorType (%s)", strCMPIStatus (rc), 
      CMGetCharsPtr(outOtherErrType,NULL));

  PROV_LOG ("Calling CMGetOwningEntity");
  outOwningEntity = CMGetOwningEntity(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetOwningEntity (%s)", strCMPIStatus (rc), 
      CMGetCharsPtr(outOwningEntity,NULL));

  PROV_LOG ("Calling CMGetMessageID");
  outMsgID = CMGetMessageID(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetMessageID (%s)", strCMPIStatus (rc), 
      CMGetCharsPtr(outMsgID,NULL));

  PROV_LOG ("Calling CMGetErrorMessage");
  outMsg = CMGetErrorMessage(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetErrorMessage (%s)", strCMPIStatus (rc), 
      CMGetCharsPtr(outMsg,NULL));

  PROV_LOG ("Calling CMGetPerceivedSeverity");
  outSev = CMGetPerceivedSeverity(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetPerceivedSeverity (%d)", strCMPIStatus (rc),
      outSev);

  PROV_LOG ("Calling CMGetProbableCause");
  outPc = CMGetProbableCause(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetProbableCause (%d)", strCMPIStatus (rc),
      outPc);

  PROV_LOG ("Calling CMGetProbableCauseDescription");
  outPcd = CMGetProbableCauseDescription(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetProbableCauseDescription (%s)",
      strCMPIStatus (rc),
      CMGetCharsPtr(outPcd,NULL));

  PROV_LOG ("Calling CMGetRecommendedActions");
  outRecActions = CMGetRecommendedActions(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetRecommendedActions", strCMPIStatus (rc));
  arrSize = CMGetArrayCount(outRecActions, &rc);
  PROV_LOG ("++++ (%s) CMGetArrayCount (%d)", strCMPIStatus (rc), arrSize);
  for (i = 0 ; i < arrSize ; i++)
  {
      CMPIData dta = CMGetArrayElementAt(outRecActions, i, &rc);
      PROV_LOG ("++++ (%s) CMGetArrayElementAt (%d:%s)", strCMPIStatus (rc),
          i, CMGetCharsPtr(dta.value.string,NULL));
  }

  PROV_LOG ("Calling CMGetErrorSource");
  outErrSource = CMGetErrorSource(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetErrorSource (%s)", strCMPIStatus (rc),
      CMGetCharsPtr(outErrSource,NULL));

  PROV_LOG ("Calling CMGetErrorSourceFormat");
  outErrSourceFormat = CMGetErrorSourceFormat(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetErrorSourceFormat (%d)", strCMPIStatus (rc),
      outErrSourceFormat);

  PROV_LOG ("Calling CMGetOtherErrorSourceFormat");
  outOtherErrSourceFormat = CMGetOtherErrorSourceFormat(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetOtherErrorSourceFormat (%s)", strCMPIStatus (rc),
      CMGetCharsPtr(outOtherErrSourceFormat,NULL));

  PROV_LOG ("Calling CMGetCIMStatusCode");
  outCIMStatusCode = CMGetCIMStatusCode(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetCIMStatusCode (%d)", strCMPIStatus (rc),
      outCIMStatusCode);

  PROV_LOG ("Calling CMGetCIMStatusCodeDescription");
  outCIMStatusCodeDesc = CMGetCIMStatusCodeDescription(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetCIMStatusCodeDescription (%s)", strCMPIStatus (rc),
      CMGetCharsPtr(outCIMStatusCodeDesc,NULL));

  PROV_LOG ("Calling CMGetMessageArguments");
  outMsgArgs = CMGetMessageArguments(cmpiErrorClone, &rc);
  PROV_LOG ("++++ (%s) CMGetMessageArguments", strCMPIStatus (rc));
  arrSize = CMGetArrayCount(outMsgArgs, &rc);
  PROV_LOG ("++++ (%s) CMGetArrayCount (%d)", strCMPIStatus (rc), arrSize);
  for (i = 0 ; i < arrSize ; i++)
  {
      CMPIData dta = CMGetArrayElementAt(outMsgArgs, i, &rc);
      PROV_LOG ("++++ (%s) CMGetArrayElementAt (%d:%s)", strCMPIStatus (rc),
          i, CMGetCharsPtr(dta.value.string,NULL));
  }

  PROV_LOG ("Calling CMPIResultFT.returnData");
  rc = (rslt)->ft->returnError (rslt, cmpiErrorClone);
  PROV_LOG ("++++ (%s) returnData", strCMPIStatus (rc));

  PROV_LOG ("Releasing cloned CMPIError");
  rc = CMRelease(cmpiErrorClone);
  PROV_LOG ("++++ (%s) CMClone", strCMPIStatus (rc));

//Test Error Paths
  PROV_LOG ("Testing for Error Paths in CMPI_Error.cpp");
  PROV_LOG ("Calling CMNewCMPIError");
  cmpiError = CMNewCMPIError(_broker, 
      inOwningEntity,
      inMsgID,
      inMsg,
      inSev,
      inPc,
      inCIMStatusCode,
      &rc);
  PROV_LOG ("++++ (%s) CMNewCMPIError", strCMPIStatus (rc));

  PROV_LOG ("Calling CMGetErrorType without setting the ErrorType");
  outErrType = CMGetErrorType(cmpiError, &rc);
  if (!outErrType)
  {
      PROV_LOG ("++++ (%s) CMGetErrorType (%d)", strCMPIStatus (rc),
          outErrType);
  }

  PROV_LOG ("Calling CMGetOtherErrorType without setting the OtherErrorType");
  outOtherErrType = CMGetOtherErrorType(cmpiError, &rc);
  if (outOtherErrType == NULL)
  {
      PROV_LOG ("++++ (%s) CMGetOtherErrorType", strCMPIStatus (rc));
  }

  PROV_LOG ("Testing CMSetMessageArguments");
  CMRelease(inMsgArgs);
  inMsgArgs = CMNewArray(_broker, 1, CMPI_uint32, &rc);
  PROV_LOG ("++++ (%s) CMNewArray inMsgArgs of CMPI_uint32 type",
      strCMPIStatus (rc));
  raOne.uint32 = 32;
  rc = CMSetArrayElementAt(inMsgArgs, 0, &raOne, CMPI_uint32);
  PROV_LOG ("++++ (%s) CMSetArrayElementAt [0]", strCMPIStatus (rc));
  PROV_LOG ("Calling CMSetMessageArguments with input array of uint32");
  rc = CMSetMessageArguments(cmpiError, inMsgArgs);
  PROV_LOG ("++++ (%s) CMSetMessageArguments", strCMPIStatus (rc));
  inMsgArgs->hdl = NULL;
  PROV_LOG ("Calling CMSetMessageArguments with input array with NULL handle");
  rc = CMSetMessageArguments(cmpiError, inMsgArgs);
  PROV_LOG ("++++ (%s) CMSetMessageArguments", strCMPIStatus (rc));

  PROV_LOG ("Testing CMSetRecommendedActions");
  CMRelease(inRecActions);
  inRecActions = CMNewArray(_broker, 1, CMPI_uint32, &rc);
  PROV_LOG ("++++ (%s) CMNewArray inRecActions of CMPI_uint32",
      strCMPIStatus (rc));
  raOne.uint32 = 32;
  rc = CMSetArrayElementAt(inRecActions, 0, &raOne, CMPI_uint32);
  PROV_LOG ("++++ (%s) CMSetArrayElementAt [0]", strCMPIStatus (rc));
  PROV_LOG ("Calling CMSetRecommendedActions with input array of CMPI_uint32");
  rc = CMSetRecommendedActions(cmpiError, inRecActions);
  PROV_LOG ("++++ (%s) CMSetRecommendedActions", strCMPIStatus (rc));
  inRecActions->hdl = NULL;
  PROV_LOG ("Calling CMSetRecommendedActions with input array"
      " with NULL handle");
  rc = CMSetRecommendedActions(cmpiError, inRecActions);
  PROV_LOG ("++++ (%s) CMSetRecommendedActions", strCMPIStatus (rc));

  /* Cases when CMPIError object handle is NULL*/
  cmpiError->hdl = NULL;

  PROV_LOG ("Clone the CMPIError with NULL handle.");
  cmpiErrorClone = CMClone(cmpiError, &rc);
  if (cmpiErrorClone == NULL)
  {
      PROV_LOG ("++++ (%s) CMClone", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetErrorType with NULL handle");
  outErrType = CMGetErrorType(cmpiError, &rc);
  if (!outErrType)
  {
      PROV_LOG ("++++ (%s) CMGetErrorType (%d)", strCMPIStatus (rc),
          outErrType);
  }

  PROV_LOG ("Calling CMGetOtherErrorType with NULL handle");
  outOtherErrType = CMGetOtherErrorType(cmpiError, &rc);
  if (outOtherErrType == NULL)
  {
      PROV_LOG ("++++ (%s) CMGetOtherErrorType ", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetOwningEntity with NULL handle");
  outOwningEntity = CMGetOwningEntity(cmpiError, &rc);
  if (outOwningEntity == NULL)
  {
      PROV_LOG ("++++ (%s) CMGetOwningEntity ", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetMessageID with NULL handle");
  outMsgID = CMGetMessageID(cmpiError, &rc);
  if (!outMsgID)
  {
      PROV_LOG ("++++ (%s) CMGetMessageID", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetErrorMessage with NULL handle");
  outMsg = CMGetErrorMessage(cmpiError, &rc);
  if (!outMsg)
  {
      PROV_LOG ("++++ (%s) CMGetErrorMessage", strCMPIStatus (rc));
  }
  PROV_LOG ("Calling CMGetPerceivedSeverity with NULL handle");
  outSev = CMGetPerceivedSeverity(cmpiError, &rc);
  if (!outSev)
  {
      PROV_LOG ("++++ (%s) CMGetPerceivedSeverity (%d)", strCMPIStatus (rc),
          outSev);
  }

  PROV_LOG ("Calling CMGetProbableCause with NULL handle");
  outPc = CMGetProbableCause(cmpiError, &rc);
  if (!outPc)
  {
      PROV_LOG ("++++ (%s) CMGetProbableCause (%d)", strCMPIStatus (rc),
          outPc);
  }

  PROV_LOG ("Calling CMGetProbableCauseDescription with NULL handle");
  outPcd = CMGetProbableCauseDescription(cmpiError, &rc);
  if (!outPcd)
  {
      PROV_LOG ("++++ (%s) CMGetProbableCauseDescription ",
          strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetRecommendedActions with NULL handle");
  outRecActions = CMGetRecommendedActions(cmpiError, &rc);
  if (!outRecActions)
  {
      PROV_LOG ("++++ (%s) CMGetRecommendedActions", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetErrorSource with NULL handle");
  outErrSource = CMGetErrorSource(cmpiError, &rc);
  if (!outErrSource)
  {
      PROV_LOG ("++++ (%s) CMGetErrorSource", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetErrorSourceFormat with NULL handle");
  outErrSourceFormat = CMGetErrorSourceFormat(cmpiError, &rc);
  if (!outErrSourceFormat)
  {
      PROV_LOG ("++++ (%s) CMGetErrorSourceFormat (%d)", strCMPIStatus (rc),
          outErrSourceFormat);
  }

  PROV_LOG ("Calling CMGetOtherErrorSourceFormat with NULL handle");
  outOtherErrSourceFormat = CMGetOtherErrorSourceFormat(cmpiError, &rc);
  if (!outOtherErrSourceFormat)
  {
      PROV_LOG ("++++ (%s) CMGetOtherErrorSourceFormat", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetCIMStatusCode with NULL handle");
  outCIMStatusCode = CMGetCIMStatusCode(cmpiError, &rc);
  if (!outCIMStatusCode)
  {
      PROV_LOG ("++++ (%s) CMGetCIMStatusCode (%d)", strCMPIStatus (rc),
          outCIMStatusCode);
  }

  PROV_LOG ("Calling CMGetCIMStatusCodeDescription with NULL handle");
  outCIMStatusCodeDesc = CMGetCIMStatusCodeDescription(cmpiError, &rc);
  if (!outCIMStatusCodeDesc)
  {
      PROV_LOG ("++++ (%s) CMGetCIMStatusCodeDescription", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMGetMessageArguments with NULL handle");
  outMsgArgs = CMGetMessageArguments(cmpiError, &rc);
  if (!outMsgArgs)
  {
      PROV_LOG ("++++ (%s) CMGetMessageArguments", strCMPIStatus (rc));
  }

  PROV_LOG ("Calling CMSetErrorType with NULL handle");
  rc = CMSetErrorType(cmpiError, inErrType);
  PROV_LOG ("++++ (%s) CMSetErrorType", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetOtherErrorType with NULL handle");
  rc = CMSetOtherErrorType(cmpiError, inOtherErrType);
  PROV_LOG ("++++ (%s) CMSetOtherErrorType", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetProbableCauseDescription with NULL handle");
  rc = CMSetProbableCauseDescription(cmpiError, inPcd);
  PROV_LOG ("++++ (%s) CMSetProbableCauseDescription", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetRecommendedActions with NULL handle");
  rc = CMSetRecommendedActions(cmpiError, inRecActions);
  PROV_LOG ("++++ (%s) CMSetRecommendedActions", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetErrorSource with NULL handle");
  rc = CMSetErrorSource(cmpiError, inErrSource);
  PROV_LOG ("++++ (%s) CMSetErrorSource", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetErrorSourceFormat with NULL handle");
  rc = CMSetErrorSourceFormat(cmpiError, inErrSourceFormat);
  PROV_LOG ("++++ (%s) CMSetErrorSourceFormat", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetOtherErrorSourceFormat with NULL handle");
  rc = CMSetOtherErrorSourceFormat(cmpiError, inOtherErrSourceFormat);
  PROV_LOG ("++++ (%s) CMSetOtherErrorSourceFormat", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetCIMStatusCodeDescription with NULL handle");
  rc = CMSetCIMStatusCodeDescription(cmpiError, inCIMStatusCodeDesc);
  PROV_LOG ("++++ (%s) CMSetCIMStatusCodeDescription", strCMPIStatus (rc));

  PROV_LOG ("Calling CMSetMessageArguments with NULL handle");
  rc = CMSetMessageArguments(cmpiError, inMsgArgs);
  PROV_LOG ("++++ (%s) CMSetMessageArguments", strCMPIStatus (rc));

  PROV_LOG_CLOSE();
  // Test case to increase coverage in CMPI_Broker.cpp
  objPath = CMNewObjectPath (_broker,
      "test/TestProvider",
      "TestCMPI_Method",
      &rc);
  retData = CBInvokeMethod(_broker,
      ctx,
      objPath,
      "testReturn",
      in,
      out,
      &rc);
  PROV_LOG_OPEN (_ClassName, _ProviderLocation);

  if(retData.value.uint32 == 2 && rc.rc == CMPI_RC_OK)
  {
      PROV_LOG ("++++ (%s) CMInvokeMethod", strCMPIStatus (rc));
  }
  PROV_LOG ("--- %s CMPI InvokeMethod() exited with CMPI_RC_ERR_FAILED", 
      _ClassName);
  PROV_LOG_CLOSE();
  CMReturnWithString(inCIMStatusCode, 
      CMNewString(_broker, "TestError invokeMethod() expected failure", NULL));
}
CMPIStatus
TestMethodProviderInvokeMethod(CMPIMethodMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * ref,
                               const char *methodName,
                               const CMPIArgs * in, CMPIArgs * out)
{
  CMPIStatus      rc = { CMPI_RC_OK, NULL };
  CMPIString     *className;
  CMPIData        data;
  char            result[80] = "Hello,";
  const char     *strCat;
  const char     *name;
  char           *argName = "Message";
  CMPIString     *str1;
  CMPIString     *str2;
  CMPIValue       val1,
                  val2;

  /*
   * get the class name from object-path 
   */
  className = CMGetClassName(ref, &rc);
  /*
   * get a pointer to a C char* representation of this String. 
   */
  name = CMGetCharsPtr(className, &rc);

  if (!strcmp(name, _ClassName)) {
    if (!strcmp("SayHello", methodName)) {
      /*
       * gets the number of arguments contained in "in" Args. 
       */
      if (CMGetArgCount(in, &rc) > 0) {
        /*
         * gets a Name argument value 
         */
        data = CMGetArg(in, "Name", &rc);
        /*
         * check for data type and not null value of argument value
         * recieved 
         */
        if (data.type == CMPI_string && !(CMIsNullValue(data))) {
          strCat = CMGetCharsPtr(data.value.string, &rc);
          strcat(result, strCat);
          // strcat(result, "!");
          /*
           * create the new string to return to client 
           */
          str1 = CMNewString(_broker, result, &rc);
          val1.string = str1;
        }
      } else {
        str1 = CMNewString(_broker, result, &rc);
        val1.string = str1;
      }
      /*
       * create string to add to an array 
       */
      str2 = CMNewString(_broker, "Have a good day", &rc);
      val2.string = str2;
      /*
       * Adds a value of str2 string to out array argument 
       */
      rc = CMAddArg(out, argName, &val2, CMPI_string);

    /*
     * For: 3048960 method array types not filled in Test provider. 
     */
    } else if (!strcmp("CheckArrayNoType", methodName)) {
      data = CMGetArg(in, "IntArray", &rc);
      CMPIType atype=data.value.array->ft->getSimpleType(data.value.array,&rc); 
      sprintf(result,"Datatype is %s",paramType(atype));
      str1 = CMNewString(_broker, result, &rc);
      val1.string = str1;

    /*
     * This method simulates various provider problems for testing. 
     */
    } else if (!strcmp("Misbehave", methodName)) {
      data = CMGetArg(in, "Action", &rc);

      const char *strval = NULL;
      if (data.type == CMPI_string && !(CMIsNullValue(data))) {
        strval = CMGetCharsPtr(data.value.string, &rc);
        sprintf(result, "data type is %s, value = %s", paramType(data.type),
            strval);
        
        if (!strcmp(strval,"hang")) {
          while(sleep(60)); /* to test req handler timeout, etc. */
        }
        else if (!strcmp(strval,"abort")) {
          abort();
        }
        else if (!strcmp(strval,"fpe")) {
          #pragma GCC diagnostic ignored "-Wdiv-by-zero"
          fprintf(stderr,"ouch! %d\n",1/0);
          #pragma GCC diagnostic warning "-Wdiv-by-zero"
        }
        else if (!strcmp(strval,"segfault")) {
          void (*crashme)(void) = NULL;
          crashme();
        }
        /*
         * These tend to behave as if the condition were raised internally
         */
        else if (!strcmp(strval,"sigabrt")) {
          kill(getpid(), SIGABRT);
          while(sleep(3)); /* slight pause to ensure we catch signal */
        }
        else if (!strcmp(strval,"sigfpe")) {
          kill(getpid(), SIGFPE);
          while(sleep(3));
        }
        else if (!strcmp(strval,"sigsegv")) {
          kill(getpid(), SIGSEGV);
          while(sleep(3));
        }
        else if (!strcmp(strval,"sigusr1")) {
          kill(getpid(), SIGUSR1); /* as if we received a signal from stopBroker() */
          while(sleep(3));
        }
        else if (!strcmp(strval,"sigkill")) {
          kill(getpid(), SIGKILL); /* this is currently not handled by providerDrv*/
          while(sleep(3));
        } else {
          sprintf(result, "Action not recognized: %s", strval);
          fprintf(stderr,
              "+++ cmpiTestMethodProvider: Action not recognized \"%s\"\n",
              strval);
        }
        /*
         * create the new string to return to client 
         */
        str1 = CMNewString(_broker, result, &rc);
        val1.string = str1;
      }

    } else {
      sprintf(result, "Unknown method name: %s", methodName);
      fprintf(stderr,
          "+++ cmpiTestMethodProvider: Unknown method name \"%s\"\n",
          methodName);
      
      str1 = CMNewString(_broker, result, &rc);
      val1.string = str1;
    }
  }
  CMReturnData(rslt, (CMPIValue *) & val1, CMPI_string);
  CMReturnDone(rslt);
  return rc;
}
CMPIStatus
InternalProviderCreateInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  unsigned long   len;
  void           *blob;
  CMPIString     *cn = CMGetClassName(cop, NULL);
  CMPIString     *ns = CMGetNameSpace(cop, NULL);
  char           *key = normalizeObjectPathCharsDup(cop);
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderCreateInstance");

  if (testNameSpace(bnss, &st) == 0) {
    free(key);
    _SFCB_RETURN(st);
  }

  CMPIConstClass *cc = getConstClass(nss, cns);
  /*
   * per DSP0004 2.5.2 
   */
  if (cc != NULL && cc->ft->isAbstract(cc) != 0) {
    CMPIStatus      st = { CMPI_RC_ERR_NOT_SUPPORTED, NULL };
    free(key);
    _SFCB_RETURN(st);
  }

  if (existingBlob(bnss, cns, key)) {
    CMPIStatus      st = { CMPI_RC_ERR_ALREADY_EXISTS, NULL };
    free(key);
    _SFCB_RETURN(st);
  }

  len = getInstanceSerializedSize(ci);
  blob = malloc(len + 64);
  getSerializedInstance(ci, blob);

  if (addBlob(bnss, cns, key, blob, (int) len)) {
    CMPIStatus      st = { CMPI_RC_ERR_FAILED, NULL };
    st.msg =
        sfcb_native_new_CMPIString("Unable to write to repository", NULL,
                                   0);
    free(blob);
    free(key);
    _SFCB_RETURN(st);
  }
  free(blob);

  if (rslt) {
    CMReturnObjectPath(rslt, cop);
  }

  free(key);
  _SFCB_RETURN(st);
}
Example #25
0
CMPIStatus
IndCIMXMLHandlerCreateInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIArgs       *in,
                 *out = NULL;
  CMPIObjectPath *op;
  unsigned short  persistenceType;

  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerCreateInstance");

  if (interOpNameSpace(cop, &st) == 0)
    _SFCB_RETURN(st);

  CMPIInstance   *ciLocal = CMClone(ci, NULL);
  memLinkInstance(ciLocal);
  CMPIObjectPath* copLocal = CMClone(cop, NULL);
  memLinkObjectPath(copLocal);

  setCCN(copLocal,ciLocal,"CIM_ComputerSystem");

  internalProviderGetInstance(copLocal, &st);
  if (st.rc == CMPI_RC_ERR_FAILED)
    _SFCB_RETURN(st);
  if (st.rc == CMPI_RC_OK) {
    setStatus(&st, CMPI_RC_ERR_ALREADY_EXISTS, NULL);
    _SFCB_RETURN(st);
  }


  CMPIString *sysname=ciLocal->ft->getProperty(ciLocal,"SystemName",&st).value.string;
  if (sysname == NULL || sysname->hdl == NULL) {
    char hostName[512];
    hostName[0]=0;
    gethostname(hostName,511); /* should be the same as SystemName of IndicationService */
    CMAddKey(copLocal, "SystemName", hostName, CMPI_chars);
    CMSetProperty(ciLocal,"SystemName",hostName,CMPI_chars);
  }


  CMPIString     *dest =
      CMGetProperty(ciLocal, "destination", &st).value.string;
  if (dest == NULL || CMGetCharPtr(dest) == NULL) {
    setStatus(&st, CMPI_RC_ERR_FAILED,
              "Destination property not found; is required");
    CMRelease(ciLocal);
    _SFCB_RETURN(st);
  } else {                      /* if no scheme is given, assume http (as
                                 * req. for param by mof) */
    char           *ds = CMGetCharPtr(dest);
    if (strstr(ds, "://") == NULL) {
      char           *prefix = "http://";
      int             n = strlen(ds) + strlen(prefix) + 1;
      char           *newdest = malloc(n * sizeof(*newdest));
      strcpy(newdest, prefix);
      strcat(newdest, ds);
      CMSetProperty(ciLocal, "destination", newdest, CMPI_chars);
      free(newdest);
    }
  }

  CMPIData        persistence =
      CMGetProperty(ciLocal, "persistencetype", &st);
  if (persistence.state == CMPI_nullValue
      || persistence.state == CMPI_notFound) {
    persistenceType = 2;        /* default is 2 = permanent */
  } else if (persistence.value.uint16 < 1 || persistence.value.uint16 > 3) {
    setStatus(&st, CMPI_RC_ERR_FAILED,
              "PersistenceType property must be 1, 2, or 3");
    CMRelease(ciLocal);
    _SFCB_RETURN(st);
  } else {
    persistenceType = persistence.value.uint16;
  }
  CMSetProperty(ciLocal, "persistencetype", &persistenceType, CMPI_uint16);

  if (CMClassPathIsA(_broker, copLocal, "cim_listenerdestination", NULL)) {

    //get the creation timestamp
    struct timeval  tv;
    struct timezone tz;
    char   context[100];
    gettimeofday(&tv, &tz);
    struct tm cttm;
    char * gtime = malloc(15 * sizeof(*gtime));
    memset(gtime, 0, 15 * sizeof(char));
    if (gmtime_r(&tv.tv_sec, &cttm) != NULL) {
      strftime(gtime, 15, "%Y%m%d%H%M%S", &cttm);
    }

    // Even though reliable indications may be disabled, we need to do this 
    // in case it ever gets enabled.
    // Get the IndicationService name
    CMPIObjectPath * isop = CMNewObjectPath(_broker, "root/interop", "CIM_IndicationService", NULL);
    CMPIEnumeration * isenm = _broker->bft->enumerateInstances(_broker, ctx, isop, NULL, NULL);
    CMPIData isinst = CMGetNext(isenm, NULL);
    CMPIData mc = CMGetProperty(isinst.value.inst, "Name", NULL);

    // build the context string
    sprintf (context,"%s#%s#",mc.value.string->ft->getCharPtr(mc.value.string,NULL),gtime);
    CMPIValue scontext;
    scontext.string = sfcb_native_new_CMPIString(context, NULL, 0);
    free(gtime);

    // set the properties
    CMSetProperty(ciLocal, "SequenceContext", &scontext, CMPI_string);
    CMPIValue zarro = {.sint64 = -1 };
    CMSetProperty(ciLocal, "LastSequenceNumber", &zarro, CMPI_sint64);
  }

  _SFCB_TRACE_VAR(CMPIString *str = CDToString(_broker, copLocal, NULL));
  _SFCB_TRACE_VAR(CMPIString *ns = CMGetNameSpace(copLocal, NULL));
  _SFCB_TRACE(1,("--- handler %s %s", (char *) ns->hdl, (char *) str->hdl));

  in = CMNewArgs(_broker, NULL);
  CMAddArg(in, "handler", &ciLocal, CMPI_instance);
  CMAddArg(in, "key", &copLocal, CMPI_ref);
  op = CMNewObjectPath(_broker, "root/interop",
                       "cim_indicationsubscription", &st);
  CBInvokeMethod(_broker, ctx, op, "_addHandler", in, out, &st);

  if (st.rc == CMPI_RC_OK) {
    st = InternalProviderCreateInstance(NULL, ctx, rslt, copLocal, ciLocal);
  }
  else {
    CBInvokeMethod(_broker,ctx,op,"_removeHandler",in,out,NULL);
  }

  _SFCB_RETURN(st);
}

/*
 * ModifyInstance only for ListenerDestination.Destination
 */
CMPIStatus
IndCIMXMLHandlerModifyInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci,
                               const char **properties)
{
  CMPIStatus st = { CMPI_RC_OK, NULL };
  CMPIString *cn = CMGetClassName(cop, NULL);
  const char *cns = cn->ft->getCharPtr(cn,NULL);
  CMPIArgs *in;
        
  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerModifyInstance");   
   
  if(isa("root/interop", cns, "cim_listenerdestination")) {
    _SFCB_TRACE(1,("--- modify %s", cns));
                
    CMPIData newDest = CMGetProperty(ci, "Destination", &st);
    fprintf(stderr, "new dest is %s\n", CMGetCharPtr(newDest.value.string));

    if(newDest.state != CMPI_goodValue) {
      st.rc = CMPI_RC_ERR_FAILED;
      return st;        
    }
          
    in=CMNewArgs(_broker,NULL);
    CMAddArg(in,"handler",&ci,CMPI_instance);
    CMAddArg(in,"key",&cop,CMPI_ref);
    /* cn needs to be IndicationSub to route the IM call to interopProv */
    CMPIObjectPath* sop=CMNewObjectPath(_broker,"root/interop","cim_indicationsubscription",&st);
    CBInvokeMethod(_broker,ctx,sop,"_updateHandler",in,NULL,&st);

    if (st.rc==CMPI_RC_OK) {
      st=InternalProviderModifyInstance(NULL,ctx,rslt,cop,ci,properties);
    }
    else {
      CBInvokeMethod(_broker,ctx,sop,"_removeHandler",in,NULL,NULL);
    }

  }

  _SFCB_RETURN(st);
}
static CMPIStatus
enumInstances(CMPIInstanceMI * mi,
              const CMPIContext *ctx, void *rslt,
              const CMPIObjectPath * ref,
              const char **properties,
              void (*retFnc) (void *, CMPIInstance *), int ignprov)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIStatus      sti = { CMPI_RC_OK, NULL };
  BlobIndex      *bi;
  CMPIString     *cn = CMGetClassName(ref, NULL);
  CMPIString     *ns = CMGetNameSpace(ref, NULL);
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);
  int             len,
                  i,
                  ac = 0;
  CMPIInstance   *ci;
  CMPIArgs       *in,
                 *out;
  CMPIObjectPath *op;
  CMPIArray      *ar;
  CMPIData        rv;
  const char    **keyList;

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "enumInstances");
  _SFCB_TRACE(1, ("--- %s %s", nss, cns));

  in = CMNewArgs(Broker, NULL);
  out = CMNewArgs(Broker, NULL);
  if (ignprov)
    CMAddArg(in, "classignoreprov", cns, CMPI_chars);
  else
    CMAddArg(in, "class", cns, CMPI_chars);

  op = CMNewObjectPath(Broker, bnss, "$ClassProvider$", &sti);
  _SFCB_TRACE(1, ("--- getallchildren"));
  rv = CBInvokeMethod(Broker, ctx, op, "getallchildren", in, out, &sti);
  _SFCB_TRACE(1, ("--- getallchildren rc: %d", sti.rc));

  ar = CMGetArg(out, "children", NULL).value.array;
  if (ar)
    ac = CMGetArrayCount(ar, NULL);
  _SFCB_TRACE(1, ("--- getallchildren ar: %p count: %d", ar, ac));

  for (i = 0; cns; i++) {
    _SFCB_TRACE(1, ("--- looking for %s", cns));
    if ((bi = _getIndex(bnss, cns)) != NULL) {
      for (ci = ipGetFirst(bi, &len, NULL, 0); ci;
           ci = ipGetNext(bi, &len, NULL, 0)) {
        if (properties) {
          keyList = getKeyList(ci->ft->getObjectPath(ci, NULL));
          ci->ft->setPropertyFilter(ci, properties, keyList);
          if (keyList) {
            free(keyList);
          }
        }
        _SFCB_TRACE(1, ("--- returning instance %p", ci));
        retFnc(rslt, ci);
      }
    }
    freeBlobIndex(&bi, 1);
    if (i < ac)
      cns = (char *) CMGetArrayElementAt(ar, i, NULL).value.string->hdl;
    else
      cns = NULL;
  }

  _SFCB_RETURN(st);
}
CMPIStatus
InternalProviderEnumInstanceNames(CMPIInstanceMI * mi,
                                  const CMPIContext *ctx,
                                  const CMPIResult *rslt,
                                  const CMPIObjectPath * ref)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIStatus      sti = { CMPI_RC_OK, NULL };
  BlobIndex      *bi;
  CMPIString     *cn = CMGetClassName(ref, NULL);
  CMPIString     *ns = CMGetNameSpace(ref, NULL);
  CMPIObjectPath *cop;
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);
  size_t          ekl;
  int             i,
                  ac = 0;
  char            copKey[8192] = "";
  char           *kp;
  CMPIArgs       *in,
                 *out;
  CMPIObjectPath *op;
  CMPIArray      *ar;
  CMPIData        rv;

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderEnumInstanceNames");
  _SFCB_TRACE(1, ("%s %s", nss, cns));

  in = CMNewArgs(Broker, NULL);
  out = CMNewArgs(Broker, NULL);
  CMAddArg(in, "class", cns, CMPI_chars);
  op = CMNewObjectPath(Broker, bnss, "$ClassProvider$", &sti);
  rv = CBInvokeMethod(Broker, ctx, op, "getallchildren", in, out, &sti);
  ar = CMGetArg(out, "children", NULL).value.array;
  if (ar)
    ac = CMGetArrayCount(ar, NULL);

  for (i = 0; cns; i++) {
    if ((bi = _getIndex(bnss, cns)) != NULL) {
      if (ipGetFirst(bi, NULL, &kp, &ekl)) {
        while (1) {
          strcpy(copKey, nss);
          strcat(copKey, ":");
          strcat(copKey, cns);
          strcat(copKey, ".");
          strncat(copKey, kp, ekl);

          cop = getObjectPath(copKey, NULL);
          if (cop)
            CMReturnObjectPath(rslt, cop);
          else {
            CMPIStatus      st = { CMPI_RC_ERR_FAILED, NULL };
            return st;
          }
          if (bi->next < bi->dSize && ipGetNext(bi, NULL, &kp, &ekl)) {
            continue;
          }
          break;
        }
      }
      freeBlobIndex(&bi, 1);
    }
    if (i < ac)
      cns = (char *) CMGetArrayElementAt(ar, i, NULL).value.string->hdl;
    else
      cns = NULL;
  }
  _SFCB_RETURN(st);
}
Example #28
0
CMPIStatus TestCMPIBrokerInstanceProviderCreateInstance (CMPIInstanceMI * mi,
    const CMPIContext * ctx,
    const CMPIResult * rslt,
    const CMPIObjectPath * cop,
    const CMPIInstance * ci)
{
    const CMPIString* retNamespace;
    const CMPIString* retClassname;
    CMPIString* type;
    const char* str1;
    const char* str2;
    CMPIStatus rc = { CMPI_RC_OK, NULL };
    CMPIData retData;
    CMPIObjectPath *obj;
    CMPIBoolean bol = 0;

    PROV_LOG_OPEN (_ClassName, _ProviderLocation);
    PROV_LOG("CreateInstance");

    retNamespace = CMGetNameSpace(cop, &rc);
    retClassname = CMGetClassName(cop, &rc);
    str1 = CMGetCharsPtr(retNamespace, &rc);
    str2 = CMGetCharsPtr(retClassname, &rc);
    PROV_LOG("++++Obtained Namespace : (%s) Class (%s)", str1, str2);

    if(ci)
    { 
        /* Test to increase coverage in Broker_Enc.cpp*/
        type = CDToString (_broker, ci, &rc);
        PROV_LOG ("++++ Passing CMPIInstance with CMPI_InstanceOnStack_Ftab "
            "to mbEncToString successes : "
            "(%s)",
            strCMPIStatus (rc));    

        type = CDGetType (_broker, ci, &rc);
        PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIInstance"
            " : (%s) type(%s)",
            strCMPIStatus (rc),
            CMGetCharsPtr(type, NULL));

        bol = CDIsOfType (_broker, ci, "CMPIInstance", &rc);
        if ( bol )
        {
            PROV_LOG ("++++ CDIsOfType for CMPIInstance with "
                "CMPI_InstanceOnStack_Ftab status is (%s) : %d",
                strCMPIStatus (rc),
                bol);
        }

        type = CDToString (_broker, cop, &rc);
        PROV_LOG ("++++ Passing CMPIObjectPath with "
            "CMPI_ObjectPathOnStack_Ftab to mbEncToString successes : (%s)",
            strCMPIStatus (rc));    

        type = CDGetType (_broker, cop, &rc);
        PROV_LOG ("++++ Status of mbEncGetType with input of type "
            "CMPIObjectPath : (%s) type(%s)",
            strCMPIStatus (rc),
            CMGetCharsPtr(type, NULL));

        bol = CDIsOfType (_broker, cop, "CMPIObjectPath", &rc);
        if ( bol )
        {
            PROV_LOG ("++++ CDIsOfType for CMPIObjectPath with "
                "CMPI_ObjectPathOnStack_Ftab status is (%s) : %d",
                strCMPIStatus (rc),
                bol);
        }

        type = CDGetType (_broker, rslt, &rc);
        PROV_LOG ("++++ Status of mbEncGetType with input of type "
            "CMPIResult with CMPI_ResultRefOnStack_Ftab : (%s) type(%s)",
            strCMPIStatus (rc),
            CMGetCharsPtr(type, NULL));

        bol = CDIsOfType (_broker, rslt, "CMPIResult", &rc);
        if ( bol )
        {
            PROV_LOG ("++++ CDIsOfType for CMPIResult with "
                "CMPI_ResultRefOnStack_Ftab status is (%s) : %d",
                strCMPIStatus (rc),
                bol);
        }

        _inst = CMClone(ci, &rc);
        PROV_LOG("++++ Status of CMClone(ci) : (%s)",
            strCMPIStatus(rc));
        CMSetObjectPath (_inst, cop);
        PROV_LOG("++++ Status of CMSetObjectPath(_inst) : (%s)",
            strCMPIStatus(rc));
        _setProperty1(_inst, "*");
        retData = CMGetProperty(_inst, "n64", &rc);
        PROV_LOG("++++ Status of CMGetProperty : (%s)",
            strCMPIStatus(rc));
        PROV_LOG("n64 = %" PEGASUS_64BIT_CONVERSION_WIDTH "u",
            retData.value.uint64);
        retData = CMGetProperty(_inst, "n32", &rc);
        PROV_LOG("++++ Status of CMGetProperty : (%s)",
            strCMPIStatus(rc));
        PROV_LOG("n32 = %d", retData.value.uint32);

        obj = CMGetObjectPath(_inst, &rc);
        PROV_LOG("++++ Status of CMGetObjectPath : (%s)",
            strCMPIStatus(rc));
        retNamespace = CMGetNameSpace(obj, &rc);
        PROV_LOG("++++ Status of CMGetNameSpace : (%s)",
            strCMPIStatus(rc));
        retClassname = CMGetClassName(obj, &rc);
        PROV_LOG("++++ Status of CMGetClassName : (%s)",
            strCMPIStatus(rc));
        str1 = CMGetCharsPtr(retNamespace, &rc);
        PROV_LOG("++++ Status of CMGetCharsPtr : (%s)",
            strCMPIStatus(rc));
        str2 = CMGetCharsPtr(retClassname, &rc);
        PROV_LOG("++++ Status of CMGetCharsPtr : (%s)",
            strCMPIStatus(rc));
        PROV_LOG("++++Namespace (_inst): (%s) Class (*%s)", str1, str2);
        retData = CMGetProperty(_inst, "n64", &rc);
        PROV_LOG("++++ Status of CMGetProperty : (%s)",
            strCMPIStatus(rc));
        PROV_LOG("n64 = %" PEGASUS_64BIT_CONVERSION_WIDTH "u",
            retData.value.uint64);
        PROV_LOG_CLOSE ();

        CMReturnObjectPath(rslt, cop);
        CMReturnDone(rslt);
        CMReturn (CMPI_RC_OK);
    }
    else
    {
        PROV_LOG_CLOSE ();
        CMReturn (CMPI_RC_ERR_NOT_SUPPORTED);
    }
}
Example #29
0
CMPIStatus TestCMPIBrokerInstanceProviderGetInstance (CMPIInstanceMI * mi,
    const CMPIContext * ctx,
    const CMPIResult * rslt,
    const CMPIObjectPath * cop,
    const char **properties)
{
    CMPIStatus rc = {CMPI_RC_OK, NULL};
    CMPIString* retNamespace;
    CMPIString* retClassname;
    CMPIString* type;
    CMPIData retData;
    CMPIObjectPath* obj;
    CMPIBoolean bol = 0;
    const char* str1;
    const char* str2;

    PROV_LOG_OPEN (_ClassName, _ProviderLocation);
    PROV_LOG("GetInstance");
    PROV_LOG("++++Namespace ");

    obj = CMGetObjectPath(_inst, &rc);
    PROV_LOG("++++ Status of CMGetObjectPath : (%s)",
        strCMPIStatus(rc));
    retNamespace = CMGetNameSpace(obj, &rc);
    PROV_LOG("++++ Status of CMGetNameSpace : (%s)",
        strCMPIStatus(rc));
    retClassname = CMGetClassName(obj, &rc);
    PROV_LOG("++++ Status of CMGetClassName : (%s)",
        strCMPIStatus(rc));
    str1 = CMGetCharsPtr(retNamespace, &rc);
    PROV_LOG("++++ Status of CMGetCharsPtr : (%s)",
        strCMPIStatus(rc));
    str2 = CMGetCharsPtr(retClassname, &rc);
    PROV_LOG("++++ Status of CMGetCharsPtr : (%s)",
        strCMPIStatus(rc));
    retData = CMGetProperty(_inst, "n64", &rc);
    PROV_LOG("++++ Status of CMGetProperty : (%s)",
        strCMPIStatus(rc));
    PROV_LOG("n64 = %" PEGASUS_64BIT_CONVERSION_WIDTH "u",
        retData.value.uint64);
   
    /* Test cases for increasing coverage in CMPI_BrokerEnc.cpp*/
    type = CDGetType (_broker, rslt, &rc);
    PROV_LOG ("++++ Status of mbEncGetType with input of type "
        "CMPIResult with CMPI_ResultInstOnStack_Ftab : (%s) type(%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    bol = CDIsOfType (_broker, rslt, "CMPIResult", &rc);
    if ( bol )
    {
        PROV_LOG ("++++ CDIsOfType for CMPIResult with "
            "CMPI_ResultInstOnStack_Ftab status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }
    PROV_LOG_CLOSE();

    if (_inst)
    {
        CMReturnInstance(rslt, _inst);
        CMReturnDone(rslt);
        CMReturn (CMPI_RC_OK);
    }
    else
    {
        CMReturn (CMPI_RC_ERR_NOT_SUPPORTED);
    }
}
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;
}