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; 
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
static CMPIrc hostcomputer_capabilities_set_properties(
    const CMPIBroker *broker,
    provider_resource *resource, 
    CMPIInstance *inst
    )
{
    xen_host_record *host_rec = ((local_host_resource *)resource->ctx)->host_rec;
    if(host_rec == NULL)
        return CMPI_RC_ERR_FAILED;

    if(CMIsNullObject(inst))
        return CMPI_RC_ERR_FAILED;

    /* Set the CMPIInstance properties from the resource data. */
    char buf[MAX_INSTANCEID_LEN];
    _CMPICreateNewSystemInstanceID(buf, MAX_INSTANCEID_LEN, host_rec->uuid);
    CMSetProperty(inst, "InstanceID", (CMPIValue *)buf, CMPI_chars);
    CMSetProperty(inst, "ElementName", (CMPIValue *)host_rec->name_label, CMPI_chars);

    int nameEditSupported = 0;
    CMSetProperty(inst, "ElementNameEditSupported", (CMPIValue *)&nameEditSupported, CMPI_boolean);

    _set_allowed_operations(broker, host_rec, inst, "RequestedStatesSupported");
    return CMPI_RC_OK;
}
Exemplo n.º 5
0
CMPIValue
makeFromEmbeddedObject(XtokValue value, char *ns)
{
  XtokProperty   *p = NULL;
  CMPIValue       val;
  memset(&val, 0, sizeof(CMPIValue));
  CMPIObjectPath *path;
  CMPIStatus rc = {CMPI_RC_OK, NULL};

  if (value.type == typeValue_Instance) {
    CMPIInstance   *inst;
    XtokInstance   *xtokInstance = value.instance;
    path = TrackedCMPIObjectPath(ns, xtokInstance->className, NULL);
    inst = TrackedCMPIInstance(path, NULL);

    for (p = xtokInstance->properties.first; p; p = p->next) {
      if (p->val.val.value) {
        val = str2CMPIValue(p->valueType, p->val.val, &p->val.ref, NULL, &rc);
        CMSetProperty(inst, p->name, &val, p->valueType);
      }
    }
    val.inst = inst;
  } else if (value.type == typeValue_Class) {
    // not yet supported
  }
  return val;
}
Exemplo n.º 6
0
/**
    Replace an existing Instance from inst, using object-path op as reference.
*/
CMPIStatus TestInstanceProviderModifyInstance  (
    CMPIInstanceMI * mi,
    const CMPIContext * ctx,
    const CMPIResult * rslt,
    const CMPIObjectPath * cop,
    const CMPIInstance * ci,
    const char **properties)
{
    CMPIStatus rc = { CMPI_RC_OK, NULL };
    CMPIInstance * inst;
    CMPIValue val1, val2;
    CMPIData key1, key2, retData1, retInst;
    CMPIObjectPath *obp;
    unsigned int j = 0, flag = 0;
    if(ci)
    {
        inst = CMClone(ci, &rc);
        /* get key from the object-path */
        key1 = CMGetKey(cop, "Identifier", &rc);
        val1.uint8 = key1.value.uint8;
        /* get the value of Message property */
        retData1 = CMGetProperty(inst, "Message", &rc);
        val2.string = retData1.value.string;
        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 then set the properties received from client */
                if(key1.value.uint8 == key2.value.uint8)
                {
                    CMSetProperty(
                        retInst.value.inst,
                        "Message",
                        &val2,
                        CMPI_string);
                    flag = 1;
                }
            }
        }
        CMRelease(inst);
        /*If match fails, throw exception, as instance to be mmodified is not
          found */
        if(!flag)
        {
            CMReturn (CMPI_RC_ERR_NOT_FOUND);
        }
    }
    CMReturnDone (rslt);
    CMReturn (CMPI_RC_OK);
}
Exemplo n.º 7
0
static CMPIrc processor_alloc_capabilities_set_properties(
    const CMPIBroker *broker,
    provider_resource *resource, 
    CMPIInstance *inst)
{
    char buf[MAX_INSTANCEID_LEN];
    xen_host_record *host_rec = ((local_host_resource *)resource->ctx)->host_rec;

    /* Populate the instance's properties with the backend data */
    CMSetProperty(inst, "Caption",(CMPIValue *)"Xen Processor Allocation Capabilities", CMPI_chars);
    CMSetProperty(inst, "Description",(CMPIValue *) "Xen Processor Allocation Capabilities", CMPI_chars);
    CMSetProperty(inst, "ElementName",(CMPIValue *)host_rec->name_label, CMPI_chars);
    _CMPICreateNewDeviceInstanceID(buf, sizeof(buf)/sizeof(buf[0])-1, host_rec->uuid, "ProcessorAllocationCapabilities");
    CMSetProperty(inst, "InstanceID",(CMPIValue *)buf, CMPI_chars);
    //CMSetProperty(inst, "OtherResourceType",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "RequestTypesSupported",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "ResourceSubType",(CMPIValue *)<value>, CMPI_chars);
    int resourceType = DMTF_ResourceType_Processor;
    CMSetProperty(inst, "ResourceType",(CMPIValue *)&resourceType, CMPI_uint16);
    int sharingMode = DMTF_SharingMode_Dedicated;
    CMSetProperty(inst, "SharingMode",(CMPIValue *)&sharingMode, CMPI_uint16);
    //CMPIArray *arr = CMNewArray(broker, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "SupportedAddStates",(CMPIValue *)&arr, CMPI_uint16A);
    //CMPIArray *arr = CMNewArray(broker, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "SupportedRemoveStates",(CMPIValue *)&arr, CMPI_uint16A);

    return CMPI_RC_OK;
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
CMPIrc memory_allocation_cap_set_properties(
    provider_resource *resource, 
    CMPIInstance *inst)
{
    char buf[MAX_INSTANCEID_LEN];
    local_host_resource *ctx = resource->ctx;

    /* Populate the instance's properties with the backend data */
    CMSetProperty(inst, "Caption",(CMPIValue *)"Xen Memory Allocation Capabilities", CMPI_chars);
    CMSetProperty(inst, "Description",(CMPIValue *)"Memory Allocation Capabilities for Xen", CMPI_chars);
    CMSetProperty(inst, "ElementName",(CMPIValue *)ctx->host_rec->name_label, CMPI_chars);
    _CMPICreateNewDeviceInstanceID(buf, sizeof(buf)/sizeof(buf[0])-1, ctx->host_rec->uuid, "MemoryAllocationCapabilities");
    CMSetProperty(inst, "InstanceID",(CMPIValue *)buf, CMPI_chars);
    //CMSetProperty(inst, "OtherResourceType",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "RequestTypesSupported",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "ResourceSubType",(CMPIValue *)<value>, CMPI_chars);
    int resourceType = DMTF_ResourceType_Memory;
    CMSetProperty(inst, "ResourceType",(CMPIValue *)&resourceType, CMPI_uint16);
    int sharingMode = DMTF_SharingMode_Dedicated;
    CMSetProperty(inst, "SharingMode",(CMPIValue *)&sharingMode, CMPI_uint16);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "SupportedAddStates",(CMPIValue *)&arr, CMPI_uint16A);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "SupportedRemoveStates",(CMPIValue *)&arr, CMPI_uint16A);

    return CMPI_RC_OK;

}
Exemplo n.º 10
0
static CMPIrc processor_metric_set_properties(
    const CMPIBroker *broker,
    provider_resource *resource, 
    xen_host_record *host_rec,
    CMPIInstance *inst)
{
    char buf[MAX_INSTANCEID_LEN];
    xen_host_cpu_record *cpu_rec = (xen_host_cpu_record *)resource->ctx;
    _CMPICreateNewDeviceInstanceID(buf, MAX_INSTANCEID_LEN, host_rec->uuid, cpu_rec->uuid);
    CMSetProperty(inst, "InstanceID",(CMPIValue *)buf, CMPI_chars);

    // Is this the MetricsDefinitionID or the classname ?
    snprintf(buf, MAX_INSTANCEID_LEN, "%sDef", resource->classname);
    CMSetProperty(inst, "MetricDefinitionId",(CMPIValue *)buf, CMPI_chars);
    //CMSetProperty(inst, "BreakdownDimension",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "BreakdownValue",(CMPIValue *)<value>, CMPI_chars);
    CMSetProperty(inst, "Caption",(CMPIValue *)"Xen Host Processor Metrics", CMPI_chars);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(_BROKER, &<time_value>);
    //CMSetProperty(inst, "Duration",(CMPIValue *)&date_time, CMPI_dateTime);
    //CMSetProperty(inst, "Generation",(CMPIValue *)&<value>, CMPI_uint64);
    CMSetProperty(inst, "ElementName",(CMPIValue *)host_rec->uuid, CMPI_chars);
    CMSetProperty(inst, "MeasuredElementName",(CMPIValue *)host_rec->name_label, CMPI_chars);

    xen_host host = NULL;
    double load_percentage = 0.0;
    xen_host_get_by_uuid(resource->session->xen, &host, host_rec->uuid);
    if(host) {

        snprintf(buf, MAX_INSTANCEID_LEN, "cpu%" PRId64, cpu_rec->number);
        xen_host_query_data_source(resource->session->xen, &load_percentage, host, buf);
        CMSetProperty(inst, "Description",(CMPIValue *)buf, CMPI_chars);
        xen_host_free(host);
    }
    snprintf(buf, MAX_INSTANCEID_LEN, "%f", (load_percentage*100));
    CMSetProperty(inst, "MetricValue",(CMPIValue *)buf, CMPI_chars);

    CMPIDateTime *date_time = xen_utils_CMPIDateTime_now(broker);
    CMSetProperty(inst, "TimeStamp",(CMPIValue *)&date_time, CMPI_dateTime);
    bool vol=true;
    CMSetProperty(inst, "Volatile",(CMPIValue *)&vol, CMPI_boolean);
    return CMPI_RC_OK;
}
Exemplo n.º 11
0
/************************************************************************
 * 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;
}
Exemplo n.º 12
0
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);
}
Exemplo n.º 13
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;
}
Exemplo n.º 14
0
static CMPI_THREAD_RETURN CMPI_THREAD_CDECL
thread (void *args)
{
  CMPIString *str = NULL;
  CMPIStatus rc = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Eval = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Clone = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Inst = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Pred = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Array = { CMPI_RC_OK, NULL };
  CMPIStatus rc_CMGetPropertyAt = { CMPI_RC_OK, NULL };

  CMPIString *type = NULL;
  CMPISelectExp *clone = NULL;
  CMPIBoolean evalRes;
  CMPIInstance *inst = NULL;
  CMPIObjectPath *objPath = NULL;
  CMPIString *name = NULL;
  CMPIData prop_data = { 0, CMPI_null, {0} };
  CMPIData data = { 0, CMPI_null, {0} };
  CMPIArray *projection = NULL;
  /* General purpose counters */
  unsigned int idx;
  CMPICount cnt;
  /* Select Condition and sub conditions */
  CMPISelectCond *cond = NULL;
  int sub_type;
  CMPISubCond *subcnd = NULL;
  /* Predicate operations */
  CMPICount pred_cnt;
  unsigned int pred_idx;
  CMPIPredicate *pred = NULL;
  CMPIType pred_type;
  CMPIPredOp pred_op;
  CMPIString *left_side = NULL;
  CMPIString *right_side = NULL;
  /* Thread specific data, passed in via arguments. This could also
     be passed via thread specific data.. */
  void **arguments = (void **) args;
  CMPIContext *ctx;
  CMPISelectExp *se;
  char *ns;
  CMPIBroker *broker;

 // Copy over the CMPISelectExp, CMPIContext, CMPIBroker and the ns from the argument. 
  se = (CMPISelectExp *)arguments[0];
  ctx = (CMPIContext *)arguments[1];
  broker = (CMPIBroker *)arguments[2];
  ns = (char *)arguments[3];

  free(arguments);

  _thread_active = 1;
  // Get the CMPIContext and attach it to this thread.
  rc = CBAttachThread (broker, ctx);

  // Wait until we get the green signal.
  while (_thread_runs == 0)
    {
	broker->xft->threadSleep(1000);
    }

  //PROV_LOG_OPEN (_IndClassName, _ProviderLocation);
  PROV_LOG ("--- CBAttachThread callled.");
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));

  PROV_LOG ("--- %s CMPI thread(void *) running",_IndClassName);


  PROV_LOG ("-- #1 Clone");
  clone = CMClone (se, &rc_Clone);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Clone), (rc_Clone.msg == 0) ? "" : CMGetCharPtr(rc_Clone.msg));
  if (clone)
    CMRelease (clone);

  /*
     This functionality is not used in indication providers, but instead in
     ExecQuery provider API (instance providers). But for the sake
     of completness this functionality is also used here. */

  PROV_LOG ("-- #1.1 CMNewSelectExp");
  str = CMGetSelExpString (se, &rc);
  clone =
    //CMPI_CQL_NewSelectExp (broker, CMGetCharPtr (str), "CIMxCQL",
    CMNewSelectExp (broker, CMGetCharPtr (str), "CIM:CQL",
                    &projection, &rc_Clone);

  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Clone), (rc_Clone.msg == 0) ? "" : CMGetCharPtr(rc_Clone.msg));
  if (clone)
    {
      if (projection)
        {
          PROV_LOG ("--- #1.2 Projection list is: ");
          cnt = CMGetArrayCount (projection, &rc_Array);
          PROV_LOG ("---- %s, [%s]", strCMPIStatus (rc_Array),(rc_Array.msg == 0) ? "" : CMGetCharPtr(rc_Array.msg));
          PROV_LOG ("--- #1.3 CMGetArrayCount, %d", cnt);
          for (idx = 0; idx < cnt; idx++)
            {
              PROV_LOG ("--- #1.4 CMGetArrayElementAt");
              data = CMGetArrayElementAt (projection, idx, &rc_Array);
              PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Array), (rc_Array.msg == 0) ? "" : CMGetCharPtr(rc_Array.msg));
              PROV_LOG ("---- type is : %d", data.type);
              if (data.type == CMPI_chars)
                {
                  PROV_LOG ("---- %s (chars)", data.value.chars);
                }
              if (data.type == CMPI_string)
                {
                  PROV_LOG ("---- %s (string)",
                            CMGetCharPtr (data.value.string));
                }
            }
        }
      else
        {
          PROV_LOG
            ("--- #1.2 No projection list, meaning it is SELECT * .... ");
        }
    }
  // This is how an indication provider would work.
  //  Create an objectpath + instance and use CMEvaluateSelExp
  //  OR
  //  use CMEvaluateSelExpUsingAccessor and pass in the function that would
  // provide the properties values.

  PROV_LOG ("-- #2 MakeObjectPath");
  // Create instance

  objPath = make_ObjectPath (broker, _Namespace, _IndClassName);
  type = CDGetType (broker, objPath, &rc_Inst);
  PROV_LOG ("---- %s (%s) [%s]", CMGetCharPtr (type), strCMPIStatus (rc_Inst),(rc_Inst.msg == 0) ? "" : CMGetCharPtr(rc_Inst.msg));
  CMRelease (type);

  PROV_LOG ("-- #3 Instance");
  inst = CMNewInstance (broker, objPath, &rc_Inst);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Inst), (rc_Inst.msg == 0) ? "" : CMGetCharPtr(rc_Inst.msg));

  if (rc_Inst.rc == CMPI_RC_ERR_NOT_FOUND)
    {
      PROV_LOG (" --- Class %s is not found in the %s namespace!",
                _IndClassName, _Namespace);
      PROV_LOG (" --- Aborting!!! ");
      goto exit;
    }

  type = CDGetType (broker, inst, &rc_Inst);
  if (type)
    {
      PROV_LOG ("---- %s (%s) [%s]", CMGetCharPtr (type), strCMPIStatus (rc_Inst),(rc_Inst.msg == 0) ? "" : CMGetCharPtr(rc_Inst.msg));
      CMRelease (type);
    }

  PROV_LOG ("- CMGetPropertyCount: %d", CMGetPropertyCount (inst, &rc));
  // Set each property.
  for (idx = 0; idx < CMGetPropertyCount (inst, &rc); idx++)
    {
      prop_data = CMGetPropertyAt (inst, idx, &name, &rc_CMGetPropertyAt);
      // Really dumb way of doing it. Just set each property with its own property name.
      if (prop_data.type == CMPI_string)
        {
          CMSetProperty (inst, CMGetCharPtr (name), CMGetCharPtr (name),
                         CMPI_chars);
        }
      prop_data = CMGetPropertyAt (inst, idx, &name, &rc_CMGetPropertyAt);

      PROV_LOG ("-- %d: %s(%s: %s: %s) [%s]", idx,
                CMGetCharPtr (name),
                strCMPIType (prop_data.type),
                strCMPIValueState (prop_data.state),
                strCMPIValue (prop_data.value),
                strCMPIStatus (rc_CMGetPropertyAt));

    }

  PROV_LOG ("-- #4 Evaluate using instance");
  evalRes = CMEvaluateSelExp (se, inst, &rc_Eval);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Eval), (rc_Eval.msg == 0) ? "" : CMGetCharPtr(rc_Eval.msg));
  if (evalRes == CMPI_true)
    {
      PROV_LOG ("--- True, sending indication");
      rc_Eval = CBDeliverIndication (broker, ctx, _Namespace, inst);
      PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Eval), (rc_Eval.msg == 0) ? "" : CMGetCharPtr(rc_Eval.msg));
    }
  else
    {
      PROV_LOG ("--- False");
    }

  PROV_LOG ("-- #4.1 Evalute using accessor");
  evalRes =
    CMEvaluateSelExpUsingAccessor (se, instance_accessor, broker, &rc_Eval);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Eval), (rc_Eval.msg == 0) ? "" : CMGetCharPtr(rc_Eval.msg));
  if (evalRes == CMPI_true)
    {
      PROV_LOG ("--- True, but not sending indication");
    }
  else
    {
      PROV_LOG ("--- False");
    }

  PROV_LOG ("-- #5 CMGetSelExpString");
  str = CMGetSelExpString (se, &rc);
  type = CDGetType (broker, str, &rc_Inst);
  if (type != NULL)
    {
      PROV_LOG ("---- %s (%s) [%s]", CMGetCharPtr (type), strCMPIStatus (rc_Inst), (rc_Inst.msg == 0) ? "" : CMGetCharPtr(rc_Inst.msg));
      CMRelease (type);
    }

  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
  PROV_LOG ("-- #5.1 Query is [%s]", CMGetCharPtr (str));
  PROV_LOG ("-- #5.2 Query is [%s]", ns);


  PROV_LOG ("-- #6 Continue evaluating using GetDOC");
  {
    cond = CMGetDoc (se, &rc);
    PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
    if (cond != NULL)
      {

        PROV_LOG ("--- #6.1 CMGetSubCondCountAndType ");
        cnt = CMGetSubCondCountAndType (cond, &sub_type, &rc);
        PROV_LOG ("---- %s %s", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));


        PROV_LOG ("---- Number of disjunctives: %d, Type: %X", cnt, sub_type);

        /* Parsing the disjunctives */
        for (idx = 0; idx < cnt; idx++)
          {
            PROV_LOG ("--- #6.2 CMGetSubCondAt @ %d ", idx);
            subcnd = CMGetSubCondAt (cond, idx, &rc);
            PROV_LOG ("---- %s [%s]", strCMPIStatus (rc),(rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));

            PROV_LOG ("--- #6.3 CMGetPredicateCount");
            pred_cnt = CMGetPredicateCount (subcnd, &rc);
            PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
            PROV_LOG ("---- Number of predicates in the conjuctives: %d",
                      pred_cnt);

            /* Parsing throught conjuctives */
            for (pred_idx = 0; pred_idx < pred_cnt; pred_idx++)
              {
                PROV_LOG ("--- #6.4 CMGetPredicateAt, %d", pred_idx);
                pred = CMGetPredicateAt (subcnd, pred_idx, &rc);

                PROV_LOG ("---- %s [%s]", strCMPIStatus (rc),(rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
                PROV_LOG ("--- #6.4 CMGetPredicateData");
                rc = CMGetPredicateData (pred,
                                         &pred_type,
                                         &pred_op, &left_side, &right_side);
                PROV_LOG ("---- %s [%s]", strCMPIStatus (rc),(rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));

                PROV_LOG ("----- Type: %s , CMPIPredOp: %s, LS: %s, RS: %s",
                          strCMPIType (pred_type), strCMPIPredOp (pred_op),
                          CMGetCharPtr (left_side),
                          CMGetCharPtr (right_side));

                PROV_LOG ("--- #6.5 Evaluate using predicate");
#ifdef CMPI_VER_100
// The CMEvaluatePredicate is gone in the CMPI 1.0 standard.
                evalRes =
                  CMEvaluatePredicateUsingAccessor (pred, instance_accessor,
                                                    NULL, &rc_Pred);
#else
                // One can also evaluate this specific predicate
                evalRes =
                  CMEvaluatePredicate (pred, "PredicateEvaluation",
                                       CMPI_chars, &rc_Pred);
#endif
                PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Pred), (rc_Pred.msg == 0) ? "" : CMGetCharPtr(rc_Pred.msg));

                if (evalRes == CMPI_true)
                  {
                    PROV_LOG ("--- True");
                  }
                else
                  {
                    PROV_LOG ("--- False");
                  }
              }

          }
      }
  }
  PROV_LOG ("-- #7 GetCOD");
  {
    cond = CMGetCod (se, &rc);
    PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
    /* Currently this is not supported in Pegasus. */
    if (cond != NULL)
      {
      }
  }
exit:
  PROV_LOG ("--- CBDetachThread called");
  rc = CBDetachThread (broker, ctx);
  free (ns);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));

  PROV_LOG ("--- %s CMPI thread(void *) exited", _IndClassName);

  _thread_active = 0;
  _thread_runs = 0;
  return (CMPI_THREAD_RETURN) 0;
}
Exemplo n.º 15
0
static CMPIrc hostprocessor_set_properties(provider_resource *resource, 
                                    xen_host_record *host_rec, 
                                    CMPIInstance *inst)
{
    char buf[MAX_INSTANCEID_LEN];
    xen_host_cpu_record *cpu_rec = (xen_host_cpu_record *)resource->ctx;
    _CMPICreateNewDeviceInstanceID(buf, sizeof(buf), host_rec->uuid, cpu_rec->uuid);
    CMSetProperty(inst, "DeviceID",(CMPIValue *)buf, CMPI_chars);
    CMSetProperty(inst, "SystemCreationClassName",(CMPIValue *)"Xen_HostComputerSystem", CMPI_chars);
    CMSetProperty(inst, "SystemName",(CMPIValue *)host_rec->uuid, CMPI_chars);
    CMSetProperty(inst, "CreationClassName",(CMPIValue *)"Xen_HostProcessor", CMPI_chars);

    /* Populate the instance's properties with the backend data */
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "AdditionalAvailability",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "AddressWidth",(CMPIValue *)&<value>, CMPI_uint16);
    DMTF_Availability avail = DMTF_Availability_Running_Full_Power;
    CPUStatus cpuStatus =  CPUStatus_CPU_Enabled;
    DMTF_EnabledState eState = DMTF_EnabledState_Enabled;
    if(!host_rec->enabled)
    {
        avail = DMTF_Availability_Off_Line;
        cpuStatus = CPUStatus_Other;
        eState = DMTF_EnabledState_Disabled;
    }

    CMSetProperty(inst, "Availability",(CMPIValue *)&avail, CMPI_uint16);
    CMSetProperty(inst, "Caption",(CMPIValue *)"Xen Host Processor", CMPI_chars);
    CMSetProperty(inst, "CPUStatus",(CMPIValue *)&cpuStatus, CMPI_uint16);
    CMSetProperty(inst, "CurrentClockSpeed",(CMPIValue *)&cpu_rec->speed, CMPI_uint32);
    //CMSetProperty(inst, "DataWidth",(CMPIValue *)&<value>, CMPI_uint16);
    CMSetProperty(inst, "Description",(CMPIValue *)cpu_rec->modelname, CMPI_chars);
    char model[4];

#if XENAPI_VERSION > 400
    sprintf(model, "%3" PRId64, cpu_rec->model);
#endif
    CMSetProperty(inst, "ElementName",(CMPIValue *)cpu_rec->vendor, CMPI_chars);
    DMTF_EnabledDefault eDefault = DMTF_EnabledDefault_Enabled;
    CMSetProperty(inst, "EnabledDefault",(CMPIValue *)&eDefault, CMPI_uint16);
    CMSetProperty(inst, "EnabledState",(CMPIValue *)&eState, CMPI_uint16);
    //CMSetProperty(inst, "ErrorCleared",(CMPIValue *)&<value>, CMPI_boolean);
    //CMSetProperty(inst, "ErrorDescription",(CMPIValue *)<value>, CMPI_chars);

#if XENAPI_VERSION > 400
    Family family = get_processor_family(cpu_rec->family, cpu_rec->vendor, cpu_rec->modelname);
    CMSetProperty(inst, "Family",(CMPIValue *)&family, CMPI_uint16);
#endif
    DMTF_HealthState hState = DMTF_HealthState_OK;
    CMSetProperty(inst, "HealthState",(CMPIValue *)&hState, CMPI_uint16);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "IdentifyingDescriptions",(CMPIValue *)&arr, CMPI_charsA);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(_BROKER, &<time_value>);
    //CMSetProperty(inst, "InstallDate",(CMPIValue *)&date_time, CMPI_dateTime);
    //CMSetProperty(inst, "LastErrorCode",(CMPIValue *)&<value>, CMPI_uint32);
    int load_percentage = cpu_rec->utilisation * 100;
    CMSetProperty(inst, "LoadPercentage", (CMPIValue *) &load_percentage, CMPI_uint16);
    CMSetProperty(inst, "MaxClockSpeed",(CMPIValue *)&cpu_rec->speed, CMPI_uint32);
    //CMSetProperty(inst, "MaxQuiesceTime",(CMPIValue *)&<value>, CMPI_uint64);
    CMSetProperty(inst, "Name",(CMPIValue *)cpu_rec->vendor, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "OperationalStatus",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "OtherEnabledState",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "OtherFamilyDescription",(CMPIValue *)<value>, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "OtherIdentifyingInfo",(CMPIValue *)&arr, CMPI_charsA);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "PowerManagementCapabilities",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "PowerManagementSupported",(CMPIValue *)&<value>, CMPI_boolean);
    //CMSetProperty(inst, "PowerOnHours",(CMPIValue *)&<value>, CMPI_uint64);
    //CMSetProperty(inst, "RequestedState",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "Role",(CMPIValue *)<value>, CMPI_chars);
    CMSetProperty(inst, "Status",(CMPIValue *)DMTF_Status_OK, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "StatusDescriptions",(CMPIValue *)&arr, CMPI_charsA);
    //CMSetProperty(inst, "StatusInfo",(CMPIValue *)&<value>, CMPI_uint16);
    CMSetProperty(inst, "Stepping",(CMPIValue *)cpu_rec->stepping, CMPI_chars);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(_BROKER, &<time_value>);
    //CMSetProperty(inst, "TimeOfLastStateChange",(CMPIValue *)&date_time, CMPI_dateTime);
    //CMSetProperty(inst, "TotalPowerOnHours",(CMPIValue *)&<value>, CMPI_uint64);
    CMSetProperty(inst, "UniqueID",(CMPIValue *)cpu_rec->uuid, CMPI_chars);
    //CMSetProperty(inst, "UpgradeMethod",(CMPIValue *)&<value>, CMPI_uint16);

    if(!cpu_rec->host->is_record)
        xen_host_record_free(host_rec);

    return CMPI_RC_OK;
}
Exemplo n.º 16
0
static CMPIrc hostmemory_set_properties(
    provider_resource *resource,
    CMPIInstance *inst
    )
{
    char buf[MAX_INSTANCEID_LEN];
    local_host_resource *ctx = resource->ctx;
    _CMPICreateNewDeviceInstanceID(buf, sizeof(buf), ctx->host_rec->uuid, "Memory");
    CMSetProperty(inst, "DeviceID",(CMPIValue *)buf, CMPI_chars);
    CMSetProperty(inst, "CreationClassName",(CMPIValue *)"Xen_HostMemory", CMPI_chars);
    CMSetProperty(inst, "SystemCreationClassName",(CMPIValue *)"Xen_HostComputerSystem", CMPI_chars);
    CMSetProperty(inst, "SystemName",(CMPIValue *)ctx->host_rec->uuid, CMPI_chars);

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

    /* Populate the instance's properties with the backend data */

    //CMSetProperty(inst, "Access",(CMPIValue *)&<value>, CMPI_uint16);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "AdditionalAvailability",(CMPIValue *)&arr, CMPI_uint16A);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint8, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint8);
    //CMSetProperty(inst, "AdditionalErrorData",(CMPIValue *)&arr, CMPI_uint8A);
    //CMSetProperty(inst, "Availability",(CMPIValue *)&<value>, CMPI_uint16);
    uint64_t blockSize = 1;
    CMSetProperty(inst, "BlockSize",(CMPIValue *)&blockSize, CMPI_uint64);
    CMSetProperty(inst, "Caption",(CMPIValue *)"Xen Host Memory", CMPI_chars);
    CMSetProperty(inst, "ConsumableBlocks",(CMPIValue *)&metrics_rec->memory_free, CMPI_uint64);
    //CMSetProperty(inst, "CorrectableError",(CMPIValue *)&<value>, CMPI_boolean);
    //CMSetProperty(inst, "DataOrganization",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "DataRedundancy",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "DeltaReservation",(CMPIValue *)&<value>, CMPI_uint8);
    CMSetProperty(inst, "Description",(CMPIValue *)ctx->host_rec->name_description, CMPI_chars);
    CMSetProperty(inst, "ElementName",(CMPIValue *)ctx->host_rec->name_label, CMPI_chars);
    //CMSetProperty(inst, "EnabledDefault",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "EnabledState",(CMPIValue *)&<value>, CMPI_uint16);
    CMSetProperty(inst, "EndingAddress",(CMPIValue *)&metrics_rec->memory_total, CMPI_uint64);
    //CMSetProperty(inst, "ErrorAccess",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "ErrorAddress",(CMPIValue *)&<value>, CMPI_uint64);
    //CMSetProperty(inst, "ErrorCleared",(CMPIValue *)&<value>, CMPI_boolean);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint8, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint8);
    //CMSetProperty(inst, "ErrorData",(CMPIValue *)&arr, CMPI_uint8A);
    //CMSetProperty(inst, "ErrorDataOrder",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "ErrorDescription",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "ErrorInfo",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "ErrorMethodology",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "ErrorResolution",(CMPIValue *)&<value>, CMPI_uint64);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(_BROKER, <time_value>);
    //CMSetProperty(inst, "ErrorTime",(CMPIValue *)&date_time, CMPI_dateTime);
    //CMSetProperty(inst, "ErrorTransferSize",(CMPIValue *)&<value>, CMPI_uint32);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "ExtentStatus",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "HealthState",(CMPIValue *)&<value>, CMPI_uint16);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "IdentifyingDescriptions",(CMPIValue *)&arr, CMPI_charsA);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(_BROKER, <time_value>);
    //CMSetProperty(inst, "InstallDate",(CMPIValue *)&date_time, CMPI_dateTime);
    //CMSetProperty(inst, "IsBasedOnUnderlyingRedundancy",(CMPIValue *)&<value>, CMPI_boolean);
    //CMSetProperty(inst, "LastErrorCode",(CMPIValue *)&<value>, CMPI_uint32);
    //CMSetProperty(inst, "MaxQuiesceTime",(CMPIValue *)&<value>, CMPI_uint64);
    //CMSetProperty(inst, "Name",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "NameFormat",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "NameNamespace",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "NoSinglePointOfFailure",(CMPIValue *)&<value>, CMPI_boolean);
    CMSetProperty(inst, "NumberOfBlocks",(CMPIValue *)&metrics_rec->memory_total, CMPI_uint64);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "OperationalStatus",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "OtherEnabledState",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "OtherErrorDescription",(CMPIValue *)<value>, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "OtherIdentifyingInfo",(CMPIValue *)&arr, CMPI_charsA);
    //CMSetProperty(inst, "OtherNameFormat",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "OtherNameNamespace",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "PackageRedundancy",(CMPIValue *)&<value>, CMPI_uint16);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "PowerManagementCapabilities",(CMPIValue *)&arr, CMPI_uint16A);
    //CMSetProperty(inst, "PowerManagementSupported",(CMPIValue *)&<value>, CMPI_boolean);
    //CMSetProperty(inst, "PowerOnHours",(CMPIValue *)&<value>, CMPI_uint64);
    bool primordial = true;
    CMSetProperty(inst, "Primordial",(CMPIValue *)&primordial, CMPI_boolean);
    //CMSetProperty(inst, "Purpose",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "RequestedState",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "SequentialAccess",(CMPIValue *)&<value>, CMPI_boolean);
    uint64_t startingAddress = 0;
    CMSetProperty(inst, "StartingAddress",(CMPIValue *)&startingAddress, CMPI_uint64);
    CMSetProperty(inst, "Status",(CMPIValue *)DMTF_Status_OK, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "StatusDescriptions",(CMPIValue *)&arr, CMPI_charsA);
    //CMSetProperty(inst, "StatusInfo",(CMPIValue *)&<value>, CMPI_uint16);
    //CMSetProperty(inst, "SystemLevelAddress",(CMPIValue *)&<value>, CMPI_boolean);
    //CMPIDateTime *date_time = xen_utils_time_t_to_CMPIDateTime(_BROKER, <time_value>);
    //CMSetProperty(inst, "TimeOfLastStateChange",(CMPIValue *)&date_time, CMPI_dateTime);
    //CMSetProperty(inst, "TotalPowerOnHours",(CMPIValue *)&<value>, CMPI_uint64);
    //CMSetProperty(inst, "Volatile",(CMPIValue *)&<value>, CMPI_boolean);

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

    return CMPI_RC_OK;
}
Exemplo n.º 17
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;
}
Exemplo n.º 18
0
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);
}
Exemplo n.º 19
0
int
main()
{
  CIMCEnv        *ce;
  char           *msg = NULL;
  int             rc;
  CIMCStatus      status;
  CIMCClient     *client;
  CIMCObjectPath *op,
                 *objectpath_r;
  CMPIConstClass *clas;
  CMPIInstance   *instance;
  CIMCString     *path;
  CMPIString     *classname;
  CIMCData        data;
  CMPIData        cdata;
  char           *cim_host,
                 *cim_host_passwd,
                 *cim_host_userid,
                 *cim_host_port;
  int             i = 0;
  int             retc = 0;
  int             count = 0;
  int             numproperties = 0;
  CMPIString     *propertyname;
  char           *cv;

  /*
   * Setup a connection to the CIMOM 
   */
  cim_host = getenv("CIM_HOST");
  if (cim_host == NULL)
    cim_host = "localhost";
  cim_host_userid = getenv("CIM_HOST_USERID");
  if (cim_host_userid == NULL)
    cim_host_userid = "root";
  cim_host_passwd = getenv("CIM_HOST_PASSWD");
  if (cim_host_passwd == NULL)
    cim_host_passwd = "password";
  cim_host_port = getenv("CIM_HOST_PORT");
  if (cim_host_port == NULL)
    cim_host_port = "5988";

  printf(" Testing CreateInstance \n");
  printf(" using SfcbLocal interface : host = %s userid = %s\n",
         cim_host, cim_host_userid);
  ce = NewCIMCEnv("SfcbLocal", 0, &rc, &msg);

  if (ce == NULL) {
    printf
        (" local connect failed call to NewCIMCEnv rc = %d , message = [%s] \n",
         retc, msg);
    return 1;
  }

  client =
      ce->ft->connect(ce, cim_host, "http", cim_host_port, cim_host_userid,
                      cim_host_passwd, &status);

  op = ce->ft->newObjectPath(ce, "root/cimv2", "TEST_LabeledLineage",
                             &status);

  instance = ce->ft->newInstance(ce, op, NULL);
  CMSetProperty(instance, "label", "Mitchelle", CMPI_chars);

  objectpath_r =
      (CIMCObjectPath *) client->ft->createInstance(client, op, instance,
                                                    &status);

  /*
   * Print the results 
   */
  printf("createInstance() rc=%d, msg=%s\n",
         status.rc, (status.msg) ? (char *) status.msg->hdl : NULL);
  if (!status.rc) {
    printf("result:\n");
    showObjectPath(objectpath_r);
  }

  if (instance)
    CMRelease(instance);
  if (op)
    CMRelease(op);
  if (objectpath_r)
    CMRelease(objectpath_r);
  if (status.msg)
    CMRelease(status.msg);

  return 0;
}
Exemplo n.º 20
0
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;
}
Exemplo n.º 21
0
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);
}
/************************************************************************
 * 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 CMPIrc xen_resource_set_properties(
    provider_resource *prov_res, 
    CMPIInstance *inst
    )
{
    local_net_cap_resource *resource = (local_net_cap_resource *)prov_res->ctx;
    /* Populate the instance's properties with the backend data */
    //CMSetProperty(inst, "Address",(CMPIValue *)<value>, CMPI_chars);
    CMSetProperty(inst, "AllocationUnits",(CMPIValue *)"count", CMPI_chars);
    //CMSetProperty(inst, "AutomaticAllocation",(CMPIValue *)&<value>, CMPI_boolean);
    //CMSetProperty(inst, "AutomaticDeallocation",(CMPIValue *)&<value>, CMPI_boolean);
    CMSetProperty(inst, "Caption",(CMPIValue *)"Xen Network Connection Allocation capabilities", CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "Connection",(CMPIValue *)&arr, CMPI_charsA);
    int consumerVisibilty = DMTF_ConsumerVisibility_Virtualized; 
    CMSetProperty(inst, "ConsumerVisibility",(CMPIValue *)&consumerVisibilty, CMPI_uint16);
    //CMSetProperty(inst, "Description",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "ElementName",(CMPIValue *)<value>, CMPI_chars);
    //CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_chars, NULL);
    //CMSetArrayElementAt(arr, 0, (CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(instance, "HostResource",(CMPIValue *)&arr, CMPI_charsA);
    CMSetProperty(inst, "InstanceID",(CMPIValue *)resource->instanceid, CMPI_chars);
    CMSetProperty(inst, "Limit",(CMPIValue *)&(resource->limit), CMPI_uint64);
    int mappingBehavior = DMTF_MappingBehavior_Dedicated;
    CMSetProperty(inst, "MappingBehavior",(CMPIValue *)&mappingBehavior, CMPI_uint16);
    //CMSetProperty(inst, "OtherResourceType",(CMPIValue *)<value>, CMPI_chars);
    //CMSetProperty(inst, "Parent",(CMPIValue *)<value>, CMPI_chars);
    CMSetProperty(inst, "PoolID",(CMPIValue *)resource->poolid, CMPI_chars);
    CMSetProperty(inst, "Reservation",(CMPIValue *)&(resource->reservation), CMPI_uint64);
    //CMSetProperty(inst, "ResourceSubType",(CMPIValue *)<value>, CMPI_chars);
    int type = DMTF_ResourceType_Ethernet_Connection;
    CMSetProperty(inst, "ResourceType",(CMPIValue *)&type, CMPI_uint16);
    CMSetProperty(inst, "VirtualQuantity",(CMPIValue *)&(resource->quantity), CMPI_uint64);
    CMSetProperty(inst, "Weight",(CMPIValue *)&(resource->weight), CMPI_uint32);

    return CMPI_RC_OK;
}
Exemplo n.º 23
0
CMPIStatus
IndCIMXMLHandlerCreateInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIArgs       *in,
                 *out = NULL;
  CMPIObjectPath *op;
  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);
}
Exemplo n.º 24
0
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;
}
Exemplo n.º 25
0
// 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 ;


}
Exemplo n.º 26
0
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;
}
Exemplo n.º 27
0
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;
}
Exemplo n.º 28
0
CMPIStatus
TestAssociationProviderReferenceNames(CMPIAssociationMI * mi,
                                      const CMPIContext *ctx,
                                      const CMPIResult *rslt,
                                      const CMPIObjectPath * ref,
                                      const char *resultClass,
                                      const char *role)
{
  CMPIInstance   *ci = NULL;
  CMPIObjectPath *op = NULL;
  CMPIObjectPath *rop = NULL;
  CMPIObjectPath *cop = NULL;
  CMPIEnumeration *en = NULL;
  CMPIData        data;

  const char     *targetName = NULL;
  const char     *_thisClassName;
  const char     *_RefLeftClass = NULL;
  const char     *_RefRightClass = NULL;

  CMPIStatus      rc = { CMPI_RC_OK, NULL };
  _thisClassName = _ClassName;

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

  /*
   * check for a failure in creating the object path
   */
  if (rc.rc != CMPI_RC_OK)
    return rc;

  /*
   * the target class does not belong to us so just return CMPI_RC_OK
   */
  if (!op) {
    CMSetStatusWithChars( _broker, &rc, CMPI_RC_OK, NULL );
    return rc;
  }

  /*
   * create new object path of association 
   */
  rop = CMNewObjectPath(_broker,
                        CMGetCharsPtr(CMGetNameSpace(ref, &rc), NULL),
                        _thisClassName, &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 
   */
  if (!rc.rc)
    while (CMHasNext(en, &rc)) {
      /*
       * get the object path 
       */
      data = CMGetNext(en, &rc);

      /*
       * create new instance of the association 
       */
      ci = CMNewInstance(_broker, rop, &rc);

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

      /*
       * set the properties of the association instance depending on the
       * constellation of the source class (parameter ref) and the target
       * class (see targetName) 
       */

      if (strcmp(targetName, "CMPI_TEST_Person") == 0) {
        CMSetProperty(ci,
                      "model", (CMPIValue *) & (data.value.ref), CMPI_ref);
        CMSetProperty(ci, "driver", (CMPIValue *) & (ref), CMPI_ref);
      } else if (strcmp(targetName, "CMPI_TEST_Vehicle") == 0) {
        CMSetProperty(ci,
                      "model", (CMPIValue *) & (data.value.ref), CMPI_ref);
        CMSetProperty(ci, "driver", (CMPIValue *) & (ref), CMPI_ref);
      }

      /*
       * get object path of association instance 
       */
      cop = CMGetObjectPath(ci, &rc);

      /*
       * set namespace in object path of association 
       */
      CMSetNameSpace(cop, CMGetCharsPtr(CMGetNameSpace(ref, &rc), NULL));

      /*
       * and return the association object path as result of the
       * referenceNames() call 
       */
      CMReturnObjectPath(rslt, cop);
    }

  return rc;
}
Exemplo n.º 29
0
int _setProperty1 (CMPIInstance * ci, const char *p)
{
    CMPIValue val;
    const char *property;
    CMPIStatus rc = { CMPI_RC_OK, NULL };
    CMPIData retData;

    property = p;
    PROV_LOG ("--- _setProperty: %s -> %s", p, property);
    if ((strncmp (property, "ElementName", 11) == 0)
        && (strlen (property) == 11))
    {
        rc = CMSetProperty (ci, 
            "ElementName", 
            (CMPIValue *) _ClassName,
            CMPI_chars);
    }
    else if ((strncmp (property, "s", 1) == 0) && (strlen (property) == 1))
    {
        rc = CMSetProperty (ci, "s", (CMPIValue *) "s", CMPI_chars);
    }
    else if ((strncmp (property, "c", 1) == 0) && (strlen (property) == 1))
    {
        rc = CMSetProperty (ci, "c", (CMPIValue *) "c", CMPI_char16);
    }
    else if ((strncmp (property, "n32", 3) == 0) && (strlen (property) == 3))
    {
        val.uint32 = 32;
        rc = CMSetProperty (ci, "n32", &val, CMPI_uint32);
    }
    else if ((strncmp (property, "n64", 3) == 0) && (strlen (property) == 3))
    {
        val.uint64 = 64;
        rc = CMSetProperty (ci, "n64", &val, CMPI_uint64);
    }
    else if ((strncmp (property, "n16", 3) == 0) && (strlen (property) == 3))
    {
        val.uint16 = 16;
        rc = CMSetProperty (ci, "n16", &val, CMPI_uint16);
    }
    else if ((strncmp (property, "n8", 2) == 0) && (strlen (property) == 2))
    {
        val.uint8 = 8;
        rc = CMSetProperty (ci, "n8", &val, CMPI_uint8);
    } 
    else if ((strncmp (property, "r32", 3) == 0) && (strlen (property) == 3))
    {
        val.real32 = (CMPIReal32)1.23;
        rc = CMSetProperty (ci, "r32", &val, CMPI_real32);
    }
    else if ((strncmp (property, "r64", 3) == 0) && (strlen (property) == 3))
    {
        val.real64 = 3.1415678928283;
        rc = CMSetProperty (ci, "r64", &val, CMPI_real64);
    }
    else if ((strncmp (property, "s64", 3) == 0) && (strlen (property) == 3))
    {
        val.sint64 = 0xFFFFFFF;
        rc = CMSetProperty (ci, "s64", &val, CMPI_sint64);
    }
    else if ((strncmp (property, "s32", 3) == 0) && (strlen (property) == 3))
    {
        val.sint32 = 0xDEADBEEF;
        rc = CMSetProperty (ci, "s32", &val, CMPI_sint32);
    }
    else if ((strncmp (property, "s16", 3) == 0) && (strlen (property) == 3))
    {
        val.sint16 = (CMPISint16)0xFFFF;
        rc = CMSetProperty (ci, "s16", &val, CMPI_sint16);
    }
    else if ((strncmp (property, "s8", 2) == 0) && (strlen (property) == 2))
    {
        val.sint8 = (CMPISint8)0xFF;
        rc = CMSetProperty (ci, "s8", &val, CMPI_sint8);
    }
    else if ((strncmp (property, "b", 1) == 0) && (strlen (property) == 1))
    {
        val.boolean = 1;
        rc = CMSetProperty (ci, "b", &val, CMPI_boolean);
    }
    else if ((strncmp (property, "d", 1) == 0) && (strlen (property) == 1))
    {
        PROV_LOG ("---- CMNewDateTime");
        val.dateTime = CMNewDateTime (_broker, &rc);
        rc = CMSetProperty (ci, "d", &val, CMPI_dateTime);
    }
    else if ((strncmp (property, "*", 1) == 0) && (strlen (property) == 1))
    {
        PROV_LOG ("---- All properties");
        _setProperty1 (ci, "ElementName");
        _setProperty1 (ci, "s");
        _setProperty1 (ci, "c");
        _setProperty1 (ci, "n64");
        _setProperty1 (ci, "n32");
        _setProperty1 (ci, "n16");
        _setProperty1 (ci, "s64");
        _setProperty1 (ci, "s32");
        _setProperty1 (ci, "s16");
        _setProperty1 (ci, "r64");
        _setProperty1 (ci, "r32");
        _setProperty1 (ci, "d");
        _setProperty1 (ci, "b");
    }
    else
    {
        PROV_LOG ("---- No implementation for property: %s", property);
        return 1;
    }
    return 0;
}
Exemplo n.º 30
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;
}