Beispiel #1
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);
}
CMPIObjectPath *
get_assoc_targetClass_ObjectPath(const CMPIBroker * broker,
                                 const CMPIObjectPath * ref,
                                 const char *_RefLeftClass,
                                 const char *_RefRightClass,
                                 CMPIStatus *rc)
{
  CMPIObjectPath *op = NULL;
  const char     *targetName = NULL;

  /*
   * get name of the target class 
   */
  targetName = get_assoc_targetClass_Name(broker,
                                          ref,
                                          _RefLeftClass,
                                          _RefRightClass, rc);

  if (targetName != NULL) {
    /*
     * create new object path of the target class 
     */
    op = CMNewObjectPath(broker,
                         CMGetCharsPtr(CMGetNameSpace(ref, rc), NULL),
                         targetName, rc);
  }
  return op;
}
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; 
}
CMPIStatus Linux_FanAssociatedSensorProviderAssociators(
        CMPIAssociationMI * mi,
        const CMPIContext * ctx,
        const CMPIResult * rslt,
        const CMPIObjectPath * cop,
        const char * assocClass,
        const char * resultClass,
        const char * role,
        const char * resultRole,
        const char ** propertyList)
{
    UNUSED(mi); UNUSED(propertyList);
  CMPIStatus       rc    = {CMPI_RC_OK, NULL};
  CMPIObjectPath * op    = NULL;
  int              refrc = 0;

  _OSBASE_TRACE(1,("--- %s CMPI Associators() called",_ClassName));

  if( assocClass ) {
    op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(cop,&rc)),
			  _ClassName, &rc );
    if( op==NULL ) {
      CMSetStatusWithChars( _broker, &rc,
            CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." );
      _OSBASE_TRACE(2,
              ("--- %s CMPI Associators() failed : %s",CMGetCharPtr(rc.msg)));
      return rc;
    }
  }

  if (  (assocClass == NULL)
     || (CMClassPathIsA(_broker,op,assocClass,&rc) == 1))
  {
  
    if( _assoc_check_parameter_const( _broker,cop,_RefLeft,_RefRight,
				      _RefLeftClass,_RefRightClass,
				      resultClass,role,resultRole, 
				      &rc ) == 0 ) { goto exit; }

    refrc = _assoc_create_refs_1toN(_broker, ctx, rslt, cop, 
				    _ClassName,_RefLeftClass,_RefRightClass,
				    _RefLeft,_RefRight,
				    1, 1, &rc);
    if( refrc != 0 ) {
      if( rc.msg != NULL ) {
	_OSBASE_TRACE(1, ("--- %s CMPI Associators() failed : %s",
                    _ClassName,CMGetCharPtr(rc.msg)));
      }
      else {
	_OSBASE_TRACE(1,("--- %s CMPI Associators() failed",_ClassName));
      }
      return rc;
    }
  }
  
 exit:
  CMReturnDone( rslt );
  _OSBASE_TRACE(1,("--- %s CMPI Associators() exited",_ClassName));  
  CMReturn(CMPI_RC_OK);
}
CMPIObjectPath *
get_assoc_targetClass_ObjectPath(const CMPIBroker * broker,
                                 const CMPIObjectPath * ref,
                                 const char *_RefLeftClass,
                                 const char *_RefRightClass,
                                 CMPIStatus *rc)
{
  CMPIObjectPath *op = NULL;
  const char     *targetName = NULL;

  /*
   * get name of the target class 
   */
  targetName = get_assoc_targetClass_Name(broker,
                                          ref,
                                          _RefLeftClass,
                                          _RefRightClass, rc);

  if (targetName != NULL) {
    /*
     * create new object path of the target class 
     */
    op = CMNewObjectPath(broker,
                         CMGetCharsPtr(CMGetNameSpace(ref, rc), NULL),
                         targetName, rc);

    if (!op)
      CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
          "Create CMPIObjectPath failed in cmpiTestAssociationProvider");
  }
  return op;
}
int
dqRetry(CMPIContext * ctx, RTElement * cur)
{
  _SFCB_ENTER(TRACE_INDPROVIDER, "dqRetry");
  // Delete the instance in the repo
  CMPIObjectPath * op=CMNewObjectPath(_broker,"root/interop","SFCB_IndicationElement",NULL);
  CMAddKey(op,"IndicationID",&cur->instanceID,CMPI_uint32);
  CBDeleteInstance(_broker,ctx,op);
  CBDeleteInstance(_broker,ctx,cur->ind);
  CMRelease(op);

  // Remove the entry from the queue, closing the hole
  if (cur->next == cur) {
    // queue is empty
    free(cur);
    RQhead = NULL;
  } else {
    // not last
    cur->prev->next = cur->next;
    cur->next->prev = cur->prev;
    CMRelease(cur->ref);
    CMRelease(cur->sub);
    if (cur)
      free(cur);
  }
  _SFCB_RETURN(0);
}
Beispiel #7
0
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;
}
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
IndCIMXMLHandlerDeleteInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIArgs       *in,
                 *out = NULL;
  CMPIObjectPath *op;
  CMPIData        rv;

  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerDeleteInstance");

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

  internalProviderGetInstance(cop, &st);
  if (st.rc)
    _SFCB_RETURN(st);

  in = CMNewArgs(_broker, NULL);
  CMAddArg(in, "key", &cop, CMPI_ref);
  op = CMNewObjectPath(_broker, "root/interop",
                       "cim_indicationsubscription", &st);
  rv = CBInvokeMethod(_broker, ctx, op, "_removeHandler", in, out, &st);

  if (st.rc == CMPI_RC_OK) {
    st = InternalProviderDeleteInstance(NULL, ctx, rslt, cop);
  }

  _SFCB_RETURN(st);
}
static void
generateIndication2(const char *methodname, const CMPIContext *ctx)
{

  CMPIInstance   *inst;
  CMPIObjectPath *cop;
  CMPIDateTime   *dat;
  CMPIArray      *ar;
  CMPIStatus      rc;
  char            buffer[32];

  if (enabled && activated2) {
    cop = CMNewObjectPath(broker, "root/interop2", "Test_Indication", &rc);
    inst = CMNewInstance(broker, cop, &rc);

    sprintf(buffer, "%d", _nextUID++);
    CMSetProperty(inst, "IndicationIdentifier", buffer, CMPI_chars);

    dat = CMNewDateTime(broker, &rc);
    CMSetProperty(inst, "IndicationTime", &dat, CMPI_dateTime);

    CMSetProperty(inst, "MethodName", methodname, CMPI_chars);

    ar = CMNewArray(broker, 0, CMPI_string, &rc);
    CMSetProperty(inst, "CorrelatedIndications", &ar, CMPI_stringA);

    rc = CBDeliverIndication(broker, ctx, "root/interop", inst);
    if (rc.rc != CMPI_RC_OK) {
      fprintf(stderr, "+++ Could not send the indication!\n");
    }
    gen2++;
  }
  fprintf(stderr, "+++ generateIndication2() done %d\n", gen2);
}
CMPIStatus TestCMPIAssociationProviderAssociatorNames(
    CMPIAssociationMI* mi,
    const CMPIContext* ctx,
    const CMPIResult* rslt,
    const CMPIObjectPath* ref,
    const char* _RefLeftClass,
    const char* _RefRightClass,
    const char* role,
    const char* resultRole)
{
    CMPIObjectPath* op = NULL;
    CMPIObjectPath* rop = NULL;
    CMPIEnumeration* en = NULL;
    CMPIData data ;

    CMPIStatus rc = { CMPI_RC_OK, NULL };

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

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

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

    /* create new object path of association */
    rop = CMNewObjectPath(
        _broker,
        CMGetCharsPtr(CMGetNameSpace(ref,&rc),NULL),
        _ClassName,
        &rc );

    /* upcall to CIMOM; call enumInstanceNames() of the target class */
    en = CBEnumInstanceNames( _broker, ctx, op, &rc);

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

        /* and return the target class object path as result of the
         * associatorNames() call
        */
        CMReturnObjectPath( rslt, data.value.ref );
    }
    PROV_LOG ("\n\n********************* %s CMPI AssociatorNames() exited",
        _ClassName);
    PROV_LOG_CLOSE ();
    return 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;
}
CMPIObjectPath *
make_ObjectPath(const CMPIBroker * broker,
                const char *ns, const char *className)
{
  CMPIObjectPath *objPath = NULL;
  CMPIStatus      rc = { CMPI_RC_OK, NULL };
  objPath = CMNewObjectPath(broker, ns, className, &rc);
  CMAddKey(objPath, "ElementName", (CMPIValue *) className, CMPI_chars);
  return objPath;
}
int
enqRetry(RTElement * element, const CMPIContext * ctx, int repo)
{

  _SFCB_ENTER(TRACE_INDPROVIDER, "enqRetry");
  // Put this one on the retry queue
  if (pthread_mutex_lock(&RQlock) != 0) {
    // lock failed
    return 1;
  }
  if (RQhead == NULL) {
    // Queue is empty
    _SFCB_TRACE(1,("--- Adding indication to new retry queue."));
    RQhead = element;
    RQtail = element;
    RQtail->next = element;
    RQtail->prev = element;
  } else {
    _SFCB_TRACE(1,("--- Adding indication to retry queue."));
    element->next = RQtail->next;
    element->next->prev = element;
    RQtail->next = element;
    element->prev = RQtail;
    RQtail = element;
  }
  if (repo==1) {
    // If this needs to be persisted in the repo 
    // (not the initial fill from refillRetryQ)
    _SFCB_TRACE(1,("--- Creating SFCB_IndicationElement instance."));
    CMPIObjectPath * op=CMNewObjectPath(_broker,"root/interop","SFCB_IndicationElement",NULL);
    // Add the indID as the only key
    CMAddKey(op,"IndicationID",&element->instanceID,CMPI_uint32);
    // Create the instance
    //element->SFCBIndEle=op;
    element->SFCBIndEle=op->ft->clone(op,NULL);
    CMPIInstance * ci=CMNewInstance(_broker,op,NULL);
    // Set all the properties
    CMSetProperty(ci,"IndicationID",&element->instanceID,CMPI_uint32);
    CMSetProperty(ci,"RetryCount",&(RQtail->count),CMPI_uint32);
    CMSetProperty(ci,"LastDelivery",&(RQtail->lasttry),CMPI_sint32);
    CMSetProperty(ci,"ld",&(element->ref),CMPI_ref);
    CMSetProperty(ci,"ind",&element->ind,CMPI_ref);
    CMSetProperty(ci,"sub",&element->sub,CMPI_ref);
    CBCreateInstance(_broker, ctx, op, ci, NULL);
    CMRelease(op);
    CMRelease(ci);
  }

  if (pthread_mutex_unlock(&RQlock) != 0) {
    // lock failed
    return 1;
  }
  _SFCB_RETURN(0);
}
Beispiel #15
0
static void loopOnChildNames(ClassRegister *cReg, char *cn, CMPIResult * rslt)
{
   CMPIObjectPath *op;
   UtilList *ul = getChildren(cReg,cn);
   char *child;
   if (ul) for (child = (char *) ul->ft->getFirst(ul); child;  child = (char *) ul->ft->getNext(ul)) {
      op=CMNewObjectPath(_broker,NULL,child,NULL);
      CMReturnObjectPath(rslt,op);
      loopOnChildNames(cReg,child,rslt);
   }
}
Beispiel #16
0
CMPIObjectPath* KBase_ToObjectPath(
    const KBase* self, 
    CMPIStatus* st)
{
    KPos pos;
    CMPIObjectPath* cop;

    /* Check parameters */

    if (self->magic != KMAGIC)
    {
        KSetStatus(st, ERR_FAILED);
        return NULL;
    }

    /* Create object path */

    KFirst(&pos, self);

    if (!(cop = CMNewObjectPath(self->cb, KChars(self->ns), pos.classname, 
        st)))
    {
        return NULL;
    }

    /* Set keys */

    while (KMore(&pos))
    {
        CMPIData cd;
        const KValue* value = (const KValue*)pos.field;

        if (value->exists && (pos.tag & KTAG_KEY))
        {
            CMPIStatus st;

            cd = _data(value, pos.tag);

            if (value->null)
                st = CMAddKey(cop, pos.name, NULL, cd.type);
            else
                st = CMAddKey(cop, pos.name, &cd.value, cd.type);

            if (!KOkay(st))
            {
                /* ATTN: log this but do not return! */
            }
        }

        KNext(&pos);
    }

    return cop;
}
void
ElementCapabilitiesInitInstances(const CMPIContext *ctx)
{
  CMPIObjectPath *op = NULL,
      *opLeft = NULL,
      *opRight = NULL,
      *left = NULL,
      *right = NULL;
  CMPIValue       val;
  CMPIEnumeration *enm = NULL;
  CMPIInstance   *ci = NULL;
  CMPIContext    *ctxLocal;

  ctxLocal = native_clone_CMPIContext(ctx);
  val.string = sfcb_native_new_CMPIString("$DefaultProvider$", NULL, 0);
  ctxLocal->ft->addEntry(ctxLocal, "rerouteToProvider", &val, CMPI_string);

  op = CMNewObjectPath(_broker, "root/interop", "SFCB_ElementCapabilities",
                       NULL);
  ci = CMNewInstance(_broker, op, NULL);

  opLeft =
      CMNewObjectPath(_broker, "root/interop", "CIM_IndicationService",
                      NULL);
  enm = CBEnumInstanceNames(_broker, ctx, opLeft, NULL);
  left = CMGetNext(enm, NULL).value.ref;
  opRight =
      CMNewObjectPath(_broker, "root/interop",
                      "SFCB_IndicationServiceCapabilities", NULL);
  enm = CBEnumInstanceNames(_broker, ctx, opRight, NULL);
  right = CMGetNext(enm, NULL).value.ref;

  CMAddKey(op, "ManagedElement", &left, CMPI_ref);
  CMAddKey(op, "Capabilities", &right, CMPI_ref);
  CMSetProperty(ci, "ManagedElement", &left, CMPI_ref);
  CMSetProperty(ci, "Capabilities", &right, CMPI_ref);
  CBCreateInstance(_broker, ctxLocal, op, ci, NULL);
  CMRelease(ctxLocal);
  return;
}
Beispiel #18
0
CMPIObjectPath *
make_ObjectPath (const CMPIBroker *broker, const char *ns, const char *clss)
{
  CMPIObjectPath *objPath = NULL;
  CMPIStatus rc = { CMPI_RC_OK, NULL };

  PROV_LOG ("--- make_ObjectPath: CMNewObjectPath");
  objPath = CMNewObjectPath (broker, ns, clss, &rc);

  PROV_LOG ("----- %s", strCMPIStatus (rc));

  return objPath;
}
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;
}
int refillRetryQ (const CMPIContext * ctx)
{
  _SFCB_ENTER(TRACE_INDPROVIDER, "refillRetryQ");  
  int qfill=0;
  if (RQhead==NULL) {
    // The queue is empty, check if there are instances to be restored
    CMPIObjectPath * op=CMNewObjectPath(_broker,"root/interop","SFCB_IndicationElement",NULL);
    CMPIEnumeration * enm = _broker->bft->enumerateInstances(_broker, ctx, op, NULL, NULL);
    while(enm && enm->ft->hasNext(enm, NULL)) {
    // get the properties from the repo instance
      CMPIData inst=CMGetNext(enm,NULL);
      CMPIData indID=CMGetProperty(inst.value.inst,"indicationID",NULL);
      CMPIData rcount=CMGetProperty(inst.value.inst,"retryCount",NULL);
      CMPIData last=CMGetProperty(inst.value.inst,"lastDelivery",NULL);
      CMPIData ind=CMGetProperty(inst.value.inst,"ind",NULL);
      CMPIData sub=CMGetProperty(inst.value.inst,"sub",NULL);
      CMPIData ld=CMGetProperty(inst.value.inst,"ld",NULL);
      _SFCB_TRACE(1,("--- Requeueing indication id:%d",indID.value.Int));
      // Rebuild the queue element
      RTElement *element;
      element = (RTElement *) malloc(sizeof(*element));
      element->instanceID=indID.value.Int;
      element->lasttry=last.value.Int;
      element->count=rcount.value.Int;
      element->ind=ind.value.ref->ft->clone(ind.value.ref,NULL);
      element->ref=ld.value.ref->ft->clone(ld.value.ref,NULL);
      element->sub=sub.value.ref->ft->clone(sub.value.ref,NULL);
      CMPIObjectPath * indele=CMGetObjectPath(inst.value.inst,NULL);
      element->SFCBIndEle=indele->ft->clone(indele,NULL);
      // call enq
      enqRetry(element,ctx,0);
      qfill=1;
    }
    // spawn thread if we queued anything
    if ((qfill == 1 ) && (retryRunning == 0)) {
      retryRunning=1;
      _SFCB_TRACE(1,("--- Starting retryExport thread"));
      pthread_attr_init(&tattr);
      pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
      CMPIContext * pctx = native_clone_CMPIContext(ctx);
      pthread_create(&t, &tattr,&retryExport,(void *) pctx);
    }
  }

  _SFCB_RETURN(0); 
}
Beispiel #21
0
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;
}
CMPIObjectPath * _makePath_TestClassA(
    const CMPIBroker * _broker,
    const CMPIContext * ctx,
    const CMPIObjectPath * cop)
{
   CMPIObjectPath * op = NULL;
   CMPIValue theKey;
   theKey.uint32 = 2;

   op=CMNewObjectPath(
       _broker,
       CMGetCharsPtr(CMGetNameSpace(cop,NULL), NULL),
       _ClassName,
       NULL);

   CMAddKey(op, "theKey", &theKey, CMPI_uint32);
   return op;
}
Beispiel #23
0
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;
}
Beispiel #24
0
CMPIObjectPath *kvp_rasd_create_ref(
    const CMPIBroker *broker,
    const char *name_space,
    xen_utils_session *session,
    xen_vm_record *vm_rec,
    kvp *kvp_rec
)
{
    char inst_id[MAX_INSTANCEID_LEN];
    CMPIObjectPath *result_setting = NULL;

    result_setting = CMNewObjectPath(broker, name_space, "Xen_KVPSettingData", NULL);
    if (result_setting) {
        _CMPICreateNewDeviceInstanceID(inst_id, MAX_INSTANCEID_LEN, kvp_rec->vm_uuid, kvp_rec->key);
        CMAddKey(result_setting, "InstanceID", (CMPIValue *)inst_id, CMPI_chars);
    }
    return result_setting;

}
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;             
}
// To increase the coverage in CMPIBrokerEnc.cpp
static int _testBrokerEnc (const CMPIContext * ctx,
    const CMPIResult * rslt)
{
    int flag = 1 ;
    int count;
    char* msgId;
    char* illegal;
    char path[100];
    void* hdl;
    CMPIStatus rc = { CMPI_RC_OK, NULL };
    CMPIString *type;
    CMPIString *cmpiStr;
    CMPIBoolean bol=0;
    CMPIBoolean bool=0;
    CMPIArray* cmpiArray = NULL ;
    CMPIInstance* instance = NULL;
    CMPIInstance* instance1 = NULL;
    CMPIInstance* instanceErr = NULL;
    CMPIObjectPath* objPath = NULL;
    CMPIObjectPath* objPath1 = NULL;
    CMPICount cmpiCnt = 5;
    CMPIType cmpiType = CMPI_uint64;
    CMPIDateTime* cmpiDateTime = NULL ;
    CMPIMsgFileHandle msgFileHandle;
    CMPIEnumeration* cmpiEnum;
    CMPISelectExp* selExp;
    CMPIValue val;
    CMPIError* err;
    CMPIStatus* rc1 = NULL;
    CMPIArgs* args = NULL;
    void* handle;
    CMPIInstanceFT* funcTable;

    PROV_LOG ("++++ _testBrokerEnc ");

    PROV_LOG ("++++ ObjectPath testing");

    objPath1 = CMNewObjectPath (_broker, NULL, _ClassName, &rc);
    PROV_LOG ("++++ New object path with NULL namespace creation : (%s)",
        strCMPIStatus (rc));
    CMRelease(objPath1);

    objPath1 = CMNewObjectPath (_broker, _Namespace, "abc", &rc);
    PROV_LOG ("++++ New object path with wrong classname : (%s)",
        strCMPIStatus (rc));

    instance = CMNewInstance(_broker, NULL, &rc);
    PROV_LOG ("++++ New Instance with NULL object path : (%s)",
        strCMPIStatus (rc));

    handle = objPath1->hdl;
    objPath1->hdl=NULL;
    instance = CMNewInstance(_broker, objPath1, &rc);
    PROV_LOG ("++++ New Instance with object path handle set to NULL: (%s)",
        strCMPIStatus (rc));
    objPath1->hdl = handle;

    objPath = make_ObjectPath(_broker, _Namespace, _ClassName);
    instance = CMNewInstance(_broker, objPath, &rc);
    PROV_LOG ("++++ New Instance creation status: (%s)",
        strCMPIStatus (rc));
    instance1 = CMClone(instance, &rc);
    instanceErr = CMClone(instance, &rc);

    cmpiStr = CMNewString(_broker, NULL, &rc);
    PROV_LOG ("++++ Status of mbNewString with NULL parameter:(%s)",
        strCMPIStatus (rc));

    err = CMNewCMPIError(_broker, "abc", "abc", "abc", 4, 5, 6, rc1);
    if (err)
    {
        PROV_LOG ("++++ CMNewCMPIError called with null rc");
    }
    cmpiDateTime = CMNewDateTimeFromChars(_broker, "datetime", &rc);
    PROV_LOG ("++++ Status of CMNewDateTimeFromChars with junk parameter:(%s)",
        strCMPIStatus (rc));

    if (!CMClassPathIsA(_broker, NULL, NULL, &rc))
    {
        PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)",
            strCMPIStatus (rc));
    }

    if (!CMClassPathIsA(_broker, objPath, NULL, &rc))
    {
        PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)",
            strCMPIStatus (rc));
    }
    illegal = "$";
    if (!CMClassPathIsA(_broker, objPath, illegal, &rc))
    {
        PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)",
            strCMPIStatus (rc));
    }


    rc = CMLogMessage(_broker,
        2,
        "TestProvider",
        "Testing Severity 2 in TestCMPIBrokerEnc",
        NULL);
    PROV_LOG ("++++ Status of CMLogMessage with Severity 2:(%s)",
        strCMPIStatus (rc));

    rc = CMLogMessage(_broker,
        3,
        "TestProvider",
        "Testing Severity 3 in TestCMPIBrokerEnc",
        NULL);
    PROV_LOG ("++++ Status of CMLogMessage with Severity 3:(%s)",
        strCMPIStatus (rc));

    rc = CMLogMessage(_broker,
        4,
        "TestProvider",
        "Testing Severity 4 in TestCMPIBrokerEnc",
        NULL);
    PROV_LOG ("++++ Status of CMLogMessage with Severity 4:(%s)",
        strCMPIStatus (rc));

    rc = CMTraceMessage(_broker,
        2,
        "CMPIProvider",
        "Tracing for level 2",
        NULL);
    PROV_LOG ("++++ Status of CMTraceMessage with level 2:(%s)",
        strCMPIStatus (rc));

    rc = CMTraceMessage(_broker,
        3,
        "CMPIProvider",
        "Tracing for level 3",
        NULL);
    PROV_LOG ("++++ Status of CMTraceMessage with level 3:(%s)",
        strCMPIStatus (rc));

    rc = CMTraceMessage(_broker,
        4,
        "CMPIProvider",
        "Tracing for level 4",
        NULL);
    PROV_LOG ("++++ Status of CMTraceMessage with level 4:(%s)",
        strCMPIStatus (rc));

    cmpiStr = CMNewString(_broker, "Tracing for level 5", &rc);
    rc = CMTraceMessage(_broker,
        5,
        "CMPIProvider",
        NULL,
        cmpiStr);
    PROV_LOG ("++++ Status of CMTraceMessage with level 5:(%s)",
        strCMPIStatus (rc));
    CMRelease(cmpiStr);

    PROV_LOG ("++++ Calling mbEncToString function ");

    type = CDToString (_broker, _broker, &rc);
    PROV_LOG ("++++ Error status of mbEncToString with wrong object path:"
        " (%s)",
        strCMPIStatus (rc));

    type = CDToString (_broker, NULL, &rc);
    PROV_LOG ("++++ Error status of mbEncToString with NULL parameter:"
        " (%s)",
        strCMPIStatus (rc));

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

    type = CDToString (_broker, objPath, &rc);
    PROV_LOG ("++++ Passing CMPIObjectPath to mbEncToString successes : (%s)",
        strCMPIStatus (rc));
    handle = objPath1->hdl;
    objPath1->hdl = NULL;
    type = CDToString (_broker, objPath1, &rc);
    if ( rc.rc == CMPI_RC_ERR_INVALID_PARAMETER)
    {
        PROV_LOG ("++++ Error status of mbEncToString with object path with "
            "NULL handle: (%s)",
            strCMPIStatus (rc));
    }
    objPath1->hdl = handle;

    val.boolean = 1;
    rc = CMSetProperty (instance, "Boolean", &val, CMPI_boolean);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_boolean : (%s)",
        strCMPIStatus (rc));

    val.uint8 = 8;
    rc = CMSetProperty (instance, "Uint8", &val, CMPI_uint8);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint8 : (%s)",
        strCMPIStatus (rc));

    val.uint16 = 16;
    rc = CMSetProperty (instance, "Uint16", &val, CMPI_uint16);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint16 : (%s)",
        strCMPIStatus (rc));

    val.uint32 = 32;
    rc = CMSetProperty (instance, "Uint32", &val, CMPI_uint32);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint32 : (%s)",
        strCMPIStatus (rc));

    val.uint64 = 64;
    rc = CMSetProperty (instance, "Uint64", &val, CMPI_uint64);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint64 : (%s)",
        strCMPIStatus (rc));

    val.sint8 = -8;
    rc = CMSetProperty (instance, "Sint8", &val, CMPI_sint8);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint8 : (%s)",
        strCMPIStatus (rc));

    val.sint16 = -16;
    rc = CMSetProperty (instance, "Sint16", &val, CMPI_sint16);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint16 : (%s)",
        strCMPIStatus (rc));

    val.sint32 = -32;
    rc = CMSetProperty (instance, "Sint32", &val, CMPI_sint32);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint32 : (%s)",
        strCMPIStatus (rc));

    val.sint64 = -64;
    rc = CMSetProperty (instance, "Sint64", &val, CMPI_sint64);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint64 : (%s)",
        strCMPIStatus (rc));

    val.real32 = 32.32;
    rc = CMSetProperty (instance, "Real32", &val, CMPI_real32);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_real32 : (%s)",
        strCMPIStatus (rc));

    val.real64 = 64.64;
    rc = CMSetProperty (instance, "Real64", &val, CMPI_real64);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_real64 : (%s)",
        strCMPIStatus (rc));

    val.char16 = 'c';
    rc = CMSetProperty (instance, "Char16", &val, CMPI_char16);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_char16 : (%s)",
        strCMPIStatus (rc));

    cmpiDateTime = CMNewDateTime (_broker, &rc);
    val.dateTime = cmpiDateTime;
    rc = CMSetProperty (instance, "DateTime", &val, CMPI_dateTime);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_dateTime : (%s)",
        strCMPIStatus (rc));

    val.ref = objPath;
    rc = CMSetProperty (instance, "Ref", &val, CMPI_ref);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_ref : (%s)",
        strCMPIStatus (rc));

    val.inst = instance1;
    rc = CMSetProperty (instance, "Instance", &val, CMPI_instance);
    PROV_LOG ("++++ Status of CMSetProperty of type CMPI_instance : (%s)",
        strCMPIStatus (rc));

    type = CDToString (_broker, instance, &rc);
    PROV_LOG ("++++ Passing CMPIInstance to mbEncToString successes : (%s)",
        strCMPIStatus (rc));

    args = CMNewArgs(_broker, &rc);
    PROV_LOG ("++++ Status of CMNewArgs : (%s)", strCMPIStatus (rc));
    type = CDToString (_broker, args, &rc);
    PROV_LOG ("++++ Passing CMPIArgs to mbEncToString successes : (%s)",
        strCMPIStatus (rc));

    PROV_LOG ("++++ Calling mbEncGetType function  ");
    rc1 = NULL;
    type = CDGetType (_broker, NULL, rc1);
    if (!type)
    {
        PROV_LOG ("++++ Error calling mbEncGetType with NULL rc");
    }

    rc1 = NULL;
    funcTable = instanceErr->ft;
    instanceErr->ft = NULL;
    type = CDGetType (_broker, instanceErr, rc1);
    if (!type)
    {
        PROV_LOG ("++++ Error calling mbEncGetType with wrong parameter and"
            " NULL rc");
    }
    type = CDGetType (_broker, instanceErr, &rc);
    PROV_LOG ("++++ Error status of mbEncGetType with wrong input : (%s)",
        strCMPIStatus (rc));

    instanceErr->ft = funcTable;

    type = CDGetType (_broker, NULL, &rc);
    PROV_LOG ("++++ Error status of mbEncGetType with NULL input : (%s)",
        strCMPIStatus (rc));

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

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

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

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

    cmpiArray = CMNewArray(_broker, cmpiCnt,cmpiType, &rc);
    type = CDGetType (_broker, cmpiArray, &rc);
    PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIArray:"
        " (%s) type(%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

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

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

    rc1 = NULL;
    selExp = CMNewSelectExp(_broker,
        "SELECT c,b FROM TestCMPI_Indication WHERE c='c' OR b=1",
        "WQL",
        NULL,
        rc1);
    PROV_LOG ("++++ CMNewSelectExp with rc set to NULL Called");

    selExp = CMNewSelectExp(_broker,
        "SELECT c,b FROM TestCMPI_Indication",
        "WQL",
        NULL,
        &rc);
    PROV_LOG ("++++ Status of CMNewSelectExp: (%s) ",
        strCMPIStatus (rc));
    type = CDGetType (_broker, selExp, &rc);
    PROV_LOG ("++++ Status of mbEncGetType with input of type CMPISelectExp:"
        " (%s) type(%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    handle = objPath1->hdl;
    objPath1->hdl = NULL;
    rc = CMRelease(objPath1);
    PROV_LOG ("++++ Status of CMRelease(objPath1): (%s)",
        strCMPIStatus (rc));
    objPath1->hdl = handle;
    rc = CMRelease(objPath1);
    PROV_LOG ("++++ Status of CMRelease(objPath1): (%s)",
        strCMPIStatus (rc));

    objPath1 = CMNewObjectPath(_broker,
        "test/TestProvider",
        "TestCMPI_Instance",
        &rc);
    PROV_LOG ("++++ Status of CMNewObjectPath for TestCMPI_Instance : (%s)",
        strCMPIStatus (rc));

    PROV_LOG_CLOSE();
    cmpiEnum = CBEnumInstances(_broker, ctx, objPath1, NULL, &rc);
    PROV_LOG_OPEN (_ClassName, _ProviderLocation);

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

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


    PROV_LOG ("++++ Calling mbEncIsOfType function ");
    bol = CDIsOfType (_broker, NULL, "No object", rc1);
    if(!bol)
    {
        PROV_LOG ("++++Calling mbEncIsOfType with NULL rc and wrong"
            " parameters");
    }
    bol = CDIsOfType (_broker, instance, "CMPIInstance", rc1);
    if(!bol)
    {
        PROV_LOG ("++++ Calling mbEncIsOfType with NULL rc");
    }
    bol = CDIsOfType (_broker, NULL, "No object", &rc);
    PROV_LOG ("++++ Error Status of mbEncIsOfType : (%s)", strCMPIStatus (rc));

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

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

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

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

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

    bol = CDIsOfType (_broker, cmpiDateTime, "CMPI", &rc);
    if (!bol)
    {
        PROV_LOG ("++++ CDIsOfType for CMPIDateTime status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }

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

    bol = CDIsOfType (_broker, cmpiStr, "CMPI", &rc);
    if (!bol)
    {
        PROV_LOG ("++++ CDIsOfType for CMPIString status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }

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

    bol = CDIsOfType (_broker, _broker, "CMPI", &rc);
    if (!bol)
    {
        PROV_LOG ("++++ CDIsOfType for CMPIBroker status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }


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

    bol = CDIsOfType (_broker, cmpiArray, "CMPI", &rc);
    if (!bol)
    {
        PROV_LOG ("++++ CDIsOfType for CMPIArray status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }

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

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

    bol = CDIsOfType (_broker, ctx, "CMPIContext", &rc);
    if (bol)
    {
        PROV_LOG ("++++ CDIsOfType for CMPIContext status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }
    bol = CDIsOfType (_broker, ctx, "CMPI", &rc);
    if (!bol)
    {
        PROV_LOG ("++++ CDIsOfType for CMPIContext status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }

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

    bol = CDIsOfType (_broker, cmpiEnum, "CMPI", &rc);
    if (!bol)
    {
        PROV_LOG ("++++ CDIsOfType for CMPIEnumeration status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }

    /* Testcase to increase coverage in CMPI_Enumeration.cpp*/
    rc = CMRelease(cmpiEnum);
    PROV_LOG ("++++ Status of CMRelease on cmpiEnum :(%s)",
        strCMPIStatus (rc));

    /**********************************************************/

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

    bol = CDIsOfType (_broker, selExp, "CMPI", &rc);
    if (!bol)
    {
        PROV_LOG ("++++ CDIsOfType for CMPISelectExp status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }

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

    bol = CDIsOfType (_broker, args, "CMPI", &rc);
    if (!bol)
    {
        PROV_LOG ("++++ CdIsOfType for CMPIArgs status is (%s) : %d",
            strCMPIStatus (rc),
            bol);
    }

    type = CMGetMessage (_broker,
        "msgid",
        "Test 0 arguments",
        &rc,
        0);
    PROV_LOG ("++++ Status of GetMessage with 0 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0",
        &rc,
        CMFmtArgs1(CMFmtChars("one argument")));
    PROV_LOG ("++++ Status of GetMessage with 1 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0 $1",
        &rc,
        CMFmtArgs2(CMFmtChars("Sint32 ::"),
            CMFmtSint(-1)));
    PROV_LOG ("++++ Status of GetMessage with 2 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0 $1, $2",
        &rc,
        CMFmtArgs3(CMFmtChars("Sint32, Uint32 ::"),
            CMFmtSint(-1),
            CMFmtUint(1)));
    PROV_LOG ("++++ Status of GetMessage with 3 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0 $1, $2, $3",
        &rc,
        CMFmtArgs4(CMFmtChars("Sint32, Uint32, Sint64 ::"),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64)));
    PROV_LOG ("++++ Status of GetMessage with 4 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0 $1, $2, $3, $4",
        &rc,
        CMFmtArgs5(CMFmtChars("Sint32, Uint32, Sint64, Uint64 ::"),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64)));
    PROV_LOG ("++++ Status of GetMessage with 5 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0 $1, $2, $3, $4, $5",
        &rc,
        CMFmtArgs6(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64 ::"),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64),
            CMFmtReal(64.64)));
    PROV_LOG ("++++ Status of GetMessage with 6 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0 $1, $2, $3, $4, $5, $6",
        &rc,
        CMFmtArgs7(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64,"
            " Boolean:: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64),
            CMFmtReal(64.64),
            CMFmtBoolean(1)));
    PROV_LOG ("++++ Status of GetMessage with 7 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0 $1, $2, $3, $4, $5, $6, $7",
        &rc,
        CMFmtArgs8(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64,"
            " Boolean, chars:: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64),
            CMFmtReal(64.64),
            CMFmtBoolean(1),
            CMFmtChars("chars")));
    PROV_LOG ("++++ Status of GetMessage with 8 arguments(%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage (_broker,
        "msgid",
        "Test $0 $1, $2, $3, $4, $5, $6, $7, $8",
        &rc,
        CMFmtArgs9(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64,"
            " Boolean, chars, String :: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64),
            CMFmtReal(64.64),
            CMFmtBoolean(1),
            CMFmtChars("chars"),
            CMFmtString(cmpiStr)));
    PROV_LOG ("++++ Status of GetMessage with 9 arguments (%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    strcpy(path,"path");
    rc = CMOpenMessageFile(_broker, path, &msgFileHandle);
    PROV_LOG ("++++ Status of CMOpenMessageFile (%s) ",
        strCMPIStatus (rc));

    type = CMGetMessage2(_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test zero arguments",
        &rc,
        0);
    PROV_LOG ("++++ Status of GetMessage2 with 0 argument (%s) type (%s)",
            strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2(_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0",
        &rc,
        CMFmtArgs1(CMFmtChars("Single argument")));
    PROV_LOG ("++++ Status of GetMessage2 with 1 argument (%s) type (%s)",
            strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2(_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0 $1",
        &rc,
        CMFmtArgs2(CMFmtChars("Sint32 ::"),CMFmtSint(1)));
    PROV_LOG ("++++ Status of GetMessage2 with 2 arguments (%s) type (%s)",
            strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2 (_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0 $1, $2",
        &rc,
        CMFmtArgs3(CMFmtChars("Sint32, Uint32 :: "),
            CMFmtSint(-1),
            CMFmtUint(1)));
    PROV_LOG ("++++ Status of GetMessage2 with 3 arguments (%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2 (_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0 $1, $2, $3",
        &rc,
        CMFmtArgs4(CMFmtChars("Sint32, Uint32, Sint64 :: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64)));
    PROV_LOG ("++++ Status of GetMessage2 with 4 arguments (%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2 (_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0 $1, $2, $3, $4",
        &rc,
        CMFmtArgs5(CMFmtChars("Sint32, Uint32, Sint64, Uint64 :: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64)));
    PROV_LOG ("++++ Status of GetMessage2 with 5 arguments (%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2 (_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0 $1, $2, $3, $4, $5",
        &rc,
        CMFmtArgs6(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64 :: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64),
            CMFmtReal(64.64)));
    PROV_LOG ("++++ Status of GetMessage2 with 6 arguments (%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2 (_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0 $1, $2, $3, $4, $5, $6",
        &rc,
        CMFmtArgs7(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64,"
            " Boolean :: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64),
            CMFmtReal(64.64),
            CMFmtBoolean(1)));
    PROV_LOG ("++++ Status of GetMessage2 with 7 arguments (%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2 (_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0 $1, $2, $3, $4, $5, $6, $7",
        &rc,
        CMFmtArgs8(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64,"
            " Boolean, chars :: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64),
            CMFmtReal(64.64),
            CMFmtBoolean(1),
            CMFmtChars("chars")));
    PROV_LOG ("++++ Status of GetMessage2 with 8 arguments (%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    type = CMGetMessage2 (_broker,
        "Common.CIMStatusCode.CIM_ERR_SUCCESS",
        msgFileHandle,
        "Test $0 $1, $2, $3, $4, $5, $6, $7, $8",
        &rc,
        CMFmtArgs9(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64,"
            " Boolean, chars, String :: "),
            CMFmtSint(-1),
            CMFmtUint(1),
            CMFmtSint64(-64),
            CMFmtUint64(64),
            CMFmtReal(64.64),
            CMFmtBoolean(1),
            CMFmtChars("chars"),
            CMFmtString(cmpiStr)));
    PROV_LOG ("++++ Status of GetMessage2 with 9 arguments (%s) type (%s)",
        strCMPIStatus (rc),
        CMGetCharsPtr(type, NULL));

    rc = CMCloseMessageFile(_broker, msgFileHandle);
    PROV_LOG ("++++ Status of CMCloseMessageFile (%s) ",
        strCMPIStatus (rc));

    CMRelease(instance1);
    CMRelease(instanceErr);
    return flag ;


}
Beispiel #27
0
static CMPIStatus
ClassProviderEnumClassNames(CMPIClassMI * mi,
                            const CMPIContext *ctx,
                            const CMPIResult *rslt, const CMPIObjectPath * ref)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  char           *cn = NULL;
  CMPIFlags       flgs = 0;
  CMPIString     *cni;
  ClassBase      *cb;
  Iterator        it;
  char           *key;
  int             rc,
                  n;
  ClassRecord    *crec;
  CMPIObjectPath *op;
  ClassRegister  *cReg;
  char           *ns;

  _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderEnumClassNames");

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

  ns = (char *) CMGetNameSpace(ref, NULL)->hdl;
  flgs = ctx->ft->getEntry(ctx, CMPIInvocationFlags, NULL).value.uint32;
  cni = ref->ft->getClassName(ref, NULL);
  if (cni) {
    cn = (char *) cni->hdl;
    if (cn && *cn == 0)
      cn = NULL;
  }
  cb = (ClassBase *) cReg->hdl;

  cReg->ft->wLock(cReg);

  if (cn && strcasecmp(cn, "$ClassProvider$") == 0)
    cn = NULL;

  if (cn == NULL) {
    n = 0;
    for (it = cReg->ft->getFirstClassRecord(cReg, &key, &crec);
         key && it && crec;
         it = cReg->ft->getNextClassRecord(cReg, it, &key, &crec)) {
      if ((flgs & CMPI_FLAG_DeepInheritance) || crec->parent == NULL) {
        if (((flgs & FL_assocsOnly) == 0)
            || crec->flags & CREC_isAssociation) {
          op = CMNewObjectPath(_broker, ns, key, NULL);
          CMReturnObjectPath(rslt, op);
        }
      }
    }
  }

  else {
    CMPIConstClass *cls = getClass(cReg, cn, NULL);
    if (cls == NULL) {
      st.rc = CMPI_RC_ERR_INVALID_CLASS;
    } else if ((flgs & CMPI_FLAG_DeepInheritance) == 0) {
      UtilList       *ul = getChildren(cReg, cn);
      char           *child;
      if (ul)
        for (child = (char *) ul->ft->getFirst(ul); child;
             child = (char *) ul->ft->getNext(ul)) {
          op = CMNewObjectPath(_broker, ns, child, NULL);
          CMReturnObjectPath(rslt, op);
        }
    } else if (flgs & CMPI_FLAG_DeepInheritance) {
      if (((flgs & FL_assocsOnly) == 0)
          || crec->flags & CREC_isAssociation)
        loopOnChildNames(cReg, cn, rslt);
    }
  }

  cReg->ft->wUnLock(cReg);

  _SFCB_RETURN(st);
}
CMPIStatus
IndCIMXMLHandlerInvokeMethod(CMPIMethodMI * mi,
                             const CMPIContext *ctx,
                             const CMPIResult *rslt,
                             const CMPIObjectPath * ref,
                             const char *methodName,
                             const CMPIArgs * in, CMPIArgs * out)
{
  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerInvokeMethod");

  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIStatus      circ = { CMPI_RC_OK, NULL };
  struct timeval tv;
  struct timezone tz;
  static unsigned int indID=1;


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

  if (strcasecmp(methodName, "_deliver") == 0) {

    // On the first indication, check if reliable indications are enabled.
    if (RIEnabled == -1) {
      CMPIObjectPath *op=CMNewObjectPath(_broker,"root/interop","CIM_IndicationService",NULL);
      CMPIEnumeration *isenm = _broker->bft->enumerateInstances(_broker, ctx, op, NULL, NULL);
      CMPIData isinst=CMGetNext(isenm,NULL);
      CMPIData mc=CMGetProperty(isinst.value.inst,"DeliveryRetryAttempts",NULL);
      RIEnabled=mc.value.uint16;
    }

    CMPIInstance *indo=CMGetArg(in,"indication",NULL).value.inst;
    CMPIInstance *ind=CMClone(indo,NULL);
    CMPIContext    *ctxLocal=NULL;
    CMPIObjectPath *iop=NULL,*subop=NULL;
    CMPIInstance *sub=NULL;

    if (RIEnabled) {
      ctxLocal = prepareUpcall((CMPIContext *) ctx);
      // Set the indication sequence values
      iop=CMGetObjectPath(ind,NULL);
      CMAddKey(iop,"SFCB_IndicationID",&indID,CMPI_uint32);
      CMSetProperty(ind,"SFCB_IndicationID",&indID,CMPI_uint32);
      // Prevent this property from showing up in the indication
      filterFlagProperty(ind, "SFCB_IndicationID");
      sub=CMGetArg(in,"subscription",NULL).value.inst;
      CMPIData handler=CMGetProperty(sub, "Handler", &st);
      CMPIObjectPath *hop=handler.value.ref;
      CMPIInstance *hdlr=CBGetInstance(_broker, ctxLocal, hop, NULL, &st);

      // Build the complete sequence context
      // Get the stub from the handler
      CMPIString *context = CMGetProperty(hdlr, "SequenceContext", &st).value.string;
      // and add the sfcb start time
      char *cstr=malloc( (strlen(context->ft->getCharPtr(context,NULL)) + strlen(sfcBrokerStart) + 1) * sizeof(char));
      sprintf(cstr,"%s%s",context->ft->getCharPtr(context,NULL),sfcBrokerStart);
      context = sfcb_native_new_CMPIString(cstr, NULL, 0); 
      // and put it in the indication
      CMSetProperty(ind, "SequenceContext", &context, CMPI_string);
      free(cstr);
      CMRelease(context);

      // Get the proper sequence number
      CMPIValue lastseq = CMGetProperty(hdlr, "LastSequenceNumber", &st).value;
      lastseq.sint64++;
      // Handle wrapping of the signed int
      if (lastseq.sint64 < 0) lastseq.sint64=0;
      // Update the last used number in the handler
      CMSetProperty(hdlr, "LastSequenceNumber", &lastseq.sint64, CMPI_sint64);
      CBModifyInstance(_broker, ctxLocal, hop, hdlr, NULL);
      // And the indication
      CMSetProperty(ind, "SequenceNumber", &lastseq, CMPI_sint64);
    }

    // Now send the indication
    st = deliverInd(ref, in, ind);
    if (st.rc != 0) {
      if (RIEnabled){
        _SFCB_TRACE(1,("--- Indication delivery failed, adding to retry queue"));
        // Indication delivery failed, send to retry queue
        // build an element
        RTElement      *element;
        element = (RTElement *) malloc(sizeof(*element));
        element->ref=ref->ft->clone(ref,NULL);
        // Get the OP of the subscription and indication
        subop=CMGetObjectPath(sub,NULL);
        element->sub=subop->ft->clone(subop,NULL);
        element->ind=iop->ft->clone(iop,NULL);
        // Store other attrs
        element->instanceID=indID;
        element->count=0;
        gettimeofday(&tv, &tz);
        element->lasttry=tv.tv_sec;
        // Push the indication to the repo
        CBCreateInstance(_broker, ctxLocal, iop, ind, &circ);
        if (circ.rc != 0) {
            mlogf(M_ERROR,M_SHOW,"Pushing indication instance to repository failed, rc:%d\n",circ.rc);
        }
        indID++;
        // Add it to the retry queue
        enqRetry(element,ctx,1);
        // And launch the thread if it isn't already running
        pthread_attr_init(&tattr);
        pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
        if (retryRunning == 0) {
          retryRunning = 1;
          _SFCB_TRACE(1,("--- Starting retryExport thread"));
          CMPIContext    *pctx = native_clone_CMPIContext(ctx);
          pthread_create(&t, &tattr, &retryExport, (void *) pctx);
        }
        CMRelease(ctxLocal);
      }
    }
    CMRelease(ind);
  }
  else {
    printf("--- ClassProvider: Invalid request %s\n", methodName);
    st.rc = CMPI_RC_ERR_METHOD_NOT_FOUND;
  }

  _SFCB_RETURN(st);
}
void           *
retryExport(void *lctx)
{
  _SFCB_ENTER(TRACE_INDPROVIDER, "retryExport");

  CMPIObjectPath *ref;
  CMPIArgs       *in;
  CMPIInstance   *sub;
  CMPIContext    *ctx = (CMPIContext *) lctx;
  CMPIContext    *ctxLocal;
  RTElement      *cur,
                 *purge;
  struct timeval  tv;
  struct timezone tz;
  int             rint,
                  maxcount,
                  ract,
                  rtint;
  CMPIUint64      sfc = 0;
  CMPIObjectPath *op;
  CMPIEnumeration *isenm = NULL;

  //Setup signal handlers
  struct sigaction sa;
  sa.sa_handler = handle_sig_retry;
  sa.sa_flags = 0;
  sigemptyset(&sa.sa_mask);
  sigaction(SIGUSR2, &sa, NULL);

  CMPIStatus      st = { CMPI_RC_OK, NULL };

  ctxLocal = prepareUpcall(ctx);

  // Get the retry params from IndService
  op = CMNewObjectPath(_broker, "root/interop", "CIM_IndicationService",
                       NULL);
  isenm = _broker->bft->enumerateInstances(_broker, ctx, op, NULL, NULL);
  CMPIData        isinst = CMGetNext(isenm, NULL);
  CMPIData        mc =
      CMGetProperty(isinst.value.inst, "DeliveryRetryAttempts", NULL);
  CMPIData        ri =
      CMGetProperty(isinst.value.inst, "DeliveryRetryInterval", NULL);
  CMPIData        ra =
      CMGetProperty(isinst.value.inst, "SubscriptionRemovalAction", NULL);
  CMPIData        rti =
      CMGetProperty(isinst.value.inst, "SubscriptionRemovalTimeInterval",
                    NULL);
  maxcount = mc.value.uint16;   // Number of times to retry delivery
  rint = ri.value.uint32;       // Interval between retries
  rtint = rti.value.uint32;     // Time to allow sub to keep failing until 
  ract = ra.value.uint16;       // ... this action is taken

  // Now, run the queue
  sleep(5); //Prevent deadlock on startup when localmode is used.
  pthread_mutex_lock(&RQlock);
  cur = RQhead;
  while (RQhead != NULL) {
    if(retryShutdown) break; // Provider shutdown
    ref = cur->ref;
    // Build the CMPIArgs that deliverInd needs
    CMPIInstance *iinst=internalProviderGetInstance(cur->ind,&st);
    if (st.rc != 0 ) {
      mlogf(M_ERROR,M_SHOW,"Failed to retrieve indication instance from repository, rc:%d\n",st.rc);
      purge=cur;
      cur=cur->next;
      dqRetry(ctx,purge);
      continue;
    }
    in=CMNewArgs(_broker,NULL);
    CMAddArg(in,"indication",&iinst,CMPI_instance);
    sub=internalProviderGetInstance(cur->sub,&st);
    if (st.rc == CMPI_RC_ERR_NOT_FOUND) {
      // sub got deleted, purge this indication and move on
      _SFCB_TRACE(1,("--- Subscription for indication gone, deleting indication."));
      purge = cur;
      cur = cur->next;
      dqRetry(ctx,purge);
    } else {
      // Still valid, retry
      gettimeofday(&tv, &tz);
      if ((cur->lasttry + rint) > tv.tv_sec) {
        _SFCB_TRACE(1,("--- sleeping."));
        // no retries are ready, release the lock
        // and sleep for an interval, then relock
        pthread_mutex_unlock(&RQlock);
        sleep(rint);
        if(retryShutdown) break; // Provider shutdown
        pthread_mutex_lock(&RQlock);
      }
      st = deliverInd(ref, in, iinst);
      if ((st.rc == 0) || (cur->count >= maxcount - 1)) {
        // either it worked, or we maxed out on retries
        // If it succeeded, clear the failtime
        if (st.rc == 0) {
          _SFCB_TRACE(1,("--- Indication succeeded."));
          sfc = 0;
          CMSetProperty(sub, "DeliveryFailureTime", &sfc, CMPI_uint64);
          CBModifyInstance(_broker, ctxLocal, cur->sub, sub, NULL);
        }
        // remove from queue in either case
        _SFCB_TRACE(1,("--- Indication removed."));
        purge = cur;
        cur = cur->next;
        dqRetry(ctx,purge);
      } else {
        // still failing, leave on queue 
        _SFCB_TRACE(1,("--- Indication still failing."));
        cur->count++;
        gettimeofday(&tv, &tz);
        cur->lasttry = tv.tv_sec;

        CMPIInstance * indele=internalProviderGetInstance(cur->SFCBIndEle,&st);
        CMSetProperty(indele,"LastDelivery",&cur->lasttry,CMPI_sint32);
        CMSetProperty(indele,"RetryCount",&cur->count,CMPI_uint32);
        CBModifyInstance(_broker, ctxLocal, cur->SFCBIndEle, indele, NULL);

        CMPIData        sfcp =
            CMGetProperty(sub, "DeliveryFailureTime", NULL);
        sfc = sfcp.value.uint64;
        if (sfc == 0) {
          // if the time isn't set, this is the first failure
          sfc = tv.tv_sec;
          CMSetProperty(sub, "DeliveryFailureTime", &sfc, CMPI_uint64);
          CBModifyInstance(_broker, ctxLocal, cur->sub, sub, NULL);
          cur = cur->next;
        } else if (sfc + rtint < tv.tv_sec) {
          // Exceeded subscription removal threshold, if action is:
          // 2, delete the sub; 3, disable the sub; otherwise, nothing
          if (ract == 2) {
            _SFCB_TRACE(1,("--- Subscription threshold reached, deleting."));
            CBDeleteInstance(_broker, ctx, cur->sub);
            purge = cur;
            cur = cur->next;
            dqRetry(ctx,purge);
          } else if (ract == 3) {
            // Set sub state to disable(4)
            _SFCB_TRACE(1,("--- Subscription threshold reached, disable."));
            CMPIUint16      sst = 4;
            CMSetProperty(sub, "SubscriptionState", &sst, CMPI_uint16);
            CBModifyInstance(_broker, ctx, cur->sub, sub, NULL);
            purge = cur;
            cur = cur->next;
            dqRetry(ctx,purge);
          }
        } else {
          cur = cur->next;
        }
      }
    }
  }
  // Queue went dry, cleanup and exit
  _SFCB_TRACE(1,("--- Indication retry queue empty, thread exitting."));
  pthread_mutex_unlock(&RQlock);
  retryRunning = 0;
  CMRelease(ctxLocal);
  CMRelease(ctx);
  _SFCB_RETURN(NULL);
}
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;
  CMPIData        rv;
  unsigned short  persistenceType;

  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerCreateInstance");

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

  internalProviderGetInstance(cop, &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);
  }

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

  setCCN(copLocal,ciLocal,"CIM_ComputerSystem");

  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 = (char *) malloc(n * sizeof(char));
      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 = (char *) malloc(15 * sizeof(char));
    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);
  }

  CMPIString     *str = CDToString(_broker, copLocal, NULL);
  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);
  rv = CBInvokeMethod(_broker, ctx, op, "_addHandler", in, out, &st);

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

  _SFCB_RETURN(st);
}

CMPIStatus
IndCIMXMLHandlerModifyInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci,
                               const char **properties)
{
  CMPIStatus      st = { CMPI_RC_ERR_NOT_SUPPORTED, NULL };
  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerSetInstance");
  _SFCB_RETURN(st);
}