void UNIX_BGPEndpointStatisticsProvider::invokeMethod(
	const OperationContext& context,
	const CIMObjectPath& objectReference,
	const CIMName& methodName,
	const Array<CIMParamValue>& inParameters,
	MethodResultResponseHandler& handler)
{
	if (!objectReference.getClassName().equal("UNIX_BGPEndpointStatistics") && !objectReference.getClassName().equal("CIM_BGPEndpointStatistics")) {
		String classMessage;
		classMessage.append("UNIX_BGPEndpointStatistics Provider");
		classMessage.append (" does not support class ");
		classMessage.append (objectReference.getClassName().getString());
		throw CIMNotSupportedException(classMessage);
	}


	handler.processing();
	// Make cimom handle invokeMethod request with input parameters.
	CIMObjectPath localReference = CIMObjectPath(
		String(""),
		CIMNamespaceName("root/cimv2"),
		objectReference.getClassName(),
		objectReference.getKeyBindings());
	
	if (methodName.equal("ResetSelectedStats")) {

		if (inParameters.size() != 1)
		{
			throw new CIMOperationFailedException("Incorrect in parameters");
		}
		
		//Invoking ResetSelectedStats method.
		Uint32 invokeResetSelectedStatsReturnValue;

		Array<String> inSelectedStatistics;
		
		for(Uint32 pi = 0; pi < inParameters.size(); pi++) {
			CIMParamValue p = inParameters[pi];
			if (String::equalNoCase(p.getParameterName(), "SelectedStatistics"))
			{
				p.getValue().get(inSelectedStatistics);
			}
		}
		_p.initialize();
		_p.find(localReference.getKeyBindings());
		invokeResetSelectedStatsReturnValue = _p.invokeResetSelectedStats(

			inSelectedStatistics
		);
		_p.finalize();
		handler.deliver(invokeResetSelectedStatsReturnValue);

	}
	else {
		String message;
		message.append("UNIX_BGPEndpointStatistics");
		message.append (" does not support invokeMethod");
		throw CIMNotSupportedException(message);
	}
}
Beispiel #2
0
void TimingProvider::modifyInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance & instanceObject,
    const Boolean includeQualifiers,
    const CIMPropertyList & propertyList,
    ResponseHandler & handler)
{
    // convert a potential fully qualified reference into a local reference
    // (class name and keys only).
    CIMObjectPath localReference = CIMObjectPath(
        String(),
        String(),
        instanceReference.getClassName(),
        instanceReference.getKeyBindings());
    cout <<"TimingProvider::modifyInstance" << endl;
    // begin processing the request
    handler.processing();

    // instance index corresponds to reference index
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(localReference == _instanceNames[i])
        {
            // overwrite existing instance
            _instances[i] = instanceObject;

            break;
        }
    }
    // complete processing the request
    handler.complete();
}
Beispiel #3
0
void IBM_CIMOMStatDataProvider::getInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
        const Boolean includeQualifiers,
        const Boolean includeClassOrigin,
        const CIMPropertyList & propertyList,
	InstanceResponseHandler & handler)
{
	CIMObjectPath localReference = CIMObjectPath(
		String::EMPTY,
		CIMNamespaceName(),
		instanceReference.getClassName(),
		instanceReference.getKeyBindings());

	// begin processing the request
	handler.processing();

	// instance index corresponds to reference index
	for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
	{ // cout << "loop" << endl;
		if(localReference == _references[i])
		{
			// deliver requested instance
			handler.deliver(getInstance(i));
			break;
		}
	}

	// complete processing the request
	handler.complete();
}
Beispiel #4
0
static void _BubbleSort(Array<CIMKeyBinding>& x)
{
    Uint32 n = x.size();

    //
    //  If the key is a reference, the keys in the reference must also be
    //  sorted
    //
    for (Uint32 k = 0; k < n ; k++)
        if (x[k].getType () == CIMKeyBinding::REFERENCE)
        {
            CIMObjectPath tmp (x[k].getValue ());
            Array <CIMKeyBinding> keyBindings = tmp.getKeyBindings ();
            _BubbleSort (keyBindings);
            tmp.setKeyBindings (keyBindings);
            x[k].setValue (tmp.toString ());
        }

    if (n < 2)
        return;

    for (Uint32 i = 0; i < n - 1; i++)
    {
        for (Uint32 j = 0; j < n - 1; j++)
        {
            if (String::compareNoCase(x[j].getName().getString(),
                                      x[j+1].getName().getString()) > 0)
            {
                CIMKeyBinding t = x[j];
                x[j] = x[j+1];
                x[j+1] = t;
            }
        }
    }
}
void _getKeyValue (
    const CIMObjectPath&  instanceName,
    CIMNamespaceName& childNamespaceName,
    Boolean& isRelativeName)

{

    Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings();
    if ((kbArray.size() == 1) &&
            (kbArray[0].getName() == NAMESPACE_PROPERTYNAME))
    {
        String childNamespaceString = kbArray[0].getValue();

        if (childNamespaceString != String::EMPTY)
        {
            childNamespaceName = childNamespaceString;
        }

        isRelativeName = !(childNamespaceName.isNull());
    }
    else
    {
        //l10n
        //throw CIMInvalidParameterException("Invalid key property:  ");
        throw CIMInvalidParameterException(MessageLoaderParms(
                                               "ControlProviders.NamespaceProvider.NamespaceProvider.INVALID_KEY_PROPERTY",
                                               "Invalid key property:  "));
    }
}
void InstanceProvider::deleteInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	ResponseHandler & handler)
{
	// convert a potential fully qualified reference into a local reference
	// (class name and keys only).
	CIMObjectPath localReference = CIMObjectPath(
		String(),
		CIMNamespaceName(),
		instanceReference.getClassName(),
		instanceReference.getKeyBindings());
	
	// begin processing the request
	handler.processing();

	// instance index corresponds to reference index
	for(Uint32 i = 0, n = _instances.size(); i < n; i++)
	{
		if(localReference == _instances[i].getPath())
		{
			// remove instance from the array
			_instances.remove(i);

			break;
		}
	}
	
	// complete processing the request
	handler.complete();
}
void LargeDataProvider::getInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & propertyList,
    InstanceResponseHandler & handler)
{
    cout << "------------------------------" << endl;
    cout << "LargeDataProvider::getInstance" << endl;
    cout << "------------------------------" << endl;
    // convert a potential fully qualified reference into a local reference
    // (class name and keys only).
    CIMObjectPath localReference = CIMObjectPath(
        String(),
        String(),
        instanceReference.getClassName(),
        instanceReference.getKeyBindings());

    // begin processing the request
    handler.processing();

    // instance index corresponds to reference index
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(localReference == _instanceNames[i])
        {
            // deliver requested instance
            handler.deliver(_instances[i]);
            break;
        }
    }
    // complete processing the request
    handler.complete();
}
void ComputerSystemProvider::getInstance(
    const OperationContext& context,
    const CIMObjectPath& ref,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList& propertyList,
    InstanceResponseHandler &handler)
{
    CIMName className = ref.getClassName();
    _checkClass(className);

    Array<CIMKeyBinding> keys = ref.getKeyBindings();

    //-- make sure we're the right instance
    unsigned int keyCount = NUMKEYS_COMPUTER_SYSTEM;
    CIMName keyName;
    String keyValue;

    if (keys.size() != keyCount)
    {
        throw CIMInvalidParameterException("Wrong number of keys");
    }

    for (unsigned int ii = 0; ii < keys.size(); ii++)
    {
        keyName = keys[ii].getName();
        keyValue = keys[ii].getValue();

        //Put CLASS_EXTENDED_COMPUTER_SYSTEM in front CLASS_CIM_COMPUTER_SYSTEM
        //to prefer CLASS_EXTENDED_COMPUTER_SYSTEM as class being served first
        //followed by CLASS_CIM_UNITARY_COMPUTER_SYSTEM
        if (keyName.equal(PROPERTY_CREATION_CLASS_NAME) &&
            (String::equalNoCase(keyValue,CLASS_EXTENDED_COMPUTER_SYSTEM) ||
             String::equalNoCase(keyValue,CLASS_CIM_UNITARY_COMPUTER_SYSTEM) ||
             String::equalNoCase(keyValue,CLASS_CIM_COMPUTER_SYSTEM) ||
             String::equalNoCase(keyValue,String::EMPTY)))
        {
            keyCount--;
        }
        else if (keyName.equal("Name") &&
                 String::equalNoCase(keyValue,_cs.getHostName()))
        {
            keyCount--;
        }
    }

    if (keyCount)
    {
        throw CIMInvalidParameterException(String::EMPTY);
    }

    // return instance of specified class
    CIMInstance instance = _cs.buildInstance(ref.getClassName());

    handler.processing();
    handler.deliver(instance);
    handler.complete();

    return;
}
void AuditLogger::logUpdateInstanceOperation(
    const char* cimMethodName,
    AuditEvent eventType,
    const String& userName,
    const String& ipAddr,
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& instanceName,
    const String& moduleName,
    const String& providerName,
    CIMStatusCode statusCode)
{
    // check if SMF is gathering this type of records.
    if (_smf.isRecording(CIM_OPERATION) ||
        (! _isInternalWriterUsed) )
    {
        String cimInstanceName =
            CIMObjectPath("", CIMNamespaceName(), instanceName.getClassName(),
            instanceName.getKeyBindings()).toString();

        _writeCIMOperationRecord(
            INSTANCE_OPERATION, userName, statusCode,
            ipAddr, cimMethodName, cimInstanceName,
            nameSpace.getString(), providerName, moduleName );
    }
}
Beispiel #10
0
void ANHProvider::references(
        const OperationContext& context,
        const CIMObjectPath& objectName,
        const CIMName& resultClass,
        const String& role,
        const Boolean includeQualifiers,
        const Boolean includeClassOrigin,
        const CIMPropertyList& propertyList,
        ObjectResponseHandler& handler)
{
    // validate namespace
    const CIMNamespaceName& nameSpace = objectName.getNameSpace();
    if (!nameSpace.equal(NAMESPACE))
    {
        throw CIMNotSupportedException(
            nameSpace.getString() + " not supported.");
    }

    // Build a host and namespace independent object path
    CIMObjectPath localObjectPath = CIMObjectPath(
            String(),
            CIMNamespaceName(),
            objectName.getClassName(),
            objectName.getKeyBindings());

    // begin processing the request
    handler.processing();

    // Filter the instances from the list of association instances against
    // the specified role filter
    //
    Array<CIMInstance> resultInstances;
    if (resultClass == CLASS_PG_ASSOCIATED_NEXT_HOP)
    {
        resultInstances =
            _filterAssociationInstancesByRole(
                _AssociationInstances,
                localObjectPath, 
                role);
    }
    else
    {
        throw CIMNotSupportedException(
            resultClass.getString() + " is not supported");
    }

    // return the instances
    for (Uint32 i = 0, n = resultInstances.size(); i < n; i++)
    {
        handler.deliver(resultInstances[i]);
    }

    // complete processing the request
    handler.complete();
}
Beispiel #11
0
void DefaultInstanceProvider::deleteInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	ResponseHandler & handler)
{
        CIMNamespaceName nameSpace = instanceReference.getNameSpace();

        // get the class name
        CIMName className = instanceReference.getClassName();

        // create the namespace if necessary
        if (!_nameSpaceExists(nameSpace))
        {
            _copyNameSpace(nameSpace.getString(), className.getString());
        }

        // check to see if class already exists
        // if not, copy the class
        //
        try
        {
            CIMClass cimClass = _repository->getClass(nameSpace, className);
        }
        catch (Exception&)
        {
            // Class does not exist.  Copy the class.
            //
            _copyClass(nameSpace.getString(), className.getString()); 
        }

	// convert a potential fully qualified reference into a local reference
	// (class name and keys only).
	CIMObjectPath localReference = CIMObjectPath(
		String(),
		String(),
		instanceReference.getClassName(),
		instanceReference.getKeyBindings());
	
	// begin processing the request
	handler.processing();

        try
        {
           _repository->deleteInstance(nameSpace, localReference);
        }
        catch (Exception & ex)
        {
            const String msg = "delete Instance failed. " + ex.getMessage();
            throw CIMOperationFailedException( msg );
        }

	// complete processing the request
	handler.complete();
}
Beispiel #12
0
void ANHProvider::associators(
        const OperationContext& context,
        const CIMObjectPath& objectName,
        const CIMName& associationClass,
        const CIMName& resultClass,
        const String& role,
        const String& resultRole,
        const Boolean includeQualifiers,
        const Boolean includeClassOrigin,
        const CIMPropertyList& propertyList,
        ObjectResponseHandler& handler)
{

    // validate namespace
    const CIMNamespaceName& nameSpace = objectName.getNameSpace();
    if (!nameSpace.equal(NAMESPACE))
    {
        throw CIMNotSupportedException(
            nameSpace.getString() + " not supported.");
    }


    // Build a host and namespace independent object path
    CIMObjectPath localObjectPath = CIMObjectPath(
        String(),
        CIMNamespaceName(),
        objectName.getClassName(),
        objectName.getKeyBindings());

    // begin processing the request
    handler.processing();

    if (associationClass == CLASS_PG_ASSOCIATED_NEXT_HOP)
    {
        _associators(
            _AssociationInstances,
            localObjectPath, 
            role,
            resultClass, 
            resultRole, 
            handler);
    }
    else
    {
        throw CIMNotSupportedException(
            associationClass.getString() + " is not supported");
    }

    // complete processing the request
    handler.complete();
}
Beispiel #13
0
Boolean isValid(const CIMObjectPath & cimObjectPath)
{
    if(!String::equalNoCase(cimObjectPath.getClassName().getString(), CLASSNAME))
    {
        return(false);
    }

    if(cimObjectPath.getKeyBindings().size() == 0)  // singleton?
    {
        return(false);
    }

    return(true);
}
Beispiel #14
0
void MethodProvider::invokeMethod(
    const OperationContext & context,
    const CIMObjectPath & objectReference,
    const CIMName & methodName,
    const Array<CIMParamValue> & inParameters,
    MethodResultResponseHandler & handler)
{
    // convert a fully qualified reference into a local reference
    // (class name and keys only).
    CIMObjectPath localReference = CIMObjectPath(
        String(),
        CIMNamespaceName(),
        objectReference.getClassName(),
        objectReference.getKeyBindings());

    handler.processing();

    if (objectReference.getClassName().equal("Sample_MethodProviderClass"))
    {
        if (methodName.equal("SayHello"))
        {
            String outString = "Hello";
            if (inParameters.size() > 0)
            {
                CIMValue paramVal = inParameters[0].getValue();
                if (!paramVal.isNull())
                {
                    String replyName;
                    paramVal.get(replyName);
                    if (replyName != String::EMPTY)
                    {
                        outString.append(", " + replyName + "!");
                    }
                }

                handler.deliverParamValue(
                    CIMParamValue("Place",
                        CIMValue(String("From Neverland"))));
                handler.deliver(CIMValue(outString));
            }
            else
            {
                handler.deliver(CIMValue(outString));
            }
        }
    }
    
    handler.complete();
}
Beispiel #15
0
void
LinuxNetworkAdapterProvider::getInstance(const OperationContext& context,
					 const CIMObjectPath& ref,
					 const Boolean includeQualifiers,
					 const Boolean includeClassOrigin,
					 const CIMPropertyList& propertyList,
					 InstanceResponseHandler& handler)
{
   Array<CIMKeyBinding> keys = ref.getKeyBindings();
   Uint32 i;
   NetworkAdapterData* located_interface;
   String unique_name;
   CIMName className;
   enum network_provider_types classType;

   className = ref.getClassName();
   if (className.equal("Linux_EthernetAdapter"))
   {
      classType = NETWORK_ADAPTER_PROVIDER_ETHERNET;
   }
   else if (className.equal("Linux_NetworkAdapter"))
   {
      classType = NETWORK_ADAPTER_PROVIDER_OTHER;
   }
   else
   {
      throw CIMNotSupportedException(className.getString() + "::getInstance");
   }
 
   for (i = 0; i < keys.size(); i++)
      if (keys[i].getName() == CIMName("Name"))
         unique_name = keys[i].getValue();
 
   handler.processing();
 
   located_interface = LocateInterface(unique_name);
   
   if (located_interface != NULL && interface_is_my_type(classType,located_interface))
   {
      CIMInstance instance = build_instance(className, classType, located_interface);
      handler.deliver(instance);
   }
 
   delete located_interface;
 
   handler.complete();
   return;
}
Beispiel #16
0
void ParserTestProvider::getInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & propertyList,
    InstanceResponseHandler & handler)
{
    String Value;
    char csname[256];
    int cnum;
    char badstrname[256];

    cout << "ParserTestProvider::getInstance" << endl;

    CIMName className = instanceReference.getClassName();
    CIMNamespaceName nameSpace = instanceReference.getNameSpace();

    Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();

    for (int i = 0; i < (int)keys.size(); i++)
    {
        CIMName cimName = keys[i].getName();
        Value = keys[i].getValue();

        if (cimName.equal("BadStringName")) {
                strncpy(badstrname, Value.getCString(), 256);
        }
    }
    CIMInstance instance(CLASS_NAME);
    instance.setPath(CIMObjectPath(String::EMPTY, // hostname
                                      nameSpace,
                                      CLASS_NAME,
                                      keys));
    instance.addProperty(CIMProperty("CName",
                         String(CLASS_NAME)));
    instance.addProperty(CIMProperty("BadStringName",
                         String(badstrname)));
    
    //begin processing the request
    handler.processing();

    handler.deliver(instance);
    // complete processing the request
    handler.complete();
}
Beispiel #17
0
void RUEpProvider::associatorNames(
        const OperationContext& context,
        const CIMObjectPath& objectName,
        const CIMName& associationClass,
        const CIMName& resultClass,
        const String& role,
        const String& resultRole,
        ObjectPathResponseHandler& handler)
{
    // validate namespace
    const CIMNamespaceName& nameSpace = objectName.getNameSpace();
    if (!nameSpace.equal(NAMESPACE))
    {
        throw CIMNotSupportedException(
            nameSpace.getString() + " not supported.");
    }

    // Build a host and namespace independent object path
    CIMObjectPath localObjectPath = CIMObjectPath(
        String(),
        CIMNamespaceName(),
        objectName.getClassName(),
        objectName.getKeyBindings());

    // begin processing the request
    handler.processing();

    if (associationClass == CLASS_PG_ROUTE_USES_ENDPOINT)
    {
        _associatorNames(
            _AssociationInstances,
            localObjectPath,
            role,
            resultClass,
            resultRole,
            handler);
    }
    else
    {
        throw CIMNotSupportedException(
            associationClass.getString() + " is not supported");
    }

    // complete processing the request
    handler.complete();
}
Beispiel #18
0
void _checkFilterOrHandlerPath
  (const CIMObjectPath & path, const CIMName & className, const String & name)
{
  PEGASUS_ASSERT (path.getClassName () == className);
  Array < CIMKeyBinding > keyBindings = path.getKeyBindings ();
  Boolean SCCNfound = false;
  Boolean SNfound = false;
  Boolean CCNfound = false;
  Boolean Nfound = false;
  for (Uint32 i = 0; i < keyBindings.size (); i++)
    {
      if (keyBindings[i].getName ().equal ("SystemCreationClassName"))
	{
	  SCCNfound = true;
	  PEGASUS_ASSERT (keyBindings[i].getValue () ==
			  System::getSystemCreationClassName ());
	}
      else if (keyBindings[i].getName ().equal ("SystemName"))
	{
	  SNfound = true;
	  PEGASUS_ASSERT (keyBindings[i].getValue () ==
			  System::getFullyQualifiedHostName ());
	}
      else if (keyBindings[i].getName ().equal ("CreationClassName"))
	{
	  CCNfound = true;
	  PEGASUS_ASSERT (keyBindings[i].getValue () ==
			  className.getString ());
	}
      else if (keyBindings[i].getName ().equal ("Name"))
	{
	  Nfound = true;
	  PEGASUS_ASSERT (keyBindings[i].getValue () == name);
	}
      else
	{
	  PEGASUS_ASSERT (false);
	}
    }

  PEGASUS_ASSERT (SCCNfound);
  PEGASUS_ASSERT (SNfound);
  PEGASUS_ASSERT (CCNfound);
  PEGASUS_ASSERT (Nfound);
}
CIMInstance ProviderIndicationCountTable::getProviderIndicationDataInstance(
    const CIMObjectPath& instanceName)
{
    PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
        "ProviderIndicationCountTable::getProviderIndicationDataInstance");

    //
    // Gets provider module name and provider name from the provider indication
    // data instance object path
    //
    String providerModuleName;
    String providerName;
    Array<CIMKeyBinding> keys = instanceName.getKeyBindings();

    for (Uint32 i = 0; i < keys.size(); i++)
    {
        if (keys[i].getName() == _PROPERTY_PROVIDERNAME)
        {
            providerName = keys[i].getValue();
        }
        else if (keys[i].getName() == _PROPERTY_PROVIDERMODULENAME)
        {
            providerModuleName = keys[i].getValue();
        }
    }

    String providerKey = _generateKey(providerModuleName, providerName);

    _ProviderIndicationCountTableEntry entry;

    WriteLock lock(_tableLock);

    if (_table.lookup(providerKey, entry))
    {
        CIMInstance providerIndDataInstance =
            _buildProviderIndDataInstance(entry);

        PEG_METHOD_EXIT();
        return providerIndDataInstance;
    }

    PEG_METHOD_EXIT();
    throw CIMObjectNotFoundException(instanceName.toString());
}
Beispiel #20
0
/**
   _validateKeys method of the OS provider Test Client
  */
void OSTestClient::_validateKeys(CIMObjectPath &cimRef, 
                                 Boolean verboseTest)
{
   // don't have a try here - want it to be caught by caller

   Array<CIMKeyBinding> keyBindings = cimRef.getKeyBindings();

   if (verboseTest)
      cout << "Retrieved " << keyBindings.size() << " keys" <<endl;

   for (Uint32 j = 0; j < keyBindings.size(); j++)
   {
      CIMName keyName = keyBindings[j].getName();
      if (verboseTest)
         cout << "checking key " << keyName << endl;
      if (((keyName.equal ("CSCreationClassName")) &&
          (goodCSCreationClassName(
               keyBindings[j].getValue(),
               verboseTest) == false))) 
      {
         errorExit ("CSCreationClassName not CIM_UnitaryComputerSystem");
      }
      else if ((keyName.equal ("CSName")) &&
               (goodCSName(keyBindings[j].getValue(),
                       verboseTest) == false))
      { 
         errorExit ("CSName not correct");
      }
      else if ((keyName.equal ("CreationClassName")) &&
          (goodCreationClassName( 
            keyBindings[j].getValue(),
            verboseTest) == false))
      { 
         errorExit ("CreationClassName not correct");
      }
      else if ((keyName.equal ("Name")) &&
                (goodName( 
                  keyBindings[j].getValue(),
                  verboseTest) == false))
      { 
         errorExit ("Name not correct");
      }
    }  // end for j looping through properties
}
Beispiel #21
0
void ExceptionsTest::getInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & propertyList,
    InstanceResponseHandler & handler)
{
    // convert a potential fully qualified reference into a local reference
    // (class name and keys only).
    CIMObjectPath localReference = CIMObjectPath(
        String(),
        String(),
        instanceReference.getClassName(),
        instanceReference.getKeyBindings());

    CIMName className = instanceReference.getClassName();
    
    // begin processing the request
    handler.processing();
    
    cout <<"Calling Exception ExceptionsTest::getInstance 1" << endl;
    CheckExceptionType(EXCEPTION_TYPE);
    
    if (className == CIMName("FirstClass"))
    {
        // instance index corresponds to reference index
        for(Uint32 i = 0, n = _instances.size(); i < n; i++)
        {
            if(localReference == _instanceNames[i])
            {
                // deliver requested instance
                handler.deliver(_instances[i]);
                break;
            }
        }
    }
    // complete processing the request
    handler.complete();
    cout <<"Calling Exception ExceptionsTest::getInstance 2" << endl;
    CheckExceptionType(EXCEPTION_TYPE);
}
void LargeDataProvider::createInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance & instanceObject,
    ObjectPathResponseHandler & handler)
{
    cout << "---------------------------------" << endl;
    cout << "LargeDataProvider::createInstance" << endl;
    cout << "---------------------------------" << endl;

    // convert a potential fully qualified reference into a local reference
    // (class name and keys only).
    CIMObjectPath localReference = CIMObjectPath(
        String(),
        String(),
        instanceReference.getClassName(),
        instanceReference.getKeyBindings());

    // instance index corresponds to reference index
    for(Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
    {
        if(localReference == _instanceNames[i])
        {
            throw CIMObjectAlreadyExistsException(
                                  localReference.toString());
        }
    }

    // begin processing the request
    handler.processing();

    // add the new instance to the array
    _instances.append(instanceObject);
    _instanceNames.append(instanceReference);

    // deliver the new instance
    handler.deliver(_instanceNames[_instanceNames.size() - 1]);

    // complete processing the request
    handler.complete();
}
Beispiel #23
0
/**
   _validateKeys method of the NIS provider Test Client
  */
void NISTestClient::_validateKeys(
    CIMObjectPath &cimRef,
    Boolean verboseTest)
{
    // don't have a try here - want it to be caught by caller
    String keyVal;
    CIMName keyName;
    Array<CIMKeyBinding> keyBindings = cimRef.getKeyBindings();

    if (verboseTest)
        cout << "Retrieved " << keyBindings.size() << " keys" <<endl;

    for (Uint32 j = 0; j < keyBindings.size(); j++)
    {
        keyName = keyBindings[j].getName();
        keyVal = keyBindings[j].getValue();
        if (verboseTest)
            cout << "checking key " << keyName.getString() << endl;

        if (keyName.equal("CreationClassName") &&
            !goodCreationClassName(keyVal, verboseTest))
        {
            errorExit ("CreationClassName not PG_NISServerService");
        }
        else if (keyName.equal("Name") &&
                 !goodName(keyVal, verboseTest))
        {
            errorExit ("Name not correct");
        }
        else if (keyName.equal("SystemCreationClassName") &&
                 !goodSystemCreationClassName(keyVal, verboseTest))
        {
            errorExit ("SystemCreationClassName not correct");
        }
        else if (keyName.equal("SystemName") &&
                 !goodSystemName(keyVal, verboseTest))
        {
            errorExit ("SystemName not correct");
        }
    }
}
Beispiel #24
0
/* SystemName key property should be set to fully qualified hostname
   which is set on cimserver at startup to "hugo.bert" before this test case
   is executed
 */
void testFilterSystemName(
    CIMClient & client)
{
    CIMInstance filter("CIM_IndicationFilter");
    String query("SELECT * FROM CIM_ProcessIndication");

    filter.addProperty(
        CIMProperty(CIMName("Name"),String("Filter01")));
    filter.addProperty(
        CIMProperty(CIMName("SourceNamespace"),String("root/SampleProvider")));

    filter.addProperty(
        CIMProperty(CIMName("Query"), query));
    filter.addProperty(
        CIMProperty(CIMName("QueryLanguage"),String("WQL")));

    CIMObjectPath path =
        client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, filter);
    
    client.deleteInstance(PEGASUS_NAMESPACENAME_INTEROP, path);

    // SystemName is fourth (=last) keybinding
    Array<CIMKeyBinding> keys = path.getKeyBindings();
    CIMKeyBinding sysName=keys[3];

    if (verbose)
    {
        cout << "SystemName returned is: " << sysName.getValue() << endl;
    }
    
    Boolean result = String("hugo.bert") == sysName.getValue();

    if(!result)
    {
       cout << "Test failed, Make sure that cimserver is started " \
               "with \"hostname=hugo fullyQualifiedHostName=hugo.bert\"" \
               << endl;
    }

    PEGASUS_TEST_ASSERT(result);
}
void benchmarkProvider::getInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & propertyList,
    InstanceResponseHandler & handler)
{
    CIMInstance _instance;
    Uint32 numberOfProperties;
    Uint32 sizeOfPropertyValue;
    Uint32 numberOfInstances;

    CIMName className = instanceReference.getClassName();
    test.getConfiguration(className, numberOfProperties,
                 sizeOfPropertyValue, numberOfInstances);

    Array<CIMKeyBinding> keyBindings = instanceReference.getKeyBindings();
    if (keyBindings.size() != 1)
    {
       throw CIMException(CIM_ERR_NOT_SUPPORTED);
    }
    
    // begin processing the request
    handler.processing();

    Uint32 ID;
    if (sscanf (keyBindings[0].getValue().getCString(), "%u", &ID) != 1)
    {
        throw CIMException (CIM_ERR_INVALID_PARAMETER);
    }

    _instance = _buildInstance(className, numberOfProperties,
                        sizeOfPropertyValue , CIMValue(ID));   

    handler.deliver(_instance);

    // complete processing the request
    handler.complete();
}
Beispiel #26
0
void ExceptionsTest::deleteInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    ResponseHandler & handler)
{
    // convert a potential fully qualified reference into a local reference
    // (class name and keys only).
    CIMObjectPath localReference = CIMObjectPath(
        String(),
        String(),
        instanceReference.getClassName(),
        instanceReference.getKeyBindings());

    // begin processing the request
    handler.processing();

    cout <<"Calling Exception ExceptionsTest::deleteInstance 1" << endl;
    CheckExceptionType(EXCEPTION_TYPE);
    // instance index corresponds to reference index
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(localReference == _instanceNames[i])
        {
            // save the instance locally
            CIMInstance cimInstance(_instances[i]);

            // remove instance from the array
            _instances.remove(i);
            _instanceNames.remove(i);

            // exit loop
            break;
        }
    }

    cout <<"Calling Exception ExceptionsTest::deleteInstance 2" << endl;
    CheckExceptionType(EXCEPTION_TYPE);
    // complete processing the request
    handler.complete();
}
Beispiel #27
0
void testEnumInstances(CIMClient& client, const char* ns)
{
    Array<CIMInstance> instances;

   instances = client.enumerateInstances(ns,CIM_QUERYCAPCLASS_NAME);

   if(instances.size() != 1) throw Exception("instances.size() incorrect");

   Array<Uint16> providerReturnedVal;
   //Array<Uint16> actualVal(NUM_QUERY_CAPABILITIES);
   Uint32 prop = 0;
   CIMObjectPath path;

   path = instances[0].getPath();
   Array<CIMKeyBinding> keys = path.getKeyBindings();

   //-- make sure we're the right instance
   CIMName keyName;
   String keyValue;

   if (keys.size() != NUM_KEY_PROPERTIES)
       throw Exception("Wrong number of keys");

    keyName = keys[0].getName();
    keyValue = keys[0].getValue();

    if(keyName.getString() != String(PROPERTY_NAME_INSTANCEID) )
        throw Exception("Incorrect Key");
    if(keyValue != String(INSTANCEID_VALUE))
        throw Exception(keyValue);

     prop = instances[0].findProperty(CIMName(PROPERTY_NAME_CQLFEATURES));
     instances[0].getProperty(prop).getValue().get(providerReturnedVal);

     _checkIfReturnedValueIsCorrect(providerReturnedVal);

}
Beispiel #28
0
void LinuxDiskDriveProvider::getInstance(const OperationContext& context,
					 const CIMObjectPath& ref,
					 const Boolean includeQualifiers,
					 const Boolean includeClassOrigin,
					 const CIMPropertyList& propertyList,
					 InstanceResponseHandler& handler)
{
   DiskDriveData diskdriveData;
   MediaAccessDeviceInformation *curDiskDrive;
   Array<CIMKeyBinding> keys = ref.getKeyBindings();
   Uint32 i;
   String nameString;

   handler.processing();

   /* Get the diskdrive that was requested */
   i = 0;
   while (i < keys.size())
   {
      if (keys[i].getName() == CIMName("Name"))
         nameString = keys[i].getValue();
      i++;
   }
   if (nameString != String::EMPTY)
   {
      curDiskDrive = diskdriveData.GetDiskDrive(nameString);    
      if (curDiskDrive!=NULL)
      {
         CIMInstance instance =
	         build_instance(DISKDRIVECLASSNAME, curDiskDrive);
         handler.deliver(instance);
         delete curDiskDrive;
      }
   }
   handler.complete();
   return;
}
Beispiel #29
0
void AuditLogger::logInvokeMethodOperation(
    const String& userName,
    const String& ipAddr,
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& objectName,
    const CIMName& methodName,
    const String& moduleName,
    const String& providerName,
    CIMStatusCode statusCode)
{
    // check if SMF is gathering this type of records.
    if (_smf.isRecording(CIM_OPERATION) ||
        (! _isInternalWriterUsed) )
    {
        String cimObjectName =
            CIMObjectPath("", CIMNamespaceName(), objectName.getClassName(),
            objectName.getKeyBindings()).toString();

        _writeCIMOperationRecord(
            INVOKE_METHOD, userName, statusCode,
            ipAddr, methodName.getString(), cimObjectName,
            nameSpace.getString(), providerName,moduleName );
    }
}
Beispiel #30
0
void _checkSubscriptionPath
  (const CIMObjectPath & path,
   const String & filterName,
   const CIMName & handlerClass, const String & handlerName)
{
  PEGASUS_ASSERT (path.getClassName () == PEGASUS_CLASSNAME_INDSUBSCRIPTION);
  Array < CIMKeyBinding > keyBindings = path.getKeyBindings ();
  Boolean filterFound = false;
  Boolean handlerFound = false;
  for (Uint32 i = 0; i < keyBindings.size (); i++)
    {
      if (keyBindings[i].getName ().equal ("Filter"))
	{
	  filterFound = true;
	  CIMObjectPath filterPath = _buildFilterOrHandlerPath
	    (PEGASUS_CLASSNAME_INDFILTER, filterName);
	  PEGASUS_ASSERT (keyBindings[i].getValue () ==
			  filterPath.toString ());
	}
      else if (keyBindings[i].getName ().equal ("Handler"))
	{
	  handlerFound = true;
	  CIMObjectPath handlerPath = _buildFilterOrHandlerPath
	    (handlerClass, handlerName);
	  PEGASUS_ASSERT (keyBindings[i].getValue () ==
			  handlerPath.toString ());
	}
      else
	{
	  PEGASUS_ASSERT (false);
	}
    }

  PEGASUS_ASSERT (filterFound);
  PEGASUS_ASSERT (handlerFound);
}