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; 
}
Example #2
0
CMPIStatus CWS_DirectoryCreateInstance( CMPIInstanceMI * mi, 
                    const CMPIContext * ctx, 
                    const CMPIResult * rslt, 
                    const CMPIObjectPath * cop, 
                    const CMPIInstance * ci) 
{
  CMPIStatus st = {CMPI_RC_OK,NULL};
  CWS_FILE   filebuf;
  CMPIData   data;

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

  data = CMGetProperty(ci,"Name",NULL);
  if (!CMGetCharsPtr(data.value.string, NULL) ||
      strncmp(CMGetCharsPtr(data.value.string, NULL),CWS_FILEROOT,
          strlen(CWS_FILEROOT))) {
    CMSetStatusWithChars(_broker,&st,CMPI_RC_ERR_FAILED,
             "Invalid path name");
  } else if (!makeFileBuf(ci,&filebuf) || !CWS_Create_Directory(&filebuf)) {
    CMSetStatusWithChars(_broker,&st,CMPI_RC_ERR_FAILED,
             "Could not create instance");
  }

  return st;
}
CMPIStatus Linux_FanProviderEnumInstances( CMPIInstanceMI * mi,
           const CMPIContext * ctx,
           const CMPIResult * rslt,
           const CMPIObjectPath * ref,
           const char ** properties) {
    UNUSED(mi);

    CMPIInstance       * ci    = NULL;
    CMPIStatus           rc    = {CMPI_RC_OK, NULL};
    struct fanlist * lptr  = NULL;
    struct fanlist * rm    = NULL;

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

    if (enum_all_fans(&lptr)) {
        CMSetStatusWithChars(_broker, &rc,
                CMPI_RC_ERR_FAILED, "Could not list fans.");
        _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed : %s", 
                    _ClassName,CMGetCharPtr(rc.msg)));
        return rc;
    }

    // iterate fan list
    for (rm=lptr; lptr && rc.rc == CMPI_RC_OK; lptr = lptr->next) {
        // method call to create the CMPIInstance object
        ci = _makeInst_Fan(_broker, ctx, ref, properties, lptr->f, &rc);
        if (ci == NULL || rc.rc != CMPI_RC_OK ) {
            if (rc.msg != NULL ) {
                _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed :"
                           " %s",_ClassName,CMGetCharPtr(rc.msg)));
            }
            CMSetStatusWithChars( _broker, &rc,
                  CMPI_RC_ERR_FAILED, "Transformation from internal"
                 " structure to CIM Instance failed.");
            if (rm) free_fanlist(rm);
            _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() failed :"
                       " %s", _ClassName,CMGetCharPtr(rc.msg)));
            return rc;
        }else {
            CMReturnInstance(rslt, ci);
        }
    }
    if (rm) free_fanlist(rm);

    CMReturnDone(rslt);
    _OSBASE_TRACE(1, ("--- %s CMPI EnumInstances() exited", _ClassName));
    return rc;
}
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);
}
Example #5
0
   static CMPIEnumeration* mbEnumInstanceNames(const CMPIBroker *mb, const CMPIContext *ctx,
                  const CMPIObjectPath *cop, CMPIStatus *rc) {
      DDD(cout<<"--- mbEnumInstanceNames()"<<endl);
      mb=CM_BROKER;

      AutoMutex mtx(((CMPI_Broker*)mb)->mtx);
   try {
         Array<CIMObjectPath> const &en=CM_CIMOM(mb)->enumerateInstanceNames(
                     OperationContext(*CM_Context(ctx)),
         CM_ObjectPath(cop)->getNameSpace(),
         CM_ObjectPath(cop)->getClassName());
         if (rc) CMSetStatus(rc,CMPI_RC_OK);
         CMPI_Object *obj =
             new CMPI_Object(new CMPI_OpEnumeration(new Array<CIMObjectPath>(en)));
         return (CMPI_OpEnumeration *)obj->getHdl();

      }
      catch (const CIMException &e) {
         DDD(cout<<"### exception: mbEnumInstances - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl);
         if (rc) CMSetStatusWithString(rc,(CMPIrc)e.getCode(),
            (CMPIString*)string2CMPIString(e.getMessage()));
      }
      if (rc) CMSetStatusWithChars(mb,rc,CMPI_RC_ERROR,"Internal error - CMPIBoker.cpp-6");
      return NULL;
   }
Example #6
0
   static CMPIEnumeration* mbEnumInstances(const CMPIBroker *mb, const CMPIContext *ctx,
                  const CMPIObjectPath *cop, const char **properties, CMPIStatus *rc) {
      DDD(cout<<"--- mbEnumInstances()"<<endl);
      mb=CM_BROKER;

      CMPIFlags flgs=ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
      const CIMPropertyList props=getList(properties);

      AutoMutex mtx(((CMPI_Broker*)mb)->mtx);
      try {
         Array<CIMInstance> const &en=CM_CIMOM(mb)->enumerateInstances(
                     OperationContext(*CM_Context(ctx)),
         CM_ObjectPath(cop)->getNameSpace(),
         CM_ObjectPath(cop)->getClassName(),
         CM_DeepInheritance(flgs),
         CM_LocalOnly(flgs),
         CM_IncludeQualifiers(flgs),
         CM_ClassOrigin(flgs),
         props);
         if (rc) CMSetStatus(rc,CMPI_RC_OK);
         CMPI_Object *obj =
             new CMPI_Object(new CMPI_InstEnumeration(new Array<CIMInstance>(en)));
         return (CMPI_InstEnumeration*)obj->getHdl();

      }
      catch (const CIMException &e) {
         DDD(cout<<"### exception: mbEnumInstances - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl);
         if (rc) CMSetStatusWithString(rc,(CMPIrc)e.getCode(),
            (CMPIString*)string2CMPIString(e.getMessage()));
         return NULL;
      }
      if (rc) CMSetStatusWithChars(mb,rc,CMPI_RC_ERROR,"Internal error - CMPIBoker.cpp-5");
      return NULL;
   }
Example #7
0
CMPIObjectPath * _makePath_TestClass(
    const CMPIBroker * _broker,
    const CMPIContext * ctx,
    const CMPIObjectPath * ref,
    CMPIStatus * rc,
    unsigned int theKey)
{
    CMPIObjectPath * op = NULL;

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

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

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

    exit:
    return op;
}
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;
}
Example #9
0
   static CMPIInstance* mbGetInstance(const CMPIBroker *mb, const CMPIContext *ctx,
                  const CMPIObjectPath *cop, const char **properties, CMPIStatus *rc) {
      DDD(cout<<"--- mbGetInstance()"<<endl);
      mb=CM_BROKER;
      CMPIFlags flgs=ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
      const CIMPropertyList props=getList(properties);
      CIMObjectPath qop(String::EMPTY,CIMNamespaceName(),
                        CM_ObjectPath(cop)->getClassName(),
            CM_ObjectPath(cop)->getKeyBindings());

      AutoMutex mtx(((CMPI_Broker*)mb)->mtx);
      try {
         CIMInstance ci=CM_CIMOM(mb)->getInstance(
                     OperationContext(*CM_Context(ctx)),
         CM_ObjectPath(cop)->getNameSpace(),
         qop, //*CM_ObjectPath(cop),
         CM_LocalOnly(flgs),
         CM_IncludeQualifiers(flgs),
         CM_ClassOrigin(flgs),
         props);
         ci.setPath(*CM_ObjectPath(cop));
         if (rc) CMSetStatus(rc,CMPI_RC_OK);
         return (CMPIInstance*)new CMPI_Object(new CIMInstance(ci));
      }
      catch (const CIMException &e) {
         DDD(cout<<"### exception: mbGetInstance - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl);
         if (rc) CMSetStatusWithString(rc,(CMPIrc)e.getCode(),
            (CMPIString*)string2CMPIString(e.getMessage()));
         return NULL;
      }
      if (rc) CMSetStatusWithChars(mb,rc,CMPI_RC_ERROR,"Internal error - CMPIBoker.cpp-0");
      return NULL;
   }
Example #10
0
   static CMPIEnumeration* mbReferenceNames(const CMPIBroker *mb, const CMPIContext *ctx,
                  const CMPIObjectPath *cop, const char *resultClass, const char *role,
                  CMPIStatus *rc) {
      DDD(cout<<"--- mbReferencesNames()"<<endl);
      mb=CM_BROKER;
      CIMObjectPath qop(String::EMPTY,CIMNamespaceName(),
                        CM_ObjectPath(cop)->getClassName(),
            CM_ObjectPath(cop)->getKeyBindings());

      AutoMutex mtx(((CMPI_Broker*)mb)->mtx);
      try {
         Array<CIMObjectPath> const &en=CM_CIMOM(mb)->referenceNames(
         OperationContext(*CM_Context(ctx)),
         CM_ObjectPath(cop)->getNameSpace(),
         qop,
         resultClass ? CIMName(resultClass) : CIMName(),
         role ? String(role) : String::EMPTY);
         if (rc) CMSetStatus(rc,CMPI_RC_OK);
         CMPI_Object *obj =
             new CMPI_Object(new CMPI_OpEnumeration(new Array<CIMObjectPath>(en)));
         return (CMPI_OpEnumeration *)obj->getHdl();
      }
      catch (const CIMException &e) {
         DDD(cout<<"### exception: mbReferencesNames - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl);
         if (rc) CMSetStatusWithString(rc,(CMPIrc)e.getCode(),
            (CMPIString*)string2CMPIString(e.getMessage()));
      }
      if (rc) CMSetStatusWithChars(mb,rc,CMPI_RC_ERROR,"Internal error - CMPIBoker.cpp-11");
      return NULL;
   }
Example #11
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;
}
Example #12
0
CMPIInstance *SoftwareIdentityCreateElementAssocInstance(
					const char *ns,
					const char *siname,
					const char *name,
					const char ** properties,
					CMPIStatus *pStatus)
{
	const char* classKeys[] = { AntecedentName, DependentName, NULL };
	CMPIStatus status = {CMPI_RC_OK, NULL};

	_SMI_TRACE(1,("SoftwareIdentityCreateElementAssocInstance() called"));

	// Create software identity object path (LEFT)
	CMPIObjectPath *antcop;
	antcop = SoftwareIdentityCreateObjectPath(ns, siname, &status);

	if (CMIsNullObject(antcop))
	{
		CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED,
			"Could not create SoftwareIdentity cop");
		return NULL;
	}

	// Create registered profile object path (RIGHT)
	CMPIObjectPath *depcop = RegisteredProfileCreateObjectPath(ns, name, &status);
	if (CMIsNullObject(depcop))
	{
		CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED,
			"Could not create RegisteredProfile cop");
		return NULL;
	}

	CMPIInstance *assocInst = cmpiutilCreateAssociationInst(_BROKER,
											ns,
											ElementSoftwareIdentityName,
											classKeys,
											properties,
											AntecedentName,
											DependentName,
											antcop,
											depcop,
											pStatus);

	_SMI_TRACE(1,("Leaving SoftwareIdentityCreateElementAssocInstance(): %s",
			(pStatus->rc == CMPI_RC_OK)? "succeeded":"failed"));
	return assocInst;
}
CMPIInstance *RegisteredProfileCreateSubProfileRequiresAssocInstance(
					const char *ns,
					const char *profName,
					const char *subProfName,
					const char ** properties,
					CMPIStatus *pStatus)
{
	const char* classKeys[] = { DependentName, AntecedentName, NULL };
	CMPIStatus status = {CMPI_RC_OK, NULL};

	_SMI_TRACE(1,("RegisteredProfileCreateSubProfileRequiresAssocInstance() called"));

	// Create registered sub-profile object path (LEFT)
	CMPIObjectPath *rspcop = RegisteredProfileCreateObjectPath(ns, subProfName, &status);
	if (CMIsNullObject(rspcop))
	{
		CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED,
			"Could not create RegisteredSubProfile cop");
		return NULL;
	}



	// Create registered profile object path (RIGHT)
	CMPIObjectPath *rpcop = RegisteredProfileCreateObjectPath(ns, profName, &status);
	if (CMIsNullObject(rpcop))
	{
		CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED,
			"Could not create RegisteredProfile cop");
		return NULL;
	}

	CMPIInstance *assocInst = cmpiutilCreateAssociationInst(_BROKER,
											ns,
											SubProfileRequiresProfileName,
											classKeys,
											properties,
											DependentName,
											AntecedentName,
											rspcop,
											rpcop,
											pStatus);

	_SMI_TRACE(1,("Leaving RegisteredProfileCreateSubProfileRequiresAssocInstance(): %s",
			(pStatus->rc == CMPI_RC_OK)? "succeeded":"failed"));
	return assocInst;
}
Example #14
0
/* 
Get the Instances defined by <op>.

Parameters:
mi - Provider this pointer. 
ctx - Invocation Context. 
rslt - Result data container. 
cop - ObjectPath containing namespace, classname and key components. 

properties - If not NULL, the members of the array define one or more Property names. Each returned Object MUST NOT include elements for any Properties missing from this list. 

Returns:
Function return status. The following CMPIrc codes shall be recognized: CMPI_RC_OK Operation successful. CMPI_RC_ERR_FAILED Unspecific error occurred. 
CMPI_RC_ERR_NOT_SUPPORTED Operation not supported by this MI. CMPI_RC_ERR_ACCESS_DENIED Not authorized. CMPI_RC_ERR_NOT_FOUND Instance not found.
*/
CMPIStatus GK_TestGetInstance( CMPIInstanceMI * mi, 
           CMPIContext * ctx, 
           CMPIResult * rslt, 
           CMPIObjectPath * cop, 
           char ** properties) {
	const CMPIInstance * ci = NULL;
	CMPIStatus     rc = {CMPI_RC_OK, NULL};

	CMPIString         * instanceId  = NULL;
	printf("--- %s CMPI GetInstance() called",_ClassName);

	instanceId  = CMGetKey( cop, "InstanceID", &rc).value.string;
	if( instanceId  == NULL ) {    
		CMSetStatusWithChars( _broker, &rc, 
					CMPI_RC_ERR_NOT_FOUND, "Could not get InstanceID." ); 
   
   goto exit;
  }

   if ( strcmp(CMGetCharPtr(instanceId),_InstanceID) != 0){
      CMSetStatusWithChars( _broker, &rc,
                            CMPI_RC_ERR_NOT_FOUND, "This class name does not exist (wrong InstanceID)." );

		goto exit;
	}

  


	ci = _makeInst_GK_Test(cop,  &rc );

	if( ci == NULL ){

		CMSetStatusWithChars(_broker, &rc, CMPI_RC_ERR_FAILED,
								"Couldn't build instance");
		goto exit;
	}


	CMReturnInstance( rslt, ci );
	CMReturnDone(rslt);

	exit:
	
  return rc;
}
static CMPIStatus 
ResourceGroupExecQuery(CMPIInstanceMI * mi, CMPIContext * ctx, 
                       CMPIResult * rslt, CMPIObjectPath *ref,
                       char * lang, char * query)
{
        CMPIStatus rc = {CMPI_RC_OK, NULL};
        CMSetStatusWithChars(Broker, &rc, CMPI_RC_ERR_NOT_SUPPORTED, 
                             "CIM_ERR_NOT_SUPPORTED");
        return rc;
}
/**************************************************
 * Method Provider functions 
 *************************************************/
static CMPIStatus 
ColocationConstraintInvokeMethod(CMPIMethodMI * mi, CMPIContext * ctx,
                         CMPIResult * rslt, CMPIObjectPath * ref,
                         const char * method, CMPIArgs * in, CMPIArgs * out)
{
        CMPIStatus rc = {CMPI_RC_OK, NULL};
        CMSetStatusWithChars(Broker, &rc, CMPI_RC_ERR_NOT_SUPPORTED, 
                             "CIM_ERR_NOT_SUPPORTED");
	return rc;    
}
Example #17
0
/* 
Delete an existing Instance defined by <op>.
Parameters:
mi - Provider this pointer. 
ctx - Invocation Context. 
rslt - Result data container. 
op - ObjectPath containing namespace, classname and key components. 
Returns:
Function return status. The following CMPIrc codes shall be recognized: CMPI_RC_OK Operation successful. CMPI_RC_ERR_FAILED Unspecific error occurred. 
CMPI_RC_ERR_NOT_SUPPORTED Operation not supported by this MI. CMPI_RC_ERR_ACCESS_DENIED Not authorized. CMPI_RC_ERR_NOT_FOUND Instance not found.
*/
CMPIStatus GK_TestDeleteInstance( CMPIInstanceMI * mi, 
           CMPIContext * ctx, 
           CMPIResult * rslt, 
           CMPIObjectPath * cop) {
  CMPIStatus rc = {CMPI_RC_OK, NULL}; 

  

  CMSetStatusWithChars( _broker, &rc, 
			CMPI_RC_ERR_NOT_SUPPORTED, "NOT_SUPPORTED" ); 
  return rc;
}
Example #18
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;             
}
CMPIStatus Linux_FanProviderCreateInstance( CMPIInstanceMI * mi,
           const CMPIContext * ctx,
           const CMPIResult * rslt,
           const CMPIObjectPath * cop,
           const CMPIInstance * ci) {
    UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(cop); UNUSED(ci);

    CMPIStatus rc = {CMPI_RC_OK, NULL};

    _OSBASE_TRACE(1, ("--- %s CMPI CreateInstance() called", _ClassName));
    CMSetStatusWithChars(_broker, &rc,
                    CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
    _OSBASE_TRACE(1, ("--- %s CMPI CreateInstance() exited", _ClassName));
    return rc;
}
Example #21
0
CMPIStatus CWS_DirectoryModifyInstance( CMPIInstanceMI * mi, 
                     const CMPIContext * ctx, 
                     const CMPIResult * rslt, 
                     const CMPIObjectPath * cop,
                     const CMPIInstance * ci, 
                     const char **properties) 
{
  CMPIStatus st = {CMPI_RC_OK,NULL};
  CWS_FILE   filebuf;

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

  if (!makeFileBuf(ci,&filebuf) || !CWS_Update_File(&filebuf))
    CMSetStatusWithChars(_broker,&st,CMPI_RC_ERR_FAILED,
             "Could not update instance");

  return st;
}
CMPIObjectPath *RegisteredProfileCreateObjectPath(
					const char *ns,
					const char *name,
					CMPIStatus *status)
{
	CMPIObjectPath *cop;
	char buf[256];

	_SMI_TRACE(1,("RegisteredProfileCreateObjectPath() called"));

	if (strcasecmp(name, VolumeManagementName) == 0 ||
		strcasecmp(name, ArrayName) == 0 ||
		strcasecmp(name, ServerName) == 0)
	{
		cop = CMNewObjectPath(
					_BROKER, ns,
					RegisteredProfileName,
					status);
	}
	else
	{
		cop = CMNewObjectPath(
					_BROKER, ns,
					RegisteredSubProfileName,
					status);
	}

	if ((status->rc != CMPI_RC_OK) || CMIsNullObject(cop))
	{
		_SMI_TRACE(1,("RegisteredProfileCreateObjectPath(): CMNewObjectPath() failed - %s", CMGetCharPtr(status->msg)));
		CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Cannot create new objectpath");
		goto exit;
	}

	CMAddKey(cop, InstanceIDName, cmpiutilMakeInstanceID(name, buf, 256), CMPI_chars);
/*	*buf = 0;
	strncat(buf, "SNIA:", 256);
	strncat(buf, name , 256);
	CMAddKey(cop, "InstanceID", buf , CMPI_chars);
*/
exit:
	_SMI_TRACE(1,("RegisteredProfileCreateObjectPath() done"));
	return cop;
}
CMPIStatus Linux_FanAssociatedSensorProviderExecQuery(
        CMPIInstanceMI * mi, 
        const CMPIContext * ctx, 
        const CMPIResult * rslt, 
        const CMPIObjectPath * ref, 
        const char * lang, 
        const char * query)
{
    UNUSED(mi); UNUSED(ctx); UNUSED(rslt); UNUSED(ref); UNUSED(lang);
    UNUSED(query);
  CMPIStatus rc = {CMPI_RC_OK, NULL};

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

  CMSetStatusWithChars( _broker, &rc, 
			CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED" ); 

  _OSBASE_TRACE(1,("--- %s CMPI ExecQuery() exited",_ClassName));
  return rc;
}
Example #24
0
int kvp_rasd_to_kvp_rec(
    const CMPIBroker *broker,
    CMPIInstance *kvp_rasd,
    kvp *kvp_rec,
    CMPIStatus *status)
{

    CMPIStatus local_status = {CMPI_RC_OK, NULL};
    CMPIData propertyvalue;

    kvp_rec = malloc(sizeof(kvp));

    if(kvp_rec == NULL)
    {
        _SBLIM_TRACE(_SBLIM_TRACE_LEVEL_ERROR,
                     ("--- Cannot malloc memory for kvp record"));
        CMSetStatusWithChars(broker, status, CMPI_RC_ERROR_SYSTEM, "Unable to malloc memory");
        goto Error;
    }

    propertyvalue = CMGetProperty(kvp_rasd, "key", &local_status);
    if((local_status.rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue))
    {
        kvp_rec->key = strdup(CMGetCharPtr(propertyvalue.value.string));
    }
    propertyvalue = CMGetProperty(kvp_rasd, "value", &local_status);
    if((local_status.rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue))
    {
        kvp_rec->value = strdup(CMGetCharPtr(propertyvalue.value.string));
    }
    propertyvalue = CMGetProperty(kvp_rasd, "VM_ID", &local_status);
    if((local_status.rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue))
    {
        kvp_rec->vm_uuid = strdup(CMGetCharPtr(propertyvalue.value.string));
    }

    return 1;
Error:
    return 0;

}
Example #25
0
/*
Enumerate the Instances serviced by this provider.

Parameters:
mi - Provider this pointer. 
ctx - Invocation Context. 
rslt - Result data container. 
ref - ObjectPath containing namespace and classname components. 
properties - If not NULL, the members of the array define one or more Property names. Each returned Object MUST NOT include elements for any Properties missing from this list. 
Returns:
Function return status. The following CMPIrc codes shall be recognized: CMPI_RC_OK Operation successful. CMPI_RC_ERR_FAILED Unspecific error occurred. 
CMPI_RC_ERR_NOT_SUPPORTED Operation not supported by this MI. CMPI_RC_ERR_ACCESS_DENIED Not authorized. CMPI_RC_ERR_NOT_FOUND Instance not found.
*/
CMPIStatus GK_TestEnumInstances( CMPIInstanceMI * mi, 
           CMPIContext * ctx, 
           CMPIResult * rslt, 
           CMPIObjectPath * ref, 
           char ** properties) { 
  CMPIStatus rc = {CMPI_RC_OK, NULL};
  const CMPIInstance * ci = NULL;  

  ci = _makeInst_GK_Test( ref, &rc );

  if( ci == NULL) {
    CMSetStatusWithChars(_broker, &rc, CMPI_RC_ERR_FAILED,
                                                 "Couldn't build instance");
	goto exit;
  }
  
  CMReturnInstance( rslt, ci );
  CMReturnDone( rslt );

  exit:
  return rc;
}
Example #26
0
   static CMPIEnumeration* mbAssociators(const CMPIBroker *mb, const CMPIContext *ctx,
                  const CMPIObjectPath *cop, const char *assocClass, const char *resultClass,
                  const char *role, const char *resultRole, const char **properties, CMPIStatus *rc) {
      DDD(cout<<"--- mbAssociators()"<<endl);
      mb=CM_BROKER;
      CMPIFlags flgs=ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
      const CIMPropertyList props=getList(properties);
      CIMObjectPath qop(String::EMPTY,CIMNamespaceName(),
                        CM_ObjectPath(cop)->getClassName(),
            CM_ObjectPath(cop)->getKeyBindings());

      AutoMutex mtx(((CMPI_Broker*)mb)->mtx);
      try {
         Array<CIMObject> const &en=CM_CIMOM(mb)->associators(
                     OperationContext(*CM_Context(ctx)),
         CM_ObjectPath(cop)->getNameSpace(),
         qop,
         assocClass ? CIMName(assocClass) : CIMName(),
         resultClass ? CIMName(resultClass) : CIMName(),
         role ? String(role) : String::EMPTY,
         resultRole ? String(resultRole) : String::EMPTY,
         CM_IncludeQualifiers(flgs),
         CM_ClassOrigin(flgs),
         props);
         if (rc) CMSetStatus(rc,CMPI_RC_OK);
         CMPI_Object *obj =
             new CMPI_Object(new CMPI_ObjEnumeration(new Array<CIMObject>(en)));
         return (CMPI_ObjEnumeration *)obj->getHdl();

      }
      catch (const CIMException &e) {
         DDD(cout<<"### exception: mbAssociators - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl);
         if (rc) CMSetStatusWithString(rc,(CMPIrc)e.getCode(),
            (CMPIString*)string2CMPIString(e.getMessage()));
         return NULL;
      }
      if (rc) CMSetStatusWithChars(mb,rc,CMPI_RC_ERROR,"Internal error - CMPIBoker.cpp-7");
      return NULL;
   }
Example #27
0
CMPIObjectPath *SoftwareIdentityCreateObjectPath(
					const char *ns,
					const char *name,
					CMPIStatus *status)
{
	CMPIObjectPath *cop;
	char buf[256];

	_SMI_TRACE(1,("SoftwareIdentityCreateObjectPath() called"));

	if (strcasecmp(name, SMIArrayName) == 0)
	{
		cop = CMNewObjectPath(
					_BROKER, ns,
					ArraySoftwareName,
					status);
	}
	else if (strcasecmp(name, SMIVolumeManagementName) == 0)
	{
		cop = CMNewObjectPath(
					_BROKER, ns,
					VolumeManagementSoftwareName,
					status);
	}

	if ((status->rc != CMPI_RC_OK) || CMIsNullObject(cop))
	{
		_SMI_TRACE(1,("SoftwareIdentityCreateObjectPath(): CMNewObjectPath() failed - %s", CMGetCharPtr(status->msg)));
		CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Cannot create new objectpath");
		goto exit;
	}

	CMAddKey(cop, InstanceIDName, cmpiutilMakeInstanceID(name, buf, 256), CMPI_chars);

exit:
	_SMI_TRACE(1,("SoftwareIdentityCreateObjectPath() done"));
	return cop;
}
Example #28
0
   static CMPIObjectPath* mbCreateInstance(const CMPIBroker *mb, const CMPIContext *ctx,
                  const CMPIObjectPath *cop, const CMPIInstance *ci, CMPIStatus *rc) {
      DDD(cout<<"--- mbCreateInstance()"<<endl);
      mb=CM_BROKER;

      AutoMutex mtx(((CMPI_Broker*)mb)->mtx);
      try {
         CIMObjectPath ncop=CM_CIMOM(mb)->createInstance(
                     OperationContext(*CM_Context(ctx)),
         CM_ObjectPath(cop)->getNameSpace(),
                     *CM_Instance(ci));
         if (rc) CMSetStatus(rc,CMPI_RC_OK);
         return (CMPIObjectPath*)new CMPI_Object(new CIMObjectPath(ncop));
      }
      catch (const CIMException &e) {
         DDD(cout<<"### exception: mbCreateInstance - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl);
         if (rc) CMSetStatusWithString(rc,(CMPIrc)e.getCode(),
            (CMPIString*)string2CMPIString(e.getMessage()));
         return NULL;
      }
      if (rc) CMSetStatusWithChars(mb,rc,CMPI_RC_ERROR,"Internal error - CMPIBoker.cpp-1");
      return NULL;
   }
Example #29
0
/*
Enumerate ObjectPaths of Instances serviced by this provider.
Parameters:
mi - Provider this pointer. 
ctx - Invocation Context. 
rslt - Result data container. 
ref - ObjectPath containing namespace and classname components. 
Returns:
Function return status. The following CMPIrc codes shall be recognized: CMPI_RC_OK Operation successful.
CMPI_RC_ERR_FAILED Unspecific error occurred. CMPI_RC_ERR_NOT_SUPPORTED Operation not supported by this MI. CMPI_RC_ERR_ACCESS_DENIED Not authorized. 
CMPI_RC_ERR_NOT_FOUND Instance not found.
*/
CMPIStatus GK_TestEnumInstanceNames( CMPIInstanceMI * mi, 
           CMPIContext * ctx, 
           CMPIResult * rslt, 
           CMPIObjectPath * ref) { 
	CMPIObjectPath * op = NULL;
	CMPIStatus       rc = {CMPI_RC_OK, NULL};
	
	 

	op = _makePath_GK_Test( ref, &rc );

	if( op == NULL) 	{

		CMSetStatusWithChars(_broker, &rc, CMPI_RC_ERR_FAILED,
						"Couldn't build objectpath");    
		goto exit;
	}
	
	CMReturnObjectPath( rslt, op );
    CMReturnDone( rslt );
	
	exit:
	return rc;
}
/******************************************************************************
 * 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);
}