Exemple #1
0
static PredicateDisjunction* binGetPredicateDisjunction(QLOperation* op) 
{
   Predicates *c=TrackedCMPIArray(1, CMPI_ptr, NULL);
   PredicateDisjunction *dc=TrackedCMPIArray(1, CMPI_ptr, NULL);
   CMPIValuePtr cv={op,0};
   CMPIValuePtr dcv={c,1};
  
   CMSetArrayElementAt(c,0,&cv,CMPI_ptr);
   CMSetArrayElementAt(dc,0,&dcv,CMPI_ptr);

   return dc;
} 
Exemple #2
0
static PredicateConjunction* binGetPredicateConjunction(QLOperation* op) 
{
   Predicates *d=TrackedCMPIArray(1, CMPI_ptr, NULL);
   PredicateConjunction *cd=TrackedCMPIArray(1, CMPI_ptr, NULL);
   CMPIValuePtr dv={op,0};
   CMPIValuePtr cdv={d,1};
  
   CMSetArrayElementAt(d,0,&dv,CMPI_ptr);
   CMSetArrayElementAt(cd,0,&cdv,CMPI_ptr);

   return cd;
} 
/************************************************************************
 * Function that sets the properties of a CIM object with values from the
 * provider specific resource.
 *
 * @param resource - provider specific resource to get values from
 * @param inst - CIM object whose properties are being set
 * @return CMPIrc return values
*************************************************************************/
static bool _set_allowed_operations(
    const CMPIBroker *broker,
    xen_host_record *host_rec,
    CMPIInstance *inst,
    char *property_name
    )
{
    int cap_count = 1; /* enabled/disabled is always allowed ? */
    //int i;
    cap_count++; //Default Reboot operation
    cap_count++; //Default shutdown operation
    //if(host_rec->allowed_operations->size > 0) {
      //  for(i=0; i<host_rec->allowed_operations->size; i++) {
        //    if((host_rec->allowed_operations->contents[i] == XEN_HOST_ALLOWED_OPERATIONS_REBOOT) ||
          //     (host_rec->allowed_operations->contents[i] == XEN_HOST_ALLOWED_OPERATIONS_SHUTDOWN))
            //   cap_count++;
       // }
    //}
    CMPIArray *statesSupported = CMNewArray(broker, cap_count, CMPI_uint16, NULL);
    DMTF_RequestedState additional_state;
    cap_count = 0;
    if(host_rec->enabled)
        additional_state = DMTF_RequestedState_Disabled;
    else
        additional_state = DMTF_RequestedState_Enabled;
    CMSetArrayElementAt(statesSupported, cap_count++, (CMPIValue *)&additional_state, CMPI_uint16);
    //for(i=0; i<host_rec->allowed_operations->size; i++) {
      //  if (host_rec->allowed_operations->contents[i] == XEN_HOST_ALLOWED_OPERATIONS_REBOOT) {
        //    additional_state = DMTF_RequestedState_Reboot;
          //  CMSetArrayElementAt(statesSupported, cap_count++, (CMPIValue *)&additional_state, CMPI_uint16);
       // }
       // else if (host_rec->allowed_operations->contents[i] == XEN_HOST_ALLOWED_OPERATIONS_SHUTDOWN) {
         //   additional_state = DMTF_RequestedState_Shut_Down;
           // CMSetArrayElementAt(statesSupported, cap_count++, (CMPIValue *)&additional_state, CMPI_uint16);
       // }
   // }

   //A temp fix for CA-45165 that should be revereted the moment the XAPI call is fixed.
   //It is returning the stated of shutdown and reboot all the time and expecting that in a case where
   //it can't, the error message is appropriate returned.
   additional_state = DMTF_RequestedState_Reboot;
   CMSetArrayElementAt(statesSupported, cap_count++, (CMPIValue *)&additional_state, CMPI_uint16);
   additional_state = DMTF_RequestedState_Shut_Down;
   CMSetArrayElementAt(statesSupported, cap_count++, (CMPIValue *)&additional_state, CMPI_uint16);

    CMSetProperty(inst, property_name, (CMPIValue *)&statesSupported, CMPI_uint16A);
    return true;
}
Exemple #4
0
PredicateConjunction *orGetPredicateConjunction(QLOperation *op) 
{
   int rdn=0,i,m,ii,mi;
   PredicateConjunction *lc=op->lhon->ft->getPredicateConjunction(op->lhon);
   if (!op->rhon) return lc;
   
   PredicateConjunction *rc=op->rhon->ft->getPredicateConjunction(op->rhon);
   PredicateConjunction *rd=TrackedCMPIArray(
      CMGetArrayCount(lc,NULL)*CMGetArrayCount(rc,NULL), CMPI_ptr, NULL);
      
   for (i=0, m=CMGetArrayCount(lc,NULL); i<m; i++) {
      PredicateConjunction *lci=CMGetArrayElementAt(lc,i,NULL).value.dataPtr.ptr;
      for (ii=0, mi=CMGetArrayCount(rc,NULL); ii<mi; ii++) {
         PredicateConjunction *rcii=CMGetArrayElementAt(rc,ii,NULL).value.dataPtr.ptr;
         Predicates *tc=TrackedCMPIArray(0, CMPI_ptr, NULL);
         CMPIValuePtr rdv={tc,1};               
         appendArray(tc,lci);
         appendArray(tc,rcii);
         CMSetArrayElementAt(rd,rdn,&rdv,CMPI_ptr); 
         rdn++;
      }
   }
   
   return rd;
}
Exemple #5
0
static CMPIArray *
getKeyList(CMPIConstClass * cc)
{
  int             i,
                  m,
                  c;
  unsigned long   quals;
  CMPIArray      *kar;
  CMPIString     *name;
  int             idx[32];

  for (i = c = 0, m = getPropertyCount(cc, NULL); i < m; i++) {
    getPropertyQualsAt(cc, i, NULL, &quals, NULL, NULL);
    if (quals & ClProperty_Q_Key) {
      idx[c] = i;
      c++;
    }
  }
  kar = NewCMPIArray(c, CMPI_string, NULL);

  for (i = 0; i < c; i++) {
    getPropertyQualsAt(cc, idx[i], &name, &quals, NULL, NULL);
    CMSetArrayElementAt(kar, i, &name, CMPI_string);
  }
  return kar;
}
CMPIStatus get_profile(const CMPIBroker *broker,
                       const CMPIObjectPath *reference,
                       const char **properties,
                       const char* pfx,
                       struct reg_prof *profile,
                       CMPIInstance **_inst)
{
        CMPIStatus s = {CMPI_RC_OK, NULL};
        CMPIInstance *instance = NULL;
        CMPIArray *array;

        instance = get_typed_instance(broker,
                                      pfx,
                                      "RegisteredProfile",
                                      CIM_INTEROP_NS,
                                      false);

        if (instance == NULL) {
                cu_statusf(broker, &s, 
                           CMPI_RC_ERR_FAILED,
                           "Can't create RegisteredProfile instance");
                goto out;
        }

        if (properties) {
                const char *keys[] = {"InstanceID", NULL};
                CMSetPropertyFilter(instance, properties, keys);
        }
        
        CMSetProperty(instance, "InstanceID",
                      (CMPIValue *)profile->reg_id, CMPI_chars);

        CMSetProperty(instance, "RegisteredOrganization", 
                      (CMPIValue *)&profile->reg_org, CMPI_uint16);

        CMSetProperty(instance, "RegisteredName", 
                      (CMPIValue *)profile->reg_name, CMPI_chars);

        CMSetProperty(instance, "RegisteredVersion", 
                      (CMPIValue *)profile->reg_version, CMPI_chars);

        array = CMNewArray(broker, 1, CMPI_uint16, &s);
        if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(array))) {
                cu_statusf(broker, &s, 
                           CMPI_RC_ERR_FAILED,
                           "Unable to create CMPIArray object");
                goto out;
        }

        CMSetArrayElementAt(array, 0, &profile->ad_types, CMPI_uint16);

        CMSetProperty(instance, "AdvertiseTypes",
                      (CMPIValue *)&array, CMPI_uint16A);

        *_inst = instance;

 out:

        return s;
}
Exemple #7
0
void setInstQualifiers(CMPIInstance *ci, XtokQualifiers *qs)
{
   XtokQualifier *nq = NULL,*q = qs ? qs->first : NULL;
   CMPIValue val;
   int rc;
   
   while (q) {
      if (q->type & CMPI_ARRAY) {
               CMPIType type=q->type&~CMPI_ARRAY;
               CMPIArray *arr = newCMPIArray(0, type, NULL);
               int i;
          if (q->data.array.max) {
              for (i = 0; i < q->data.array.next; ++i) {
                  val = str2CMPIValue(type, q->data.array.values[i], NULL);
                  CMSetArrayElementAt(arr, i, &val, type);
                  native_release_CMPIValue(type,&val);
               }
               rc = addInstQualifier(ci, q->name, (CMPIValue*)&arr, q->type);
               native_release_CMPIValue(q->type,(CMPIValue*)&arr);
      }
      }
      else {
         val = str2CMPIValue(q->type, q->data.value.data.value, NULL);
         rc = addInstQualifier(ci, q->name, &val, q->type);
         native_release_CMPIValue( q->type,&val);
      }
      nq = q->next;
      q = nq;
   }
   if (qs) {
      qs->first = qs->last = NULL;
   }
}
/**
    Create Instance from inst, using object-path op as reference.
*/
CMPIStatus TestInstanceProviderCreateInstance (
    CMPIInstanceMI * mi,
    const CMPIContext * ctx,
    const CMPIResult * rslt,
    const CMPIObjectPath * cop,
    const CMPIInstance * ci)
{
    CMPIStatus rc = { CMPI_RC_OK, NULL };
    CMPIInstance * inst;
    CMPIValue value_inst;
    CMPIData key1,key2, retInst;
    CMPIObjectPath *obp;
    unsigned int j = 0;
    if(ci)
    {
        /* clone the instance to be added to the array */
        inst = CMClone(ci, &rc);
        key1 = CMGetProperty(inst, "Identifier", &rc);
        for (j=0; j < numOfInst ; j++)
        {
            /* check for validity of Instance, that its not deleted */
            if (valid[j] == 1)
            {
                /* get element(instance) from array */
                retInst = CMGetArrayElementAt(clone_arr_ptr, j, &rc);
                /* get object-path of instance */
                obp = CMGetObjectPath(retInst.value.inst, &rc);
                /* get key from this object-path */
                key2 = CMGetKey(obp, "Identifier", &rc);
                /*compare key values.
                  If they match throw exception as two instance with same key
                  properties cannot exists. */
                if(key1.value.uint8 == key2.value.uint8)
                {
		  CMRelease(inst);
                    CMReturn (CMPI_RC_ERR_ALREADY_EXISTS);
                }
            }
        }
        value_inst.inst = inst;
        /* If instance doesnot exists in array add it */
        rc = CMSetArrayElementAt(
            clone_arr_ptr,
            numOfInst,
            &value_inst,
            CMPI_instance);
        valid[numOfInst]=1;
        numOfInst++;
        /* return object-path of instance */
        CMReturnObjectPath(rslt, cop);
        CMReturnDone(rslt);
    }
    else
    {
        CMReturn (CMPI_RC_ERR_NOT_SUPPORTED);
    }
    CMRelease(inst);
    CMReturn (CMPI_RC_OK);
}
Exemple #9
0
void setClassProperties(CMPIConstClass *cls, XtokProperties *ps)
{
   XtokProperty *np = NULL,*p = ps ? ps->first : NULL;
   CMPIValue val;
   CMPIArray       *arr = NULL;
   XtokQualifier   *nq,*q;
   XtokQualifiers *qs;
   int rc, n;

      val.uint64=0l;
   while (p) {
      switch (p->propType) {
      case typeProperty_Value:
         addClassProperty(cls, p->name, &val, p->valueType, CMPI_nullValue);
         break;
      case typeProperty_Reference:
         addClassProperty(cls, p->name, &val, CMPI_ref, CMPI_nullValue);
     break;
      case typeProperty_Array:
         val.array = arr;
     addClassProperty(cls, p->name, &val,
                               p->valueType | CMPI_ARRAY, CMPI_nullValue);
         break;
      }

      qs=&p->val.qualifiers;
      q=qs ? qs->first : NULL;  
      n=0;   
      while (q) {
         if (q->type & CMPI_ARRAY) {
            CMPIType type=q->type&~CMPI_ARRAY;
            arr = newCMPIArray(0, type, NULL);
            int i;
            if (q->data.array.max) {
                for (i = 0; i < q->data.array.next; ++i) {
               val = str2CMPIValue(type, q->data.array.values[i], NULL);
               CMSetArrayElementAt(arr, i, &val, type);
               native_release_CMPIValue(type,&val);
            }
            }
            val.array = arr;
            rc = addClassPropertyQualifier(cls, p->name, q->name, &val, q->type); 
            native_release_CMPIValue(q->type,(CMPIValue*)&arr);
         }
         else {
            val = str2CMPIValue(q->type, q->data.value.data.value, NULL);
            rc= addClassPropertyQualifier(cls, p->name, q->name, &val, q->type);
            native_release_CMPIValue(q->type,&val);
         }   
         nq = q->next; 
         q = nq;
      }

      np = p->next;
      p = np;
   }
   if (ps) ps->first = ps->last = NULL;
}
Exemple #10
0
void setClassMethods(CMPIConstClass *cls, XtokMethods *ms)
{
   XtokMethod *nm = NULL,*m = ms ? ms->first : NULL;
   CMPIValue      val;
   CMPIArray      *arr = NULL;
   XtokQualifier  *nq,*q;
   XtokQualifiers *qs;
   XtokParam      *np,*p;
   XtokParams     *ps;
   int rc, n;

   val.uint64=0l;
   while (m) {
      addClassMethod(cls, m->name, &val, m->type, CMPI_nullValue);

      qs=&m->qualifiers;
      q=qs ? qs->first : NULL;
      n=0;
      while (q) {
         if (q->type & CMPI_ARRAY) {
            CMPIType type=q->type&~CMPI_ARRAY;
            arr = newCMPIArray(0, type, NULL);
            int i;
            if (q->data.array.max) {
               for (i = 0; i < q->data.array.next; ++i) {
                  val = str2CMPIValue(type, q->data.array.values[i], NULL);
                  CMSetArrayElementAt(arr, i, &val, type);
                  native_release_CMPIValue(type,&val);
               }
            }
            val.array = arr;
            rc = addClassMethodQualifier(cls, m->name, q->name, &val, q->type);
            native_release_CMPIValue(q->type,(CMPIValue*)&arr);
         }
         else {
            val = str2CMPIValue(q->type, q->data.value.data.value, NULL);
            rc= addClassMethodQualifier(cls, m->name, q->name, &val, q->type);
            native_release_CMPIValue(q->type,&val);
         }
         nq = q->next; 
         q = nq;
      }

      ps=&m->params;
      p=ps ? ps->first : NULL;
      n=0;
      while (p) {
         rc= addClassMethodParameter(cls, m->name, p->name, p->type);
         np = p->next; 
         p = np;
      }

      nm = m->next;
      m = nm;
   }
   if (ms) ms->first = ms->last = NULL;
}
Exemple #11
0
static CMPIArray *appendArray(CMPIArray *t, CMPIArray *f)
{
   int tn=CMGetArrayCount(t,NULL),fm=CMGetArrayCount(f,NULL),fn;
   
   for (fn=0; fn<fm; tn++,fn++) {
      CMPIData d=CMGetArrayElementAt(f,fn,NULL);
      sfcb_native_array_increase_size(t,1);
      CMSetArrayElementAt(t,tn,&d.value,d.type); 
   }   
   return t;   
}
CMPIStatus TestInstanceProviderDeleteInstance (
    CMPIInstanceMI * mi,
    const CMPIContext * ctx,
    const CMPIResult * result,
    const CMPIObjectPath * cop)
{

    CMPIStatus rc = { CMPI_RC_OK, NULL };
    CMPIData key1, key2, retInst;
    CMPIObjectPath *obp;
    unsigned int j = 0, flag = 0;
    /* get key from the object-path */
    key1 = CMGetKey(cop, "Identifier", &rc);
    for (j=0; j < numOfInst ; j++)
    {
        /*check for validity of Instance, that its not deleted */
        if(valid[j] == 1)
        {
            /*get element(instance) from array */
            retInst = CMGetArrayElementAt(clone_arr_ptr, j, &rc);

            /*get object-path of instance */
            obp = CMGetObjectPath(retInst.value.inst, &rc);

            /*get key from this object-path */
            key2 = CMGetKey(obp, "Identifier" , &rc);

            /*compare key values.
              If they match, release the object(instance)
              Also set its validity to zero, marking it as deleted */
            if (key1.value.uint8 == key2.value.uint8)
            {
                if(retInst.value.inst)
                {
                    flag =1;
                    CMRelease(retInst.value.inst);
                    CMSetArrayElementAt(
                        clone_arr_ptr,
                        j,
                        &retInst.value.inst,
                        CMPI_null);
                    valid[j] = 0;
                }
            }
        }
    }
    if(!flag)
    {
        CMReturn (CMPI_RC_ERR_NOT_FOUND);
    }
    CMReturn (CMPI_RC_OK);
}
static CMPIrc memorypool_set_properties(
    provider_resource *resource,
    CMPIInstance *inst
    )
{
    local_host_resource *ctx = resource->ctx;
    char buf[MAX_INSTANCEID_LEN];
    int prop_val_32;
    xen_host_metrics_record *host_metrics_rec = NULL;

    if (ctx->host_rec->metrics->is_record)
        host_metrics_rec = ctx->host_rec->metrics->u.record;
    else
        xen_host_metrics_get_record(resource->session->xen, &host_metrics_rec, ctx->host_rec->metrics->u.handle);

    _CMPICreateNewDeviceInstanceID(buf, MAX_INSTANCEID_LEN, ctx->host_rec->uuid, "MemoryPool");
    CMSetProperty(inst, "InstanceID", (CMPIValue *)buf, CMPI_chars);
    CMSetProperty(inst, "PoolID", (CMPIValue *)ctx->host_rec->uuid, CMPI_chars);

    int type = DMTF_ResourceType_Memory;
    CMSetProperty(inst, "ResourceType", (CMPIValue *)&type, CMPI_uint16);
    CMSetProperty(inst, "ResourceSubType", (CMPIValue *) "Xen Memory", CMPI_chars);
    CMSetProperty(inst, "AllocationUnits", (CMPIValue *)"Bytes", CMPI_chars);

    CMSetProperty(inst, "Capacity",(CMPIValue *)&(host_metrics_rec->memory_total), CMPI_uint64);
    CMSetProperty(inst, "Caption", (CMPIValue *)"Xen Virtual Memory Pool", CMPI_chars);
    CMSetProperty(inst, "Description", (CMPIValue *)"Xen Virtual Memory Pool", CMPI_chars);
    CMSetProperty(inst, "ElementName", (CMPIValue *)ctx->host_rec->name_label, CMPI_chars);
    prop_val_32 = DMTF_HealthState_OK;
    CMSetProperty(inst, "HealthState", (CMPIValue *)&prop_val_32, CMPI_uint16);
    //CMSetProperty(inst, "InstallDate", (CMPIValue *)installDate, CMPI_dateTime);
    CMSetProperty(inst, "Name", (CMPIValue *)"Xen Virtual Memory Pool", CMPI_chars);
    prop_val_32 = DMTF_OperationalStatus_OK;
    CMPIArray *arr = CMNewArray(resource->broker, 1, CMPI_uint16, NULL);
    CMSetArrayElementAt(arr, 0, (CMPIValue *)&prop_val_32, CMPI_uint16);
    CMSetProperty(inst, "OperationalStatus", (CMPIValue *) &arr, CMPI_uint16A);
    //CMSetProperty(inst, "OtherResourceType", (CMPIValue *)other_resource_type, CMPI_String);

    prop_val_32 = 1;
    CMSetProperty(inst, "Primordial" , (CMPIValue *)&prop_val_32, CMPI_boolean);
    //CMSetProperty(inst, "Status", (CMPIValue *)status, CMPI_chars);
    // CMSetProperty(inst, "StatusDescriptions", (CMPIValue *)status_descs, CMPI_chars);

    int64_t reserved = host_metrics_rec->memory_total - host_metrics_rec->memory_free;
    CMSetProperty(inst, "Reserved", (CMPIValue *)&reserved, CMPI_uint64);
    // CMSetProperty(inst, "Unreservable", (CMPIValue *)unreservable, CMPI_uint16);

    if (!ctx->host_rec->metrics->is_record)
        xen_host_metrics_record_free(host_metrics_rec);

    return CMPI_RC_OK;
}
static CMPIrc processorpool_set_properties(
    const CMPIBroker *broker,
    provider_resource *resource, 
    CMPIInstance *inst)
{
    uint64_t prop_val_64;
    int prop_val_32;
    char buf[MAX_INSTANCEID_LEN];
    xen_host_record *host_rec = ((local_host_resource *)resource->ctx)->host_rec;

    _CMPICreateNewDeviceInstanceID(buf, MAX_INSTANCEID_LEN, host_rec->uuid, "ProcessorPool");
    CMSetProperty(inst, "InstanceID", (CMPIValue *)buf, CMPI_chars);
    CMSetProperty(inst, "PoolID", (CMPIValue *)host_rec->uuid, CMPI_chars);

    _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO, ("setting ProcessorPool properties -InstanceID: %s", buf));

    prop_val_32 = DMTF_ResourceType_Processor; 
    CMSetProperty(inst, "ResourceType", (CMPIValue *)&prop_val_32, CMPI_uint16);
    CMSetProperty(inst, "ResourceSubType", (CMPIValue *) "xen:vcpu", CMPI_chars);
    CMSetProperty(inst, "AllocationUnits", (CMPIValue *)"count", CMPI_chars);

    /* Capacity is the number of items in xen_host_cpu_set. */
    prop_val_64 = host_rec->host_cpus->size;
    CMSetProperty(inst, "Capacity", (CMPIValue *)&prop_val_64, CMPI_uint64);
    CMSetProperty(inst, "Caption", (CMPIValue *)"Xen Virtual Processor Pool", CMPI_chars);
    CMSetProperty(inst, "Description", (CMPIValue *)host_rec->name_description, CMPI_chars);
    CMSetProperty(inst, "ElementName", (CMPIValue *)host_rec->name_label, CMPI_chars);
    prop_val_32 = DMTF_HealthState_OK;
    CMSetProperty(inst, "HealthState", (CMPIValue *)&prop_val_32, CMPI_uint16);
    //CMSetProperty(inst, "InstallDate", (CMPIValue *)&installDate, CMPI_dateTime);
    CMSetProperty(inst, "Name", (CMPIValue *)"Xen Virtual Processor Pool", CMPI_chars);

    prop_val_32 = DMTF_OperationalStatus_OK;
    CMPIArray *arr = CMNewArray(broker, 1, CMPI_uint16, NULL);
    CMSetArrayElementAt(arr, 0, (CMPIValue *)&prop_val_32, CMPI_uint16);
    CMSetProperty(inst, "OperationalStatus", (CMPIValue *) &arr, CMPI_uint16A);

    //CMSetProperty(inst, "OtherResourceType", (CMPIValue *)other_resource_type, CMPI_String);
    prop_val_32 = 1;
    CMSetProperty(inst, "Primordial" , (CMPIValue *)&prop_val_32, CMPI_boolean);
    //CMSetProperty(inst, "Status", (CMPIValue *)status, CMPI_chars);
    // CMSetProperty(inst, "StatusDescriptions", (CMPIValue *)status_descs, CMPI_chars);

    /* Does Xen implement reservation of CPUs by VMs ? */
    prop_val_64 = 0;
    CMSetProperty(inst, "Reserved", (CMPIValue *)&prop_val_64, CMPI_uint64);
    // CMSetProperty(inst, "Unreservable", (CMPIValue *)unreservable, CMPI_uint16);

    return CMPI_RC_OK;
}
Exemple #15
0
void setClassQualifiers(CMPIConstClass *cls, XtokQualifiers *qs)
{
   XtokQualifier *nq = NULL,*q = qs ? qs->first : NULL;
   CMPIValue val;
   int rc;
   
   while (q) {
      if (q->type & CMPI_ARRAY) {
               CMPIType type=q->type&~CMPI_ARRAY;
               CMPIArray *arr = newCMPIArray(0, type, NULL);
               int i;
          if (q->data.array.max > 0) {
              for (i = 0; i < q->data.array.next; ++i) {
                   char *valStr = q->data.array.values[i];
                   if (type == CMPI_string || type == CMPI_chars)
                   {
                       char *charsStr = XmlToAsciiStr(valStr);
                       val = str2CMPIValue(type, charsStr, NULL);
                       free (charsStr);
                   }
                   else
                       val = str2CMPIValue(type, valStr, NULL);
                  CMSetArrayElementAt(arr, i, &val, type);
                  native_release_CMPIValue(type,&val);
               }
               rc = addClassQualifier(cls, q->name, (CMPIValue*)&arr, q->type);
               native_release_CMPIValue(q->type,(CMPIValue*)&arr);
      }
      }
      else {
          char *valStr = q->data.value.data.value;
          if (q->type == CMPI_string || q->type == CMPI_chars)
          {
              char *charsStr = XmlToAsciiStr(valStr);
              val = str2CMPIValue(q->type, charsStr, NULL);
              free (charsStr);
          }
          else
              val = str2CMPIValue(q->type, valStr, NULL);
         rc = addClassQualifier(cls, q->name, &val, q->type);
         native_release_CMPIValue( q->type,&val);
      }
      nq = q->next;
      q = nq;
   }
   if (qs) {
      qs->first = qs->last = NULL;
   }
}
Exemple #16
0
static CMPIStatus returnData(const CMPIResult * result,
                                   const CMPIValue * val, CMPIType type)
{
   NativeResult *r = (NativeResult*) result;
   
   if (r->current == 0 && r->array==NULL) {
      CMPIStatus rc;
      r->array = TrackedCMPIArray(1, type, &rc);
      r->current = 0;
      if (rc.rc != CMPI_RC_OK) return rc;
   }
   else sfcb_native_array_increase_size(r->array, 1);

   return CMSetArrayElementAt(r->array, r->current++, val, type); 
}
Exemple #17
0
static NativeSelectExp *
__new_exp(int mode, const char *queryString,
          const char *language, const char *sns, CMPIArray **projection,
          CMPIStatus *rc)
{
  int             state,
                  irc;
  NativeSelectExp exp,
                 *tExp;

  memset(&exp, 0, sizeof(exp));
  exp.exp = eFt;

  /*
   * fprintf(stderr,"*** new select expression: %s %s\n",queryString,
   * language);
   */
  exp.qs =
      parseQuery(mode, (char *) queryString, (char *) language,
                 (char *) sns, &irc);
  if (irc) {
    if (rc)
      CMSetStatus(rc, CMPI_RC_ERR_INVALID_QUERY);
    return NULL;
  }

  exp.queryString = strdup(queryString);
  exp.language = strdup(language);
  if (sns)
    exp.sns = strdup(sns);

  if (projection) {
    char          **list = exp.qs->spNames;
    int             i;
    CMPIArray      *ar =
        *projection = TrackedCMPIArray(exp.qs->spNext, CMPI_string, NULL);
    for (i = 0; *list; list++, i++)
      CMSetArrayElementAt(ar, i, (CMPIValue *) * list, CMPI_chars);
  }

  tExp = memAddEncObj(mode, &exp, sizeof(exp), &state);
  tExp->mem_state = state;

  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return tExp;
}
Exemple #18
0
CMPIBoolean KArray_Null(
    KArray* self, 
    CMPICount i,
    CMPIType type)
{
    CMPIStatus st = KSTATUS_INIT;

    if (!self || !self->exists || !self->value)
        return 0;

    st = CMSetArrayElementAt((CMPIArray*)self->value, i, NULL, type);

    if (!KOkay(st))
        return 0;

    return 1;
}
Exemple #19
0
static void loopOnChildChars(ClassRegister *cReg, char *cn, CMPIArray *ar, int *i, int ignprov)
{
   UtilList *ul = getChildren(cReg,cn);
   char *child;

   _SFCB_ENTER(TRACE_PROVIDERS, "loopOnChildChars");
   _SFCB_TRACE(1,("--- class %s",cn));

   if (ul) for (child = (char *) ul->ft->getFirst(ul); child;  
         child=(char*)ul->ft->getNext(ul)) {
      if (ignprov || repCandidate(cReg, child)) {
         CMSetArrayElementAt(ar, *i, child, CMPI_chars);
         *i=(*i)+1;
      }
      loopOnChildChars(cReg, child,ar,i,ignprov);
   }
   _SFCB_EXIT();
}
Exemple #20
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));
}
static void initialize()
{
    CMPIStatus rc = { CMPI_RC_OK, NULL};
    CMPIArray *arr_ptr;
    CMPIValue value1, value2, value_inst1, value_inst2;
    CMPIInstance *instance1, *instance2, *instance3;
    CMPIObjectPath *cop1, *cop2, *cop3;
    value1.uint8 = 1;
    value2.string = CMNewString(_broker, "Hello World", &rc);

    /* create a new array to hold the instances created */
    arr_ptr = CMNewArray(_broker, initArraySize, CMPI_instance, &rc);

    /* create object path for instance1 */
    cop1 = CMNewObjectPath(
                _broker,
                "root/cimv2",
                _ClassName,
                &rc);
    /* add key (with its value) to object path to recognize instance uniquely */
    CMAddKey(cop1, "Identifier", (CMPIValue *)&value1, CMPI_uint8);
    /* if created object path is not null then create new instance */
    if(!CMIsNullObject(cop1))
    {

        instance1 = CMNewInstance(_broker,
                        cop1,
                        &rc);
        /* set the properties for newly created instance */
        CMSetProperty(instance1, "Identifier",&value1, CMPI_uint8);
        CMSetProperty(instance1, "Message", &value2, CMPI_string);
        value_inst1.inst = instance1;

        /* assign the created instance to array created */
        rc = CMSetArrayElementAt(
            arr_ptr,
            numOfInst,
            &value_inst1,
            CMPI_instance);
        /* set the validity of instance to be true.
        Validity gets false if instance gets deleted using deleteInstance(). */
        valid[numOfInst] = 1;
        numOfInst++;
    }

    /* create instance 2 and add to array */
    value1.uint8 = 2;
    value2.string = CMNewString(_broker, "Yo Planet", &rc);
    cop2 = CMNewObjectPath(
                _broker,
                "root/cimv2",
                _ClassName,
                &rc);
    CMAddKey(cop2, "Identifier", (CMPIValue *)&value1, CMPI_uint8);
    if(!CMIsNullObject(cop2))
    {

        instance2 = CMNewInstance(_broker,
                        cop2,
                        &rc);
         CMSetProperty(instance2, "Identifier", &value1, CMPI_uint8);
         CMSetProperty(instance2, "Message", &value2, CMPI_string);
         value_inst2.inst = instance2;
         rc = CMSetArrayElementAt(arr_ptr,
            numOfInst,
            &value_inst2,
            CMPI_instance);
         valid[numOfInst] = 1;
         numOfInst++;
    }

    /* create instance 3 and add to array */
    value1.uint8 = 3;
    value2.string = CMNewString(_broker, "Hey Earth", &rc);
    cop3 = CMNewObjectPath(
                _broker,
                "root/cimv2",
                _ClassName,
                &rc);
    CMAddKey(cop3, "Identifier", (CMPIValue *)&value1, CMPI_uint8);
    if(!CMIsNullObject(cop3))
    {

        instance3 = CMNewInstance(_broker,
                        cop3,
                        &rc);
         CMSetProperty(instance3, "Identifier", &value1, CMPI_uint8);
         CMSetProperty(instance3, "Message", &value2, CMPI_string);
         value_inst2.inst = instance3;
         rc = CMSetArrayElementAt(arr_ptr,
            numOfInst,
            &value_inst2,
            CMPI_instance);
         valid[numOfInst] = 1;
         numOfInst++;
    }
    /* clone the array which contains instances. */
    clone_arr_ptr = arr_ptr->ft->clone(arr_ptr, &rc);
}
Exemple #22
0
CMPIValue
str2CMPIValue(CMPIType type, XtokValue val, XtokValueReference * ref,
              char *ns, CMPIStatus *status)
{
  CMPIValue       value;
  CMPIType        t = 0;
  CMPIStatus rc = {CMPI_RC_OK, NULL};

  if (type == 0) {
    type = guessType(val.value);
  }

  if (type & CMPI_ARRAY) {
    /*
     * array type received -- needs special handling 
     */
    int             i,
                    max;
    CMPIValue       v;
    XtokValueArray *arr = (XtokValueArray *) ref;
    XtokValueRefArray *refarr = (XtokValueRefArray *) arr;
    max = arr->next;
    if ((type & CMPI_ref) == CMPI_ref) {
      t = CMPI_ref;
    } else if (type & ~CMPI_ARRAY) {
      t = type & ~CMPI_ARRAY;
    } else {
      /*
       * the guess type can go wrong 
       */
      if (max > 0) {
        t = guessType(arr->values[0].value);
      }
    }
    /*
     * build an array by looping thru the elements 
     */
    value.array = TrackedCMPIArray(max, t, NULL);
    if (value.array != NULL) {
      for (i = 0; i < max; i++) {
        v = str2CMPIValue(t, arr->values[i], refarr->values + i, ns, &rc);
        CMSetArrayElementAt(value.array, i, &v, t);
      }
      return value;
    }
  }

  /* Feature 75543 - set and return status->rc on failures */
  switch (type) {
  case CMPI_char16:
    value.char16 = *val.value;
    break;
  case CMPI_string:
    value.string = sfcb_native_new_CMPIString(val.value, NULL, 0);
    break;
  case CMPI_sint64:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%lld", &value.sint64);
    break;
  case CMPI_uint64:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%llu", &value.uint64);
    break;
  case CMPI_sint32:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%d", &value.sint32);
    break;
  case CMPI_uint32:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%u", &value.uint32);
    break;
  case CMPI_sint16:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%hd", &value.sint16);
    break;
  case CMPI_uint16:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%hu", &value.uint16);
    break;
  case CMPI_uint8:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       sscanf(val.value, "%u", &value.uint32);
       value.uint8 = value.uint32;
    }
    break;
  case CMPI_sint8:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       sscanf(val.value, "%d", &value.sint32);
       value.sint8 = value.sint32;
    }
    break;
  case CMPI_boolean:
    if (invalid_boolean(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       value.boolean = strcasecmp(val.value, "false");
       if (value.boolean)
         value.boolean = 1;
    }
    break;
  case CMPI_real32:
    if (invalid_real(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%f", &value.real32);
    break;
  case CMPI_real64:
    if (invalid_real(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%lf", &value.real64);
    break;
  case CMPI_dateTime:
    value.dateTime =
        sfcb_native_new_CMPIDateTime_fromChars(val.value, NULL);
    break;
  case CMPI_ref:
    getKeyValueTypePtr("ref", NULL, ref, &value, &t, ns);
    break;
  case CMPI_instance:
    value = makeFromEmbeddedObject(val, ns);
    break;
  default:
    mlogf(M_ERROR, M_SHOW, "%s(%d): invalid value %d-%p\n", __FILE__,
          __LINE__, (int) type, val);
    abort();
  }
  return value;
}
CMPIInstance * _makeInst_TestClassA(
    const CMPIBroker * _broker,
    const CMPIContext * ctx,
    const CMPIObjectPath * cop,
    const char ** properties)
{
   CMPIArray       *array  = NULL;
   CMPIValue opstatus;
   CMPIValue status;
   CMPIValue theKey;
   CMPIObjectPath* op=NULL;
   CMPIInstance* ci=NULL;
   opstatus.uint16 = 0; /* Unknown */
   status.uint16 = 2;  /* Enabled */
   theKey.uint32 = 2;

   //
   // Construct ObjectPath
   //
   op=_makePath_TestClassA(_broker,ctx,cop);

   //
   // Create a new instance and fill it's properties
   //
   ci = CMNewInstance( _broker, op, NULL);
   CMRelease(op);
   CMSetPropertyFilter(ci,properties,NULL);

   //
   // Properties of CIM_ManagedElement
   //
   CMSetProperty(ci,"Caption","Test class A",CMPI_chars);
   CMSetProperty(
       ci,
       "Description",
       "Test class used for all kinds of testing",
       CMPI_chars);
   CMSetProperty(ci,"ElementName","Instance1",CMPI_chars);

   //
   // Properties of CIM_ManagedSystemElement
   //
   array = CMNewArray(_broker,1,CMPI_uint16,NULL);
   CMSetArrayElementAt(array,0,&opstatus,CMPI_uint16);
   CMSetProperty(ci,"OperationalStatus",(CMPIValue*)&(array),CMPI_uint16A);

   //
   // Properties of CIM_EnabledLogicalElement
   //
   CMSetProperty(ci,"EnabledState",&status,CMPI_uint16);
   CMSetProperty(ci,"OtherEnabledState","NULL",CMPI_chars);
   CMSetProperty(ci,"RequestedState",&status,CMPI_uint16);
   CMSetProperty(ci,"EnabledDefault",&status,CMPI_uint16);

   //
   // Properties of CIM_TestClass
   //
   CMSetProperty(ci,"theKey",&theKey,CMPI_uint32 );
   CMSetProperty(ci,"theData",&theKey,CMPI_uint32 );
   CMSetProperty(ci,"theString","Test Instance Number One",CMPI_chars);

   return ci;
}
static int
_testCMPIArray()
{
  CMPIStatus      rc = { CMPI_RC_OK, NULL };
  CMPIArray      *arr_ptr = NULL;
  CMPIArray      *new_arr_ptr = NULL;
  CMPIData        data[3];
  CMPIData        clonedData[3];
  CMPIValue       value;
  CMPIType        initArrayType = CMPI_uint32;
  CMPIType        initErrArrayType = CMPI_REAL;
  CMPIType        returnedArrayType;
  CMPICount       initArraySize = 3;
  CMPICount       returnedArraySize;
  CMPIUint32      i;
  CMPIBoolean     cloneSuccessful = 0;
  CMPIBoolean     getDataSuccessful;
  void           *aptr;
  arr_ptr = CMNewArray(_broker, initArraySize, initArrayType, &rc);
  if (arr_ptr == NULL) {
    return 1;
  }
  returnedArraySize = CMGetArrayCount(arr_ptr, &rc);
  returnedArrayType = CMGetArrayType(arr_ptr, &rc);

  value.uint32 = 10;
  rc = CMSetArrayElementAt(arr_ptr, 0, &value, initArrayType);
  value.uint32 = 20;
  rc = CMSetArrayElementAt(arr_ptr, 1, &value, initArrayType);
  value.uint32 = 30;
  rc = CMSetArrayElementAt(arr_ptr, 2, &value, initArrayType);

  i = 0;
  while (i < 3) {
    data[i] = CMGetArrayElementAt(arr_ptr, i, &rc);
    i++;
  }

  i = 0;
  getDataSuccessful = 1;
  while (i < 3) {
    if (data[i].value.uint32 != (i + 1) * 10) {
      getDataSuccessful = 0;
      break;
    }
    i++;
  }
  new_arr_ptr = arr_ptr->ft->clone(arr_ptr, &rc);
  i = 0;
  while (i < 3) {
    clonedData[i] = CMGetArrayElementAt(new_arr_ptr, i, &rc);
    i++;
  }

  cloneSuccessful = 1;
  for (i = 0; i < initArraySize; i++) {
    if (data[i].value.uint32 != clonedData[i].value.uint32) {
      cloneSuccessful = 0;
      break;
    }
  }
  rc = new_arr_ptr->ft->release(new_arr_ptr);
  aptr = arr_ptr->hdl;
  arr_ptr->hdl = NULL;

  returnedArraySize = CMGetArrayCount(arr_ptr, &rc);
  if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) {
    return 1;
  }

  returnedArrayType = CMGetArrayType(arr_ptr, &rc);
  if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) {
    return 1;
  }

  rc = CMSetArrayElementAt(arr_ptr, 2, &value, initArrayType);
  if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) {
    return 1;
  }

  CMGetArrayElementAt(arr_ptr, 5, &rc);
  if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) {
    return 1;
  }
  arr_ptr->ft->clone(arr_ptr, &rc);
  if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) {
    return 1;
  }

  rc = arr_ptr->ft->release(arr_ptr);
  if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) {
    return 1;
  }

  arr_ptr->hdl = aptr;

  CMGetArrayElementAt(arr_ptr, 5, &rc);
  if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) {
    return 1;
  }

  rc = CMSetArrayElementAt(arr_ptr, 2, &value, initErrArrayType);
  if (rc.rc != CMPI_RC_ERR_TYPE_MISMATCH) {
    return 1;
  }

  rc = arr_ptr->ft->release(arr_ptr);
  return 0;
}
Exemple #25
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);
}
/****************************************************************************
* disk_rasd_from_vbd
*
* This function builds a new Xen_Disk CIM instance based on the information
* in the VBD record
*
* Returns 1 on Success and 0 on failure.
*****************************************************************************/
int disk_rasd_from_vbd(
    const CMPIBroker* broker,
    xen_utils_session *session,
    CMPIInstance *inst,
    xen_vm_record *vm_rec,
    xen_vbd_record *vbd_rec,
    xen_vdi_record *vdi_rec
    )
{
    char buf[MAX_INSTANCEID_LEN];
    xen_sr_record *sr_rec = NULL;
    unsigned long long physical_utilization = 1, limit = 1, virtual_quantity = 1;
    DMTF_ResourceType rasd_type = DMTF_ResourceType_Storage_Extent;
    uint64_t block_size = 1;
    bool autoalloc = false;
    DMTF_MappingBehavior behaviour = DMTF_MappingBehavior_Dedicated; 
    char *alloc_unit = "byte";
    Access access = Access_Unknown;

    RESET_XEN_ERROR(session->xen);
    if (vm_rec == NULL) {
        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, ("--- Orphaned VBD"));
        return 0;
    }

    _CMPICreateNewDeviceInstanceID(buf, MAX_INSTANCEID_LEN, vm_rec->uuid, vbd_rec->uuid);
    if (vdi_rec) {
        if (vdi_rec->sharable)
            behaviour = DMTF_MappingBehavior_Hard_Affinity;
        physical_utilization = vdi_rec->physical_utilisation;
        limit = vdi_rec->virtual_size;
        virtual_quantity = vdi_rec->virtual_size;
        if (vdi_rec->sr->is_record)
            sr_rec = vdi_rec->sr->u.handle;
        else
            xen_sr_get_record(session->xen, &sr_rec, vdi_rec->sr->u.handle);
    }

    if (vbd_rec->mode == XEN_VBD_MODE_RW)
        access = Access_Read_Write_Supported;
    else
        access = Access_Readable;
    DMTF_ConsumerVisibility virtualized = DMTF_ConsumerVisibility_Virtualized;
    if (vbd_rec->type == XEN_VBD_TYPE_CD) {
        rasd_type = DMTF_ResourceType_DVD_drive;
        alloc_unit = "count";
        virtual_quantity = 1;
    }

    /* Set the CMPIInstance properties from the resource data. */
    /* Key Proerpty first */
    CMSetProperty(inst, "InstanceID",(CMPIValue *)buf, CMPI_chars);

    /* Rest of the keys follow */
    CMSetProperty(inst, "Caption",(CMPIValue *)"Extended Settings for a Xen Virtual Disk", CMPI_chars);
    CMSetProperty(inst, "ResourceType",(CMPIValue *)&rasd_type, CMPI_uint16);
    CMSetProperty(inst, "ResourceSubType",(CMPIValue *)"DMTF:xen:vbd", CMPI_chars); /* required by DMTF */
    CMSetProperty(inst, "Access",(CMPIValue *)&access, CMPI_uint16);
    CMSetProperty(inst, "AddressOnParent",(CMPIValue *)vbd_rec->userdevice, CMPI_chars);
    CMSetProperty(inst, "AllocationUnits",(CMPIValue *)alloc_unit, CMPI_chars);
    CMSetProperty(inst, "AutomaticAllocation",(CMPIValue *)&autoalloc, CMPI_boolean);
    CMSetProperty(inst, "AutomaticDeallocation", (CMPIValue *)&autoalloc, CMPI_boolean);
    CMSetProperty(inst, "ConsumerVisibility", (CMPIValue *)&virtualized, CMPI_uint16);
    CMSetProperty(inst, "VirtualQuantity",(CMPIValue *)&virtual_quantity, CMPI_uint64);
    CMSetProperty(inst, "VirtualQuantityUnits",(CMPIValue *)alloc_unit, CMPI_chars);
    CMSetProperty(inst, "Reservation",(CMPIValue *)&limit, CMPI_uint64);
    CMSetProperty(inst, "Limit",(CMPIValue *)&limit, CMPI_uint64);
    CMSetProperty(inst, "VirtualResourceBlockSize",(CMPIValue *)&block_size, CMPI_uint64);
    CMSetProperty(inst, "HostResourceBlockSize",(CMPIValue *)&block_size, CMPI_uint64);

    /* Setup the Configuration properties */
    if (vdi_rec) {
        CMSetProperty(inst, "ElementName",(CMPIValue *)vdi_rec->name_label, CMPI_chars);
        CMSetProperty(inst, "Description",(CMPIValue *)vdi_rec->name_description, CMPI_chars);
        /* HostResource requires string in WBEM URI Format */
        CMPIObjectPath *disk_ref = disk_image_create_ref(broker, DEFAULT_NS, session, sr_rec->uuid, vdi_rec->uuid);
        if (disk_ref) {
            /* conver objectpath to string form */
            char *disks_uri = xen_utils_CMPIObjectPath_to_WBEM_URI(broker, disk_ref);
            if (disks_uri) {
                CMPIArray *arr = CMNewArray(broker, 1, CMPI_chars, NULL);
                CMSetArrayElementAt(arr, 0, (CMPIValue *) disks_uri, CMPI_chars);
                CMSetProperty(inst, "HostResource", &arr, CMPI_charsA);
            }
        }
        CMSetProperty(inst, "HostExtentName",(CMPIValue *)vdi_rec->uuid, CMPI_chars);
        NameFormat name_format = NameFormat_Other;
        CMSetProperty(inst, "HostExtentNameFormat",(CMPIValue *)&name_format, CMPI_uint16);
        CMSetProperty(inst, "OtherHostExtentNameFormat",(CMPIValue *)"Xen VDI UUID", CMPI_chars);
        NameNamespace name_namespace = NameNamespace_Other;
        CMSetProperty(inst, "HostExtentNameNamespace",(CMPIValue *)&name_namespace, CMPI_uint16);
        CMSetProperty(inst, "OtherHostExtentNameNamespace",(CMPIValue *)"Xen UUID", CMPI_chars);
    }
    CMSetProperty(inst, "MappingBehavior",(CMPIValue *)&behaviour, CMPI_uint16);
    if (sr_rec)
        CMSetProperty(inst, "PoolID", sr_rec->uuid, CMPI_chars);

    // Derived class properties
    CMSetProperty(inst, "Bootable",(CMPIValue *)&vbd_rec->bootable, CMPI_boolean);

    // Others not used
    //CMSetProperty(inst, "Address",(CMPIValue *)<value>, CMPI_chars);
    //CMPIArray *arr = CMNewArray(broker, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *) buf, CMPI_chars);
    //CMSetProperty(inst, "Connection", &arr, CMPI_charsA);
    //CMSetProperty(inst, "ChangeableType",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "ConfigurationName",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "Generation",(CMPIValue *)&<value>, CMPI_uint64);
    //CMSetProperty(inst, "OtherResourceType", (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "HostExtentStartingAddress",(CMPIValue *)&<value>, CMPI_uint64);
    //CMSetProperty(inst, "MaxConsumableResource",(CMPIValue *)<value>, CMPI_uint64);
    //CMSetProperty(inst, "CurrentlyConsumedResource",(CMPIValue *)<value>, CMPI_uint64);
    //CMSetProperty(inst, "ConsumedResourceUnit",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "Parent",(CMPIValue *)<value>, CMPI_chars); /* This is going to be useful for diff disks WBEM URI */ 
    //CMSetProperty(inst, "Weight",(CMPIValue *)&<value>, CMPI_uint32);

    /* Free time */
    if (sr_rec && vdi_rec && !vdi_rec->sr->is_record)
        xen_sr_record_free(sr_rec);

    return CMPI_RC_OK;
}
Exemple #27
0
void setInstProperties(CMPIInstance *ci, XtokProperties *ps)
{
   XtokProperty *np = NULL,*p = ps ? ps->first : NULL;
   CMPIValue val;
   CMPIObjectPath *op;
   CMPIStatus status;
   CMPIType   type = CMPI_null;
   XtokQualifier *nq = NULL,*q;
   XtokQualifiers *qs;
   int rc, n, setq;

   while (p) {
      setq=1;
      switch (p->propType) {
      case typeProperty_Value:
         type = p->valueType;
         if (p->val.value.data.value != NULL && p->val.null==0) {
            if (type == CMPI_string || type == CMPI_chars) {
                char *charsStr = XmlToAsciiStr(p->val.value.data.value);
                val = str2CMPIValue(type, charsStr, NULL);
                free (charsStr);
            }
            else
                val = str2CMPIValue(type, p->val.value.data.value, NULL);
            CMSetProperty(ci, p->name, &val, type);
        native_release_CMPIValue(type, &val);
         }
         else {
            CMSetProperty(ci, p->name, NULL, type);
            setq = 0;
         }
         break;
      case typeProperty_Reference: 
         val=str2CMPIValue(CMPI_ref, NULL, &p->val.ref);
         CMSetProperty(ci, p->name, &val.ref, CMPI_ref);
     CMRelease(val.ref);
         break;
      case typeProperty_Array:
         type = p->valueType;
         if (p->val.array.next > 0) {
            CMPIArray *arr = newCMPIArray(0, type, &status);
            if (p->val.array.max > 0) {
            int i;
               for (i = 0; i < p->val.array.next; ++i)
               {
                   char *valStr = p->val.array.values[i];
                   if (type == CMPI_string || type == CMPI_chars) {
                       char *charsStr = XmlToAsciiStr(valStr);
                       val = str2CMPIValue(type, charsStr, NULL);
                       free (charsStr);
                   }
                   else
                       val = str2CMPIValue(type, valStr, NULL);
                   CMSetArrayElementAt(arr, i, &val, type);
               native_release_CMPIValue(type, &val);
               }
            }
            val.array = arr;
            CMSetProperty(ci, p->name, &val, type | CMPI_ARRAY);
            CMRelease(arr);         /* cloned in property */
         }
         else {
            CMSetProperty(ci, p->name, NULL, p->valueType | CMPI_ARRAY);
            setq = 0;
         }
         break;
      }

      if (setq) {
         qs=&p->val.qualifiers;
         q=qs ? qs->first : NULL;  
         n=0;   
         while (q) {
            if (q->type & CMPI_ARRAY) {
               CMPIArray *arr = NULL;
               arr = newCMPIArray(0, type, NULL);
               type  = q->type & ~CMPI_ARRAY;
               int i;
               if (q->data.array.max) {
                   for (i = 0; i < q->data.array.next; ++i) {
                  val = str2CMPIValue(type, q->data.array.values[i], NULL);
                  CMSetArrayElementAt(arr, i, &val, type);
                  native_release_CMPIValue(type,&val);
               }
               }
               rc = addInstPropertyQualifier(ci, p->name, q->name,
                         (CMPIValue *)&arr, q->type); 
               native_release_CMPIValue(q->type,(CMPIValue*)&arr);
            }
            else {
               val = str2CMPIValue(q->type, q->data.value.data.value, NULL);
               rc= addInstPropertyQualifier(ci, p->name, q->name, &val, q->type);
               native_release_CMPIValue(q->type,&val);
            }   
            nq = q->next; 
            q = nq;
         }
      }

      np = p->next;
      p = np;

   }

   if (ps)
      ps->first = ps->last =  NULL;
}
Exemple #28
0
CMPIInstance * _makeInst_TestClass(
    const CMPIBroker * _broker,
    const CMPIContext * ctx,
    const CMPIObjectPath * ref,
    const char ** properties,
    CMPIStatus * rc,
    unsigned int theKey)
{
    CMPIValue opstatus;
    CMPIValue status;
    CMPIObjectPath * op     = NULL;
    CMPIInstance   * ci     = NULL;
    char * theName          = NULL;
    CMPIArray       *array  = NULL;
    char     **keys      = NULL;
    int              keyCount  = 0;
    opstatus.uint16 = 0; /* Unknown */
    status.uint16 = 2;  /* Enabled */

//
// Initialize Name
//
    theName = calloc(1,20);
    sprintf(theName, "%u", theKey);

//
// Construct ObjectPath
//
    op = CMNewObjectPath(
             _broker,
             CMGetCharsPtr(CMGetNameSpace(ref,rc), NULL),
             _ClassName,
             rc);
    if (CMIsNullObject(op))
    {
        CMSetStatusWithChars(
            _broker,
            rc,
            CMPI_RC_ERR_FAILED,
            "Create CMPIObjectPath failed." );
        goto exit;
    }

//
// Create a new instance and fill it's properties
//
    ci = CMNewInstance( _broker, op, rc);
    if (CMIsNullObject(ci))
    {
        CMSetStatusWithChars(
            _broker,
            rc,
            CMPI_RC_ERR_FAILED,
            "Create CMPIInstance failed." );
        goto exit;
    }

//
// Set property filter
//
    keys = calloc(2,sizeof(char*));
    keys[0] = strdup("theKey");
    CMSetPropertyFilter(ci,properties,(const char**)keys);
    for (;keys[keyCount]!=NULL;keyCount++)
    {
        free((char*)keys[keyCount]);
    }
    free(keys);

//
// Properties of CIM_ManagedElement
//
    CMSetProperty(ci,"Caption","Performance Test class",CMPI_chars);
    CMSetProperty(
        ci,
        "Description",
        "Test class used for all kinds of testing",
        CMPI_chars);
    CMSetProperty(ci,"ElementName",theName,CMPI_chars);

//
// Properties of CIM_ManagedSystemElement
//
// TBD: InstallDate
    array = CMNewArray(_broker,1,CMPI_uint16,rc);
    CMSetArrayElementAt(array,0,&opstatus,CMPI_uint16);
    CMSetProperty(ci,"OperationalStatus",(CMPIValue*)&(array),CMPI_uint16A);

//
// Properties of CIM_EnabledLogicalElement
//
    CMSetProperty( ci, "EnabledState", &status, CMPI_uint16);
    CMSetProperty( ci, "RequestedState", &status, CMPI_uint16);
    CMSetProperty( ci, "EnabledDefault", &status, CMPI_uint16);

//
// Properties of CIM_TestClass
//
    CMSetProperty(ci,"theKey",&theKey , CMPI_uint32 );
    CMSetProperty(ci,"theData",&theKey , CMPI_uint32 );
    CMSetProperty(ci,"theString0","Test Data Number Zero",CMPI_chars);
    CMSetProperty(ci,"theString1","Test Data Number One",CMPI_chars);
    CMSetProperty(ci,"theString2","Test Data Number Two",CMPI_chars);
    CMSetProperty(ci,"theString3","Test Data Number Three",CMPI_chars);
    CMSetProperty(ci,"theString4","Test Data Number Four",CMPI_chars);
    CMSetProperty(ci,"theString5","Test Data Number Five",CMPI_chars);
    CMSetProperty(ci,"theString6","Test Data Number Six",CMPI_chars);
    CMSetProperty(ci,"theString7","Test Data Number Seven",CMPI_chars);
    CMSetProperty(ci,"theString8","Test Data Number Eight",CMPI_chars);
    CMSetProperty(ci,"theString9","Test Data Number Nine",CMPI_chars);

    exit:
    free(theName);
    return ci;
}
static CMPIrc host_set_properties(
    provider_resource *resource, 
    CMPIInstance *inst
    )
{
    local_host_resource *ctx = (local_host_resource *)resource->ctx;

    /* Key properties to be filled in */
    CMSetProperty(inst, "Name",(CMPIValue *)ctx->host_rec->uuid, CMPI_chars);
    CMSetProperty(inst, "CreationClassName",(CMPIValue *)"Xen_HostComputerSystem", CMPI_chars);

    xen_host_metrics metrics = NULL;
    xen_host_get_metrics(resource->session->xen, &metrics, ctx->host);
    xen_host_metrics_record *metrics_rec = NULL;
    if (metrics) {
        xen_host_metrics_get_record(resource->session->xen, &metrics_rec, metrics);
        xen_host_metrics_free(metrics);
    }

    /* Populate the instance's properties with the backend data */
    _set_allowed_operations(resource->broker, ctx->host_rec, inst, "AvailableRequestedStates");

    /* Check other-config (as a cache) */
    char *CN = NULL;
    CN = xen_utils_get_from_string_string_map(ctx->host_rec->other_config, "host_cn");
    /* Did not find the CN in the cache, call out to plugin */
    if (CN) {
        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_DEBUG,("CN back from other_config = %s for host %s", CN, ctx->host));
        CMSetProperty(inst, "CN", (CMPIValue *)CN, CMPI_chars);
    } else {
        /* Get CN name by calling a plugin on the Host */
        //char *CN = NULL;
        xen_string_string_map *args = xen_string_string_map_alloc(0);
        xen_host_call_plugin(resource->session->xen, &CN, ctx->host, "xscim", "read_host_cn", args);
        xen_string_string_map_free(args);
        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_DEBUG,("CN name back from plugin = %s for host %s", CN, ctx->host));
        /* Update the other_config cache */
        xen_host_add_to_other_config(resource->session->xen, ctx->host, "host_cn", CN);
        CMSetProperty(inst, "CN", (CMPIValue *)CN, CMPI_chars);
	// Only need to free CN here because we have made the plugin call.
	// If we've taken the value from the cache it will be free'd when
	// ctx->host_rec is free'd.
        if (CN)
          free(CN);
    } 

    CMSetProperty(inst, "Caption",(CMPIValue *)"XenServer Host", CMPI_chars);
    DMTF_Dedicated dedicated = DMTF_Dedicated_Other;
    CMPIArray *arr = CMNewArray(resource->broker, 1, CMPI_uint16, NULL);
    CMSetArrayElementAt(arr, 0, (CMPIValue *)&dedicated, CMPI_uint16);
    CMSetProperty(inst, "Dedicated",(CMPIValue *)&arr, CMPI_uint16A);
    CMSetProperty(inst, "Description",(CMPIValue *)ctx->host_rec->name_description, CMPI_chars);
    CMSetProperty(inst, "ElementName",(CMPIValue *)ctx->host_rec->name_label, CMPI_chars);
    DMTF_EnabledDefault eDefault = DMTF_EnabledDefault_Enabled;
    CMSetProperty(inst, "EnabledDefault",(CMPIValue *)&eDefault, CMPI_uint16);
    DMTF_EnabledState eState = DMTF_EnabledState_Enabled;
    if (!ctx->host_rec->enabled)
        eState = DMTF_EnabledState_Enabled_but_Offline;
    CMSetProperty(inst, "EnabledState",(CMPIValue *)&eState, CMPI_uint16);
    DMTF_HealthState hState = DMTF_HealthState_OK;
    CMSetProperty(inst, "HealthState",(CMPIValue *)&hState, CMPI_uint16);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(resource->broker, <time_value>);
    //CMSetProperty(inst, "InstallDate",(CMPIValue *)&date_time, CMPI_dateTime);
    CMSetProperty(inst, "NameFormat",(CMPIValue *)DMTF_NameFormat_Other, CMPI_chars);
    DMTF_OperationalStatus opStatus = DMTF_OperationalStatus_OK;
    if (!ctx->host_rec->enabled)
        opStatus = DMTF_OperationalStatus_Stopped;
    CMPIArray *opStatusArr = CMNewArray(resource->broker, 1, CMPI_uint16, NULL);
    CMSetArrayElementAt(opStatusArr, 0, (CMPIValue *)&opStatus, CMPI_uint16);
    CMSetProperty(inst, "OperationalStatus",(CMPIValue *)&opStatusArr, CMPI_uint16A);
    //CMPIArray *arr = CMNewArray(resource->broker, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "OtherDedicatedDescriptions",(CMPIValue *)&arr, CMPI_charsA);
    //CMSetProperty(inst, "OtherEnabledState",(CMPIValue *)<value>, CMPI_chars);
    arr = xen_utils_convert_string_string_map_to_CMPIArray(resource->broker, ctx->host_rec->other_config);
    if(arr)
        CMSetProperty(inst, "OtherConfig",(CMPIValue *)&arr, CMPI_stringA);
    CMPIArray *otheridinfo = CMNewArray(resource->broker, 4, CMPI_chars, NULL);
    char* brand = xen_utils_get_from_string_string_map(ctx->host_rec->software_version, "product_brand");
    char* version = xen_utils_get_from_string_string_map(ctx->host_rec->software_version, "product_version");
    char* build = xen_utils_get_from_string_string_map(ctx->host_rec->software_version, "build_number");
    CMSetArrayElementAt(otheridinfo, 0, (CMPIValue *)ctx->host_rec->address, CMPI_chars);
    CMSetArrayElementAt(otheridinfo, 1, (CMPIValue *)brand, CMPI_chars);
    CMSetArrayElementAt(otheridinfo, 2, (CMPIValue *)version, CMPI_chars);
    CMSetArrayElementAt(otheridinfo, 3, (CMPIValue *)build, CMPI_chars);
    CMSetProperty(inst, "OtherIdentifyingInfo",(CMPIValue *)&otheridinfo, CMPI_charsA);
    CMPIArray *iddesc = CMNewArray(resource->broker, 4, CMPI_chars, NULL);
    CMSetArrayElementAt(iddesc, 0, (CMPIValue *)"IPv4Address", CMPI_chars);
    CMSetArrayElementAt(iddesc, 1, (CMPIValue *)"ProductBrand", CMPI_chars);
    CMSetArrayElementAt(iddesc, 2, (CMPIValue *)"ProductVersion", CMPI_chars);
    CMSetArrayElementAt(iddesc, 3, (CMPIValue *)"BuildNumber", CMPI_chars);
    CMSetProperty(inst, "IdentifyingDescriptions",(CMPIValue *)&iddesc, CMPI_charsA);

    //CMPIArray *arr = CMNewArray(resource->broker, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "PowerManagementCapabilities",(CMPIValue *)&arr, CMPI_uint16A);
    char *owner = xen_utils_get_from_string_string_map(ctx->host_rec->other_config, "owner");
    char *ownercontact = xen_utils_get_from_string_string_map(ctx->host_rec->other_config, "ownercontact");
    if (owner)
        CMSetProperty(inst, "PrimaryOwnerName",(CMPIValue *)owner, CMPI_chars);
    if (ownercontact)
        CMSetProperty(inst, "PrimaryOwnerContact",(CMPIValue *)ownercontact, CMPI_chars);
    DMTF_RequestedState rState = DMTF_RequestedState_Enabled;

    CMSetProperty(inst, "RequestedState",(CMPIValue *)&rState, CMPI_uint16);
    //CMSetProperty(inst, "ResetCapability",(CMPIValue *)&<value>, CMPI_uint16);
    char *serverrole = xen_utils_get_from_string_string_map(ctx->host_rec->other_config, "role");
    if (serverrole) {
        CMPIArray *rolesarr = CMNewArray(resource->broker, 1, CMPI_chars, NULL);
        CMSetArrayElementAt(rolesarr, 0, (CMPIValue *)serverrole, CMPI_chars);
        CMSetProperty(inst, "Roles",(CMPIValue *)&rolesarr, CMPI_charsA);
    }

    if (ctx->host_rec->other_config) {
        char *val = xen_utils_get_from_string_string_map(ctx->host_rec->other_config, "boot_time");
        if (val) {
            time_t time = atol(val);
            CMPIDateTime *start_time = xen_utils_time_t_to_CMPIDateTime(resource->broker, time);
            if (start_time) CMSetProperty(inst, "StartTime",(CMPIValue *)&start_time, CMPI_dateTime);
        }
    }
    CMSetProperty(inst, "Status",(CMPIValue *)DMTF_Status_OK, CMPI_chars);
    //CMPIArray *arr = CMNewArray(resource->broker, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "StatusDescriptions",(CMPIValue *)&arr, CMPI_charsA);
    if (metrics_rec && (metrics_rec->last_updated != 0)) {
        CMPIDateTime *install_time = xen_utils_time_t_to_CMPIDateTime(resource->broker, metrics_rec->last_updated);
        CMSetProperty(inst, "TimeOfLastStateChange",(CMPIValue *)&install_time, CMPI_dateTime);
    }

    /* properties to indicate hosts's time zone. We compute local time zone on this 
    host and assume all hosts are in the same zone since xapi doest report the time zone at this time */
    time_t now = time(NULL);
    struct tm tmnow;
    localtime_r(&now, &tmnow);
    CMSetProperty(inst, "TimeOffset", (CMPIValue *)&tmnow.tm_gmtoff, CMPI_sint32);

    if (metrics_rec)
        xen_host_metrics_record_free(metrics_rec);
    return CMPI_RC_OK;
}
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;
}