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

    CMPIStatus rc = { CMPI_RC_OK, NULL };

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

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

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

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

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

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

        /* and return the target class object path as result of the
         * associatorNames() call
        */
        CMReturnObjectPath( rslt, data.value.ref );
    }
    PROV_LOG ("\n\n********************* %s CMPI AssociatorNames() exited",
        _ClassName);
    PROV_LOG_CLOSE ();
    return rc;
}
CMPIInstance   *
internalProviderGetInstance(const CMPIObjectPath * cop, CMPIStatus *rc)
{
  int             len;
  CMPIString     *cn = CMGetClassName(cop, NULL);
  CMPIString     *ns = CMGetNameSpace(cop, NULL);
  char           *key = normalizeObjectPathCharsDup(cop);
  CMPIInstance   *ci = NULL;
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);
  CMPIStatus      st = { CMPI_RC_OK, NULL };

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

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

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

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

  *rc = st;
  free(key);
  _SFCB_RETURN(ci);
}
CMPIInstance * _makeInst_ServiceProcess( const CMPIBroker * _broker,
					 const CMPIObjectPath * service,
					 CMPIObjectPath * process,
					 CMPIStatus * rc) {
  CMPIObjectPath * op = NULL;
  CMPIInstance   * ci = NULL;

  _OSBASE_TRACE(4,("--- _makeInst_ServiceProcess() called"));

  /* create CMPIObjectPath of this association <_ClassName> */
  op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(service,rc)),
			_ClassName, rc );
  if( CMIsNullObject(op) ) { 
    CMSetStatusWithChars( _broker, rc, 
			  CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); 
    goto exit;
  }

  ci = CMNewInstance( _broker, op, rc);
  if( CMIsNullObject(ci) ) { 
    CMSetStatusWithChars( _broker, rc, 
			  CMPI_RC_ERR_FAILED, "Create CMPIInstance failed." ); 
    _OSBASE_TRACE(4,("--- _makeInst_ServiceProcess() failed : %s",CMGetCharPtr(rc->msg)));
    goto exit;
  }

  CMSetProperty( ci, _RefLeft, (CMPIValue*)&(service), CMPI_ref ); 
  CMSetProperty( ci, _RefRight, (CMPIValue*)&(process), CMPI_ref );

 exit:
  _OSBASE_TRACE(4,("--- _makeInst_ServiceProcess() exited"));
  return ci; 
}
CMPIStatus
InternalProviderDeleteInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIString     *cn = CMGetClassName(cop, NULL);
  CMPIString     *ns = CMGetNameSpace(cop, NULL);
  char           *key = normalizeObjectPathCharsDup(cop);
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderDeleteInstance");

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

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

  deleteBlob(bnss, cns, key);

  free(key);
  _SFCB_RETURN(st);
}
Esempio n. 5
0
static int
refValue2xml(CMPIObjectPath * ci, UtilStringBuffer * sb)
{
  _SFCB_ENTER(TRACE_CIMXMLPROC, "refValue2xml");

  SFCB_APPENDCHARS_BLOCK(sb, "<VALUE.REFERENCE>\n");
  if (ci && ci->hdl) {
    char           *ns = CMGetCharPtr(CMGetNameSpace(ci, NULL));
    char           *hn = CMGetCharPtr(CMGetHostname(ci, NULL));
    if (hn && *hn && ns && *ns) {
      SFCB_APPENDCHARS_BLOCK(sb, "<INSTANCEPATH>\n");
      nsPath2xml(ci, sb);
    } else if (ns && *ns) {
      SFCB_APPENDCHARS_BLOCK(sb, "<LOCALINSTANCEPATH>\n");
      lnsPath2xml(ci, sb);
    }
    instanceName2xml(ci, sb);
    if (hn && *hn && ns && *ns) {
      SFCB_APPENDCHARS_BLOCK(sb, "</INSTANCEPATH>\n");
    } else if (ns && *ns) {
      SFCB_APPENDCHARS_BLOCK(sb, "</LOCALINSTANCEPATH>\n");
    }
  }
  SFCB_APPENDCHARS_BLOCK(sb, "</VALUE.REFERENCE>\n");
  _SFCB_RETURN(0);
}
Esempio n. 6
0
static int
lnsPath2xml(CMPIObjectPath * ci, UtilStringBuffer * sb)
{
  _SFCB_ENTER(TRACE_CIMXMLPROC, "lnsPath2xml");
  char           *ns = CMGetCharPtr(CMGetNameSpace(ci, NULL));

  if (ns && *ns) {
    char           *nsc = strdup(ns);
    char           *nsp;
    ns = nsc;
    SFCB_APPENDCHARS_BLOCK(sb, "<LOCALNAMESPACEPATH>\n");
    do {
      nsp = strchr(ns, '/');
      if (nsp) {
        *nsp = 0;
      }
      SFCB_APPENDCHARS_BLOCK(sb, "<NAMESPACE NAME=\"");
      sb->ft->appendChars(sb, ns);
      SFCB_APPENDCHARS_BLOCK(sb, "\"/>\n");
      if (nsp) {
        ns = nsp + 1;
      }
    } while (nsp);
    free(nsc);
    SFCB_APPENDCHARS_BLOCK(sb, "</LOCALNAMESPACEPATH>\n");
  }
  _SFCB_RETURN(0);
}
Esempio n. 7
0
static ClassRegister *
getNsReg(const CMPIObjectPath * ref, int *rc)
{
  char           *ns;
  CMPIString     *nsi = CMGetNameSpace(ref, NULL);
  ClassRegister  *cReg;
  *rc = 0;

  pthread_once(&nsHt_once, nsHt_init);

  if (nsHt == NULL) {
    mlogf(M_ERROR, M_SHOW,
          "--- ClassProvider: namespace hash table not initialized\n");
    *rc = 1;
    return NULL;
  }

  if (nsi && nsi->hdl) {
    ns = (char *) nsi->hdl;
    if (strcasecmp(ns, "root/pg_interop") == 0)
      cReg = nsHt->ft->get(nsHt, "root/interop");
    else
      cReg = nsHt->ft->get(nsHt, ns);
    return cReg;
  }

  *rc = 1;
  return NULL;
}
CMPIObjectPath *
get_assoc_targetClass_ObjectPath(const CMPIBroker * broker,
                                 const CMPIObjectPath * ref,
                                 const char *_RefLeftClass,
                                 const char *_RefRightClass,
                                 CMPIStatus *rc)
{
  CMPIObjectPath *op = NULL;
  const char     *targetName = NULL;

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

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

    if (!op)
      CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED,
          "Create CMPIObjectPath failed in cmpiTestAssociationProvider");
  }
  return op;
}
const char     *
get_assoc_targetClass_Name(const CMPIBroker * broker,
                           const CMPIObjectPath * ref,
                           const char *_RefLeftClass,
                           const char *_RefRightClass, CMPIStatus *rc)
{
  CMPIString     *sourceClass = NULL;
  CMPIObjectPath *op = NULL;

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

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

  if (strcmp(CMGetCharsPtr(sourceClass, NULL), "CMPI_TEST_Person") == 0) {
    return "CMPI_TEST_Vehicle";
  } else if (strcmp(CMGetCharsPtr(sourceClass, NULL),
                    "CMPI_TEST_Vehicle") == 0) {
    return "CMPI_TEST_Person";
  } else {
    return NULL;
  }
}
Esempio n. 10
0
CMPIObjectPath *
get_assoc_targetClass_ObjectPath(const CMPIBroker * broker,
                                 const CMPIObjectPath * ref,
                                 const char *_RefLeftClass,
                                 const char *_RefRightClass,
                                 CMPIStatus *rc)
{
  CMPIObjectPath *op = NULL;
  const char     *targetName = NULL;

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

  if (targetName != NULL) {
    /*
     * create new object path of the target class 
     */
    op = CMNewObjectPath(broker,
                         CMGetCharsPtr(CMGetNameSpace(ref, rc), NULL),
                         targetName, rc);
  }
  return op;
}
Esempio n. 11
0
CMPIObjectPath * _makePath_TestClass(
    const CMPIBroker * _broker,
    const CMPIContext * ctx,
    const CMPIObjectPath * ref,
    CMPIStatus * rc,
    unsigned int theKey)
{
    CMPIObjectPath * op = NULL;

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

    if (CMIsNullObject(op))
    {
        CMSetStatusWithChars(
            _broker,
            rc,
            CMPI_RC_ERR_FAILED,
            "Create CMPIObjectPath failed." );
        goto exit;
    }

    CMAddKey(op, "theKey", &theKey, CMPI_uint32);

    exit:
    return op;
}
Esempio n. 12
0
CMPIStatus CWS_DirectoryGetInstance( CMPIInstanceMI * mi, 
                     const CMPIContext * ctx, 
                     const CMPIResult * rslt, 
                     const CMPIObjectPath * cop, 
                     const char ** properties) 
{
  CMPIInstance *in = NULL;
  CMPIStatus    st = {CMPI_RC_OK,NULL};
  CMPIData      nd = CMGetKey(cop,"Name",&st);
  CWS_FILE      filebuf;

  if (!silentMode()) fprintf(stderr,"--- CWS_DirectoryGetInstance() \n");

  if (st.rc == CMPI_RC_OK &&
      nd.type == CMPI_string &&
      CWS_Get_File(CMGetCharsPtr(nd.value.string, NULL),&filebuf))
    in = makeInstance(_broker,
              LOCALCLASSNAME,
              CMGetCharsPtr(CMGetNameSpace(cop,NULL), NULL),
              &filebuf);

  if (CMIsNullObject(in)) {
    CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
             "Could not find or construct instance");
  } else {
    CMReturnInstance(rslt,in);
    CMReturnDone(rslt);
  }

  return st;
}
CMPIStatus Linux_FanAssociatedSensorProviderAssociators(
        CMPIAssociationMI * mi,
        const CMPIContext * ctx,
        const CMPIResult * rslt,
        const CMPIObjectPath * cop,
        const char * assocClass,
        const char * resultClass,
        const char * role,
        const char * resultRole,
        const char ** propertyList)
{
    UNUSED(mi); UNUSED(propertyList);
  CMPIStatus       rc    = {CMPI_RC_OK, NULL};
  CMPIObjectPath * op    = NULL;
  int              refrc = 0;

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

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

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

    refrc = _assoc_create_refs_1toN(_broker, ctx, rslt, cop, 
				    _ClassName,_RefLeftClass,_RefRightClass,
				    _RefLeft,_RefRight,
				    1, 1, &rc);
    if( refrc != 0 ) {
      if( rc.msg != NULL ) {
	_OSBASE_TRACE(1, ("--- %s CMPI Associators() failed : %s",
                    _ClassName,CMGetCharPtr(rc.msg)));
      }
      else {
	_OSBASE_TRACE(1,("--- %s CMPI Associators() failed",_ClassName));
      }
      return rc;
    }
  }
  
 exit:
  CMReturnDone( rslt );
  _OSBASE_TRACE(1,("--- %s CMPI Associators() exited",_ClassName));  
  CMReturn(CMPI_RC_OK);
}
CMPIStatus TestCMPIAssociationProviderAssociators(
    CMPIAssociationMI* mi,
    const CMPIContext* ctx,
    const CMPIResult* rslt,
    const CMPIObjectPath* ref,
    const char* _RefLeftClass,
    const char* _RefRightClass,
    const char* role,
    const char* resultRole,
    const char** properties)
{
    CMPIObjectPath * op = NULL;
    CMPIEnumeration * en = NULL;
    CMPIData data ;
    CMPIStatus rc = { CMPI_RC_OK, NULL };

    CMPIString * sourceClass = NULL;

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

    sourceClass = CMGetClassName(ref,&rc);

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

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

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

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

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

        /* and return the target class instance as result of the
         * associators() call
        */
        CMReturnInstance( rslt, data.value.inst );
    }
    PROV_LOG ("\n\n********************* %s CMPI Associators exited",
        _ClassName);
    PROV_LOG_CLOSE ();
    return rc;
}
Esempio n. 15
0
static int interOpNameSpace(const CMPIObjectPath *cop, CMPIStatus *st) 
 {   
   char *ns=(char*)CMGetNameSpace(cop,NULL)->hdl;   
   if (strcasecmp(ns,"root/interop") && strcasecmp(ns,"root/pg_interop")) {
      setStatus(st,CMPI_RC_ERR_FAILED,"Object must reside in root/interop");
      return 0;
   }
   return 1;
}
Esempio n. 16
0
CMPIStatus KBase_FromObjectPath(KBase* self, const CMPIObjectPath* cop)
{
    CMPIString* cn;
    CMPIString* ns;
    CMPIStatus st = KSTATUS_INIT;
    CMPICount count;
    CMPICount i;
    KValue* kv;

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

    /* Set namespace */

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

    self->ns = ns;

    /* Get classname */

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

    /* For each property */

    count = CMGetKeyCount(cop, &st); 

    if (!KOkay(st))
        return st;

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

        /* Get i-th property */

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

        if (!KOkay(st))
            return st;

        if (!pn)
            KReturn(ERR_FAILED);

        /* Find the given property */

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

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

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderSetInstance");

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

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

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

  len = getInstanceSerializedSize(ci);
  blob = malloc(len + 64);
  getSerializedInstance(ci, blob);
  addBlob(bnss, cns, key, blob, (int) len);
  free(blob);
  free(key);
  _SFCB_RETURN(st);
}
Esempio n. 18
0
CMPIObjectPath * _makePath_TestClassA(
    const CMPIBroker * _broker,
    const CMPIContext * ctx,
    const CMPIObjectPath * cop)
{
   CMPIObjectPath * op = NULL;
   CMPIValue theKey;
   theKey.uint32 = 2;

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

   CMAddKey(op, "theKey", &theKey, CMPI_uint32);
   return op;
}
CMPIObjectPath * _makePath_ServiceProcess( const CMPIBroker * _broker, 
					   const CMPIObjectPath * service,
					   CMPIObjectPath * process,
					   CMPIStatus * rc) {
  CMPIObjectPath * op = NULL;
  CMPIInstance   * ci = NULL;

  _OSBASE_TRACE(4,("--- _makePath_ServiceProcess() called"));

  ci = _makeInst_ServiceProcess(_broker, service, process, rc);
  if( ci == NULL ) { return NULL; }

  op = CMGetObjectPath(ci,rc); 
  CMSetNameSpace(op,CMGetCharPtr(CMGetNameSpace(service,rc)));

  _OSBASE_TRACE(4,("--- _makePath_ServiceProcess() exited"));
  return op; 
}
Esempio n. 20
0
CMPIStatus CWS_DirectoryEnumInstances( CMPIInstanceMI * mi, 
                       const CMPIContext * ctx, 
                       const CMPIResult * rslt, 
                       const CMPIObjectPath * ref, 
                       const char ** properties) 
{
  CMPIInstance   *in;
  CMPIStatus      st = {CMPI_RC_OK,NULL};
  void           *enumhdl;
  CWS_FILE        filebuf;

  if (!silentMode()) fprintf(stderr,"--- CWS_DirectoryEnumInstances() \n");

  enumhdl = CWS_Begin_Enum(CWS_FILEROOT,CWS_TYPE_DIR);

  if (enumhdl == NULL) {
    CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
             "Could not begin file enumeration");
    return st;
  } else {
    while (CWS_Next_Enum(enumhdl,&filebuf)) {
      /* build instance from file buffer */
      in = makeInstance(_broker,
            LOCALCLASSNAME,
            CMGetCharsPtr(CMGetNameSpace(ref,NULL), NULL),
            &filebuf);
      if (CMIsNullObject(in)) {
    CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
                 "Could not construct instance");
    break;
      }
      CMReturnInstance(rslt,in);
    }
    CMReturnDone(rslt);
    CWS_End_Enum(enumhdl);
  }

  return st;
}
CMPIObjectPath * _makePath_Service( const CMPIBroker * _broker,
		      const CMPIContext * ctx, 
	         const CMPIObjectPath * ref,
	         LXS_Service * lxssvc,
	         CMPIStatus * rc) {
  CMPIObjectPath * op = NULL;
 
  _OSBASE_TRACE(2,("--- _makePath_Service() called"));

  /* the sblim-cmpi-base package offers some tool methods to get common
   * system data 
  */
  if( !get_system_name() ) {   
    CMSetStatusWithChars( _broker, rc, 
			  CMPI_RC_ERR_FAILED, "no host name found" );
    _OSBASE_TRACE(2,("--- _makePath_Service() failed : %s",CMGetCharPtr(rc->msg)));
    goto exit;
  }

  op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(ref,rc)), 
			_ClassName, rc );
  if( CMIsNullObject(op) ) { 
    CMSetStatusWithChars( _broker, rc, 
			  CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); 
    _OSBASE_TRACE(2,("--- _makePath_Service() failed : %s",CMGetCharPtr(rc->msg)));
    goto exit; 
  }

  CMAddKey(op, "SystemCreationClassName", CSCreationClassName, CMPI_chars);
  CMAddKey(op, "SystemName", get_system_name(), CMPI_chars);
  CMAddKey(op, "CreationClassName", _ClassName, CMPI_chars);
  CMAddKey(op, "Name", lxssvc->svName, CMPI_chars);

 exit:
  _OSBASE_TRACE(2,("--- _makePath_Service() exited"));
  return op;             
}
Esempio n. 22
0
static CMPIStatus
ClassProviderEnumClassNames(CMPIClassMI * mi,
                            const CMPIContext *ctx,
                            const CMPIResult *rslt, const CMPIObjectPath * ref)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  char           *cn = NULL;
  CMPIFlags       flgs = 0;
  CMPIString     *cni;
  ClassBase      *cb;
  Iterator        it;
  char           *key;
  int             rc,
                  n;
  ClassRecord    *crec;
  CMPIObjectPath *op;
  ClassRegister  *cReg;
  char           *ns;

  _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderEnumClassNames");

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

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

  cReg->ft->wLock(cReg);

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

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

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

  cReg->ft->wUnLock(cReg);

  _SFCB_RETURN(st);
}
Esempio 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);
}
/******************************************************************************
 * Provider export function
 * Execute an extrinsic method on the specified CIM instance.
 *****************************************************************************/
static CMPIStatus xen_resource_invoke_method(
    CMPIMethodMI * self,            /* [in] Handle to this provider (i.e. 'self') */
    const CMPIBroker *broker,       /* [in] CMPI Factory services */
    const CMPIContext * context,    /* [in] Additional context info, if any */
    const CMPIResult * results,     /* [out] Results of this operation */
    const CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */
    const char * methodname,        /* [in] Name of the method to apply against the reference object */
    const CMPIArgs * argsin,        /* [in] Method input arguments */
    CMPIArgs * argsout)             /* [in] Method output arguments */
{
    CMPIStatus status = {CMPI_RC_OK, NULL};      /* Return status of CIM operations. */
    char * nameSpace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
    unsigned long rc = 0;
    CMPIData argdata;
    xen_utils_session * session = NULL;
    
    _SBLIM_ENTER("InvokeMethod");
    _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO, ("--- self=\"%s\"", self->ft->miName));
    _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO, ("--- methodname=\"%s\"", methodname));
    _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO, ("--- namespace=\"%s\"", nameSpace));

    struct xen_call_context *ctx = NULL;
    if(!xen_utils_get_call_context(context, &ctx, &status)){
         goto Exit;
    }

    if (!xen_utils_validate_session(&session, ctx)) {
        CMSetStatusWithChars(broker, &status, 
            CMPI_RC_ERR_METHOD_NOT_AVAILABLE, "Unable to connect to Xen");
        goto Exit;
    }
    
    int argcount = CMGetArgCount(argsin, NULL);
    _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_INFO, ("--- argsin=%d", argcount));
    
    argdata = CMGetKey(reference, "Name", &status);
    if((status.rc != CMPI_RC_OK) || CMIsNullValue(argdata)) {
        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR, 
                     ("Couldnt find the Virtual System Migration Service to invoke method on"));
        goto Exit;
    }
    /* Check that the method has the correct number of arguments. */
    if(strcmp(methodname, "MigrateVirtualSystemToHost") == 0) {
        rc = MigrateVirtualSystem(broker, context, argsin, argsout, session, true, false, &status);
        //CMPIObjectPath* job_instance_op = NULL;
        //CMAddArg(argsout, "Job", (CMPIValue *)&job_instance_op, CMPI_ref);
    }
    else if(strcmp(methodname, "MigrateVirtualSystemToSystem") == 0) {
        rc = MigrateVirtualSystem(broker, context, argsin, argsout, session, false, false, &status);
        //CMPIObjectPath* job_instance_op = NULL;
        //CMAddArg(argsout, "Job", (CMPIValue *)&job_instance_op, CMPI_ref);
        //CMPIObjectPath* newcomputersystem_instance_op = NULL;
        //CMAddArg(argsout, "NewComputerSystem", (CMPIValue *)&newcomputersystem_instance_op, CMPI_ref);
    }
    else if(strcmp(methodname, "CheckVirtualSystemIsMigratableToHost") == 0) {
        rc = MigrateVirtualSystem(broker, context, argsin, argsout, session, true, true, &status);
    }
    else if(strcmp(methodname, "CheckVirtualSystemIsMigratableToSystem") == 0) {
        rc = MigrateVirtualSystem(broker, context, argsin, argsout, session, false, true, &status);
    }
    else
        status.rc = CMPI_RC_ERR_METHOD_NOT_FOUND;
    
Exit:
    if(session)
        xen_utils_cleanup_session(session);
    if(ctx)
        xen_utils_free_call_context(ctx);

    CMReturnData(results, (CMPIValue *)&rc, CMPI_uint32);
    CMReturnDone(results);

    _SBLIM_RETURNSTATUS(status);
}
Esempio n. 25
0
CMPIStatus
getRefs(const CMPIContext *ctx, const CMPIResult *rslt,
        const CMPIObjectPath * cop,
        const char *assocClass,
        const char *resultClass,
        const char *role,
        const char *resultRole,
        const char **propertyList, int associatorFunction)
{
  UtilList       *refs = UtilFactory->newList(memAddUtilList, memUnlinkEncObj);
  char           *ns = (char *) CMGetNameSpace(cop, NULL)->hdl;
  CMPIStatus      st = { CMPI_RC_OK, NULL };

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "getRefs");

  if (assocClass != NULL) {
    CMPIObjectPath *path;
    if (assocForName(ns, assocClass, role, resultRole) == NULL) {
      /*
       * for an unknown class we just return nothing 
       */
      _SFCB_RETURN(st);
    }
    path = CMNewObjectPath(_broker, ns, assocClass, NULL);
    SafeInternalProviderAddEnumInstances(refs, NULL, ctx, path,
                                         propertyList, &st, 1);
  }

  else {
    CMPIData        rv;
    CMPIObjectPath *op =
        CMNewObjectPath(Broker, ns, "$ClassProvider$", &st);
    CMPIArgs       *in = CMNewArgs(Broker, NULL);
    CMPIArgs       *out = CMNewArgs(Broker, NULL);
    rv = CBInvokeMethod(Broker, ctx, op, "getassocs", in, out, &st);
    if (out) {
      int             i,
                      m;
      CMPIArray      *ar = CMGetArg(out, "assocs", &st).value.array;
      for (i = 0, m = CMGetArrayCount(ar, NULL); i < m; i++) {
        char           *name =
            CMGetArrayElementAt(ar, i, NULL).value.string->hdl;
        if (name) {
          CMPIObjectPath *cop = CMNewObjectPath(Broker, ns, name, NULL);
          if (cop) {
            SafeInternalProviderAddEnumInstances(refs, NULL, ctx, cop,
                                                 propertyList, &st, 1);
          }
        }
        _SFCB_TRACE(1, ("--- assoc %s", name));
      }
    }
  }

  if (role) {
    // filter out the associations not matching the role property
    CMPIInstance   *ci;
    UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop);
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      CMPIData        data = CMGetProperty(ci, role, NULL);
      if ((data.state & CMPI_notFound) ||
          data.type != CMPI_ref ||
          objectPathEquals(pn, data.value.ref, NULL, 0) == 0) {
        refs->ft->removeCurrent(refs);
      }
    }
    pn->ft->release(pn);
  }

  else {
    // filter out associations not referencing pathName
    CMPIInstance   *ci;
    int             matched,
                    i,
                    m;
    UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop);
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      for (matched = 0, i = 0, m = CMGetPropertyCount(ci, NULL); i < m;
           i++) {
        CMPIData        data = CMGetPropertyAt(ci, i, NULL, NULL);
        if (data.type == CMPI_ref
            && objectPathEquals(pn, data.value.ref, NULL, 0)) {
          matched = 1;
          break;
        }
      }
      if (matched == 0)
        refs->ft->removeCurrent(refs);
    }
    pn->ft->release(pn);
  }

  if (associatorFunction == REF) {
    CMPIInstance   *ci;
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      CMReturnInstance(rslt, ci);
    }
    refs->ft->release(refs);
    _SFCB_RETURN(st);
  }

  else if (associatorFunction == REF_NAME) {
    CMPIInstance   *ci;
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      CMPIObjectPath *ref = CMGetObjectPath(ci, NULL);
      CMReturnObjectPath(rslt, ref);
    }
    refs->ft->release(refs);
    _SFCB_RETURN(st);
  }

  else {
    // Use hashtable to avoid dup'd associators
    CMPIInstance   *ci;
    UtilHashTable  *assocs =
        UtilFactory->newHashTable(61, UtilHashTable_charKey);
    UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop);
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      // Q: for ASSOC_NAME we should not require the
      // object exist if we go by the book, should we?
      // The current approach retrieves the instances
      // via the CIMOM handle
      if (resultRole) {
        CMPIData        data = CMGetProperty(ci, resultRole, NULL);
        UtilStringBuffer *an = NULL;
        if ((data.state & CMPI_notFound) == 0 && data.type == CMPI_ref &&
            objectPathEquals(pn, data.value.ref, &an, 0) == 0) {
          if (resultClass == NULL
              || CMClassPathIsA(Broker, data.value.ref, resultClass,
                                NULL)) {
            CMPIInstance   *aci =
                CBGetInstance(Broker, ctx, data.value.ref, propertyList,
                              &st);
            assocs->ft->put(assocs, an->ft->getCharPtr(an), aci);
          }
        }
      }

      else {
        // must loop over the properties to find ref instances
        int             i,
                        m;
        for (i = 0, m = CMGetPropertyCount(ci, NULL); i < m; i++) {
          CMPIData        data = CMGetPropertyAt(ci, i, NULL, NULL);
          if (data.type == CMPI_ref) {
            CMPIObjectPath *ref = data.value.ref;
            CMPIString     *tns = CMGetNameSpace(ref, NULL);
            if (tns == NULL || tns->hdl == NULL)
              CMSetNameSpace(ref, ns);
            UtilStringBuffer *an = NULL;
            if (objectPathEquals(pn, ref, &an, 0) == 0) {

              if (resultClass == NULL
                  || CMClassPathIsA(Broker, ref, resultClass, NULL)) {
                CMPIInstance   *aci =
                    CBGetInstance(Broker, ctx, ref, propertyList, &st);
                if (aci)
                  assocs->ft->put(assocs, an->ft->getCharPtr(an), aci);
              }
            }
          }
        }
      }
    }

    {
      HashTableIterator *it;
      char           *an;
      CMPIInstance   *aci;
      for (it =
           assocs->ft->getFirst(assocs, (void **) &an, (void **) &aci); it;
           it =
           assocs->ft->getNext(assocs, it, (void **) &an,
                               (void **) &aci)) {
        if (associatorFunction == ASSOC)
          CMReturnInstance(rslt, aci);
        else {
          CMPIObjectPath *op = CMGetObjectPath(aci, NULL);
          CMReturnObjectPath(rslt, op);
        }
      }
    }

    refs->ft->release(refs);
    assocs->ft->release(assocs);
    pn->ft->release(pn);
    _SFCB_RETURN(st);

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

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderCreateInstance");

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

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

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

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

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

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

  free(key);
  _SFCB_RETURN(st);
}
Esempio n. 27
0
CMPIStatus TestCMPIBrokerInstanceProviderCreateInstance (CMPIInstanceMI * mi,
    const CMPIContext * ctx,
    const CMPIResult * rslt,
    const CMPIObjectPath * cop,
    const CMPIInstance * ci)
{
    const CMPIString* retNamespace;
    const CMPIString* retClassname;
    CMPIString* type;
    const char* str1;
    const char* str2;
    CMPIStatus rc = { CMPI_RC_OK, NULL };
    CMPIData retData;
    CMPIObjectPath *obj;
    CMPIBoolean bol = 0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  _SFCB_RETURN(st);
}
Esempio n. 29
0
CMPIStatus TestCMPIBrokerInstanceProviderGetInstance (CMPIInstanceMI * mi,
    const CMPIContext * ctx,
    const CMPIResult * rslt,
    const CMPIObjectPath * cop,
    const char **properties)
{
    CMPIStatus rc = {CMPI_RC_OK, NULL};
    CMPIString* retNamespace;
    CMPIString* retClassname;
    CMPIString* type;
    CMPIData retData;
    CMPIObjectPath* obj;
    CMPIBoolean bol = 0;
    const char* str1;
    const char* str2;

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

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

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

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

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

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

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

          cop = getObjectPath(copKey, NULL);
          if (cop)
            CMReturnObjectPath(rslt, cop);
          else {
            CMPIStatus      st = { CMPI_RC_ERR_FAILED, NULL };
            return st;
          }
          if (bi->next < bi->dSize && ipGetNext(bi, NULL, &kp, &ekl)) {
            continue;
          }
          break;
        }
      }
      freeBlobIndex(&bi, 1);
    }
    if (i < ac)
      cns = (char *) CMGetArrayElementAt(ar, i, NULL).value.string->hdl;
    else
      cns = NULL;
  }
  _SFCB_RETURN(st);
}