Ejemplo n.º 1
0
Array<CIMObjectPath> PG_TestPropertyTypes::_enumerateInstanceNames(
    const OperationContext& context,
    const CIMObjectPath& classReference)
{
    Array<CIMObjectPath> instanceNames;

    // get class definition from repository
    CIMClass cimclass = _cimom.getClass(
        context,
        classReference.getNameSpace(),
        classReference.getClassName(),
        false,
        true,
        true,
        CIMPropertyList());

    // convert instances to references;
    for (Uint32 i = 0; i < _instances.size(); i++)
    {
        CIMObjectPath tempRef = _instances[i].buildPath(cimclass);

        // ensure references are fully qualified
        tempRef.setHost(classReference.getHost());
        tempRef.setNameSpace(classReference.getNameSpace());

        instanceNames.append(tempRef);
    }

    return instanceNames;
}
Ejemplo n.º 2
0
void _testServiceAffectsElementInstances(CIMClient &client)
{
    cout << "Testing Association Class "
        << (const char *)PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT.
             getString().getCString()
        << "...";

    // Get PG_ServiceAffectsElement instances.
    Array<CIMInstance> sfInstances = client.enumerateInstances(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT);

    // Get PG_ServiceAffectsElement instance names
    Array<CIMObjectPath> sfPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT);

    PEGASUS_TEST_ASSERT(sfInstances.size() == sfPaths.size());

    // Get CIM_IndicationFilter instance names
    Array<CIMObjectPath> filterPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_INDFILTER);

    // Get CIM_ListenerDestination instance names
    Array<CIMObjectPath> handlerPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_LSTNRDST);

    // Count only handlers and filters from interop namespace
    Uint32 elements = 0;
    for (Uint32 i = 0; i < sfInstances.size() ; ++i)
    {
        CIMValue value = sfInstances[i].getProperty(
            sfInstances[i].findProperty("AffectedElement")).getValue();
        CIMObjectPath path;
        value.get(path);
        PEGASUS_TEST_ASSERT(path.getNameSpace() != CIMNamespaceName());
        if (path.getNameSpace() == PEGASUS_NAMESPACENAME_INTEROP)
        {
             elements++;
        }
    }
    PEGASUS_TEST_ASSERT(
        elements == (filterPaths.size() + handlerPaths.size()));

    cout << "Test Complete" << endl;
}
Ejemplo n.º 3
0
void PG_TestPropertyTypes::deleteInstance(
    const OperationContext& context,
    const CIMObjectPath& instanceReference,
    ResponseHandler& handler)
{
    // synchronously get references
    Array<CIMObjectPath> references =
        _enumerateInstanceNames(context, instanceReference);

    // ensure the Namespace is valid
    if (!instanceReference.getNameSpace().equal("test/static"))
    {
        throw CIMException(CIM_ERR_INVALID_NAMESPACE);
    }

    // ensure the class existing in the specified namespace
    if (!instanceReference.getClassName().equal("PG_TestPropertyTypes"))
    {
        throw CIMException(CIM_ERR_INVALID_CLASS);
    }

    // ensure the requested object exists
    Uint32 index = findObjectPath(references, instanceReference);
    if (index == PEG_NOT_FOUND)
    {
        throw CIMException(CIM_ERR_NOT_FOUND);
    }

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

    // we do not remove instance
    // complete processing the request
    handler.complete();
}
Ejemplo n.º 4
0
void
OperatingSystemProvider::enumerateInstanceNames(
      				const OperationContext& context,
			  	const CIMObjectPath &ref,
			  	ObjectPathResponseHandler& handler )
{
    CIMObjectPath newref;
    CIMName className;

    // only return instances when enumerate on our subclass, CIMOM
    // will call us as natural part of recursing through subtree on
    // enumerate - if we return instances on enumerate of our superclass,
    // there would be dups
    className = ref.getClassName();
    if (className.equal (STANDARDOPERATINGSYSTEMCLASS))
    {
        handler.processing();
        handler.complete();
        return;
    }
    else if (!className.equal (EXTENDEDOPERATINGSYSTEMCLASS))
    {
        throw CIMNotSupportedException("OperatingSystemProvider "
                       "does not support class " + className.getString());
    }

    // so we know it is for EXTENDEDOPERATINGSYSTEMCLASS
    handler.processing();
    // in terms of the class we use, want to set to what was requested
    newref = _fill_reference(ref.getNameSpace(), className);
    handler.deliver(newref);
    handler.complete();

    return;
}
Ejemplo n.º 5
0
void ParserTestProvider::enumerateInstanceNames(
    const OperationContext & context,
    const CIMObjectPath & classReference,
    ObjectPathResponseHandler & handler)
{
    //DEBUG("enumerateInstanceNames()");

    // begin processing the request
    CIMName className = classReference.getClassName();
    CIMNamespaceName nameSpace = classReference.getNameSpace();
    //DEBUG("[className: "<<className<<"], [in namespace: "<<nameSpace<<"]");

    handler.processing();

    Array<CIMKeyBinding> keys;

    keys.append(CIMKeyBinding("CName", 
                    String(CLASS_NAME),
                    CIMKeyBinding::STRING));
    keys.append(CIMKeyBinding("BadStr", 
                    String(BADSTR_1),
                    CIMKeyBinding::STRING));
    
    CIMObjectPath obj_path = CIMObjectPath(String(), 
                                nameSpace, 
                                className,
                                keys);
    handler.deliver(obj_path);
    // complete processing the request
    handler.complete();
}
Ejemplo n.º 6
0
void ComputerSystemProvider::enumerateInstanceNames(
    const OperationContext& context,
    const CIMObjectPath &ref,
    ObjectPathResponseHandler& handler)
{
    CIMName className = ref.getClassName();
    _checkClass(className);

    handler.processing();

    // Deliver instance only if request was for leaf class
    if (className.equal(CLASS_EXTENDED_COMPUTER_SYSTEM))
    {
        Array<CIMKeyBinding> keys;

        keys.append(CIMKeyBinding(
            PROPERTY_CREATION_CLASS_NAME,
            CLASS_EXTENDED_COMPUTER_SYSTEM,
            CIMKeyBinding::STRING));
        keys.append(CIMKeyBinding(
            PROPERTY_NAME,
            _cs.getHostName(),
            CIMKeyBinding::STRING));

        handler.deliver(CIMObjectPath(
            _cs.getHostName(),
            ref.getNameSpace(),
            CLASS_EXTENDED_COMPUTER_SYSTEM,
            keys));
    }

    handler.complete();
    return;
}
Ejemplo n.º 7
0
void PG_TestPropertyTypes::enumerateInstanceNames(
    const OperationContext& context,
    const CIMObjectPath& classReference,
    ObjectPathResponseHandler& handler)
{

    // ensure the Namespace is valid
    if (!classReference.getNameSpace().equal ("test/static"))
    {
        throw CIMException(CIM_ERR_INVALID_NAMESPACE);
    }

    // ensure the class existing in the specified namespace
    if (!classReference.getClassName().equal ("PG_TestPropertyTypes"))
    {
        throw CIMException(CIM_ERR_INVALID_CLASS);
    }

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

    Array<CIMObjectPath> instanceNames;
    instanceNames = _enumerateInstanceNames(context, classReference);

    handler.deliver(instanceNames);

    // complete processing the request
    handler.complete();
}
Ejemplo n.º 8
0
void PG_TestPropertyTypes::enumerateInstances(
    const OperationContext& context,
    const CIMObjectPath& ref,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList& propertyList,
    InstanceResponseHandler& handler)
{

    // ensure the Namespace is valid
    if (!ref.getNameSpace().equal ("test/static"))
    {
        throw CIMException(CIM_ERR_INVALID_NAMESPACE);
    }

    // ensure the class existing in the specified namespace
    if (!ref.getClassName().equal ("PG_TestPropertyTypes"))
    {
        throw CIMException(CIM_ERR_INVALID_CLASS);
    }

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

    // NOTE: It would be much more efficient to remember the instance names

    // get class definition from repository
    CIMClass cimclass = _cimom.getClass(
        context,
        ref.getNameSpace(),
        ref.getClassName(),
        false,
        true,
        true,
        CIMPropertyList());

    for (Uint32 i = 0; i < _instances.size(); i++)
    {
        handler.deliver(_instances[i]);
    }

    // complete processing the request
    handler.complete();
}
Ejemplo n.º 9
0
void DefaultInstanceProvider::enumerateInstanceNames(
	const OperationContext & context,
	const CIMObjectPath & classReference,
	ObjectPathResponseHandler & handler)
{
        CIMNamespaceName nameSpace = classReference.getNameSpace();
        CIMName className = classReference.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()); 
        }

        Array<CIMObjectPath> instanceNames;

        try
        {
            instanceNames = _repository->enumerateInstanceNamesForClass(
                                               nameSpace, className, true);
        }
        catch (Exception & ex)
        {
            const String msg = "Enumerate InstanceNames failed. " + ex.getMessage();
            throw CIMOperationFailedException( msg );
        }
    
	// begin processing the request
	handler.processing();

	for(Uint32 i = 0, n = instanceNames.size(); i < n; i++)
	{
		// deliver reference
		handler.deliver(instanceNames[i]);
	}

	// complete processing the request
	handler.complete();
}
Ejemplo n.º 10
0
ProviderName::ProviderName(
    const CIMObjectPath & path,
    const Uint32 capabilities,
    const CIMName & method)
    : _capabilities(capabilities)
{
    _nameSpace = path.getNameSpace();
    _className = path.getClassName();
    _method = method;
}
Ejemplo n.º 11
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();
}
Ejemplo n.º 12
0
void DefaultInstanceProvider::createInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	const CIMInstance & instanceObject,
	ObjectPathResponseHandler & 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()); 
        }

        CIMObjectPath cimRef;

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

        try
        {
            cimRef = _repository->createInstance(nameSpace, instanceObject);
        }
        catch (Exception & ex)
        {
            const String msg = "create Instance failed. " + ex.getMessage();
            throw CIMOperationFailedException( msg );
        }

	// deliver the new instance
	handler.deliver(cimRef);

	// complete processing the request
	handler.complete();
}
Ejemplo n.º 13
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();
}
Ejemplo n.º 14
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();
}
Ejemplo n.º 15
0
void PG_TestPropertyTypes::modifyInstance(
    const OperationContext& context,
    const CIMObjectPath& instanceReference,
    const CIMInstance& instanceObject,
    const Boolean includeQualifiers,
    const CIMPropertyList& propertyList,
    ResponseHandler& handler)
{
    // This provider only allows partial instance modification for the
    // PropertyUint8 property.
    if (!(propertyList.isNull() ||
          ((propertyList.size() == 1) &&
           (propertyList[0].equal("PropertyUint8")))))
    {
        throw CIMException(CIM_ERR_NOT_SUPPORTED);
    }

    // synchronously get references
    Array<CIMObjectPath> references =
        _enumerateInstanceNames(context, instanceReference);

    // ensure the Namespace is valid
    if (!instanceReference.getNameSpace().equal("test/static"))
    {
        throw CIMException(CIM_ERR_INVALID_NAMESPACE);
    }

    // ensure the class existing in the specified namespace
    if (!instanceReference.getClassName().equal("PG_TestPropertyTypes"))
    {
        throw CIMException(CIM_ERR_INVALID_CLASS);
    }

    // ensure the property values are valid
    _testPropertyTypesValue(instanceObject);

    // ensure the request object exists
    Uint32 index = findObjectPath(references, instanceReference);
    if (index == PEG_NOT_FOUND)
    {
        throw CIMException(CIM_ERR_NOT_FOUND);
    }

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

    // We do nothing here since we like to have static result
    // complete processing the request
    handler.complete();
}
PEGASUS_NAMESPACE_BEGIN

/*
    ATTN: This method provider is used by ProviderRegistrationProvider to 
    update InteropProvider Cache. If SLP is enabled we invoke SLPProvider's
    'update' method to update registrations in this method. Note that 
    'updateCache' method is not defined as part of class 
    PG_ProviderProfileCapabilities. This method is used purely for internal
    purpose for the communication between InteropProvider and 
    ProviderRegistrationProvider.
*/

void InteropProvider::invokeMethod(
    const OperationContext & context,
    const CIMObjectPath & objectReference,
    const CIMName & methodName,
    const Array<CIMParamValue> & inParameters,
    MethodResultResponseHandler & handler)
{
    if(objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP)
        && objectReference.getClassName().equal(
            PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES)
        && methodName.equal("updateCache"))
    {
        handler.processing();
#ifdef PEGASUS_ENABLE_SLP
        sendUpdateRegMessageToSLPProvider(context);
#endif
        updateProfileCache++;
        handler.complete();
    }
    else
    {
        throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
            objectReference.getNameSpace().getString());
    }
}
Ejemplo n.º 17
0
//////////////////////////////////////////////////////////////////////////////
// This isn't used.  If we ever need it we can uncomment it.
// void CIMLocalClassPathtoXML(CIMObjectPath const& cop, ostream& ostr)
// {
//     if (!cop.isClassPath())
//     {
//         OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, "cop is an instance path, not a class path as expected.");
//     }
//
//     if (!cop.getNameSpace().empty())
//     {
//         // do <LOCALCLASSPATH>
//         ostr << "<LOCALCLASSPATH>";
//         CIMtoXML(cop.getFullNameSpace(),ostr,CIMtoXMLFlags::doLocal);
//         ostr << "<CLASSNAME NAME=\"" << cop.getObjectName() << "\"/></LOCALCLASSPATH>";
//     }
//     else
//     {
//         // do <CLASSNAME>
//         ostr << "<CLASSNAME NAME=\"" << cop.getObjectName() << "\"/>";
//     }
// }
/////////////////////////////////////////////////////////////
// void
// CIMClassPathtoXML(CIMObjectPath const& cop, std::ostream& ostr)
// {
//     if (!cop.isClassPath())
//     {
//         OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, "cop is an instance path, not a class path as expected.");
//     }
//
//     ostr << "<CLASSPATH>";
//     CIMtoXML(cop.getFullNameSpace(), ostr, CIMtoXMLFlags::dontDoLocal);
//
//     ostr << "<CLASSNAME NAME=\"";
//     ostr << cop.getObjectName() << "\">";
//
//     ostr << "</CLASSNAME>";
//
//     ostr << "</CLASSPATH>\n";
// }
//////////////////////////////////////////////////////////////////////////////
void CIMInstancePathtoXML(CIMObjectPath const& cop, ostream& ostr)
{
	//
	// Instance path
	//
	bool outputInstancePath = !cop.getNameSpace().empty();
	if (outputInstancePath)
	{
		ostr << "<INSTANCEPATH>";
		CIMNameSpacetoXML(cop.getFullNameSpace(), ostr);
	}
	CIMInstanceNametoXML(cop, ostr);
	if (outputInstancePath)
	{
		ostr << "</INSTANCEPATH>";
	}
}
Ejemplo n.º 18
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();
}
Ejemplo n.º 19
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();
}
Ejemplo n.º 20
0
/*
================================================================================
NAME              : enumerateInstanceNames
DESCRIPTION       : Enumerates all of the IPProtocolEndpoint instance names.
                  : An array of instance references is returned.
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             : Localization is not supported by this provider.
PARAMETERS        :
================================================================================
*/
void BIPTLEpProvider::enumerateInstanceNames(const OperationContext &ctx,
                            const CIMObjectPath &ref,
                            ObjectPathResponseHandler &handler)
{
#ifdef DEBUG
    cout << "BIPTLEpProvider::enumerateInstanceNames()" << endl;
#endif

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

    // Validate the classname
    _checkClass(className);

    // Notify processing is starting
    handler.processing();

    int i;
    InterfaceList _ifList;

#ifdef DEBUG
    cout << "BIPTLEpProvider::enumerateInstanceNames() _ifList Initialized"
      	 << endl;
#endif

    for (i = 0; i < _ifList.size(); i++)
    {
	IPInterface _ipif = _ifList.getInterface(i);

	if (_ipif.bindsToLANInterface())
	{
	    // Deliver the names
	    handler.deliver(
		CIMObjectPath(String::EMPTY, // hostname
			nameSpace, CLASS_PG_BINDS_IP_TO_LAN_ENDPOINT,
			_constructKeyBindings(nameSpace, _ipif) ) );
	}
    }

    // Notify processing is complete
    handler.complete();

    return;

}  // enumerateInstanceNames
void OW_BinarySerializationTestCases::testSomething()
{
        StringArray cmd; 
        cmd.push_back("/bin/cat"); 
        CIMObjectPath origCop("ClassName", "ns"); 
        PopenStreams rval = OpenWBEM::Exec::safePopen(cmd); 
        IOIFCStreamBuffer stdinbuf(rval.in().getPtr(), 256, "out"); 
        IOIFCStreamBuffer stdoutbuf(rval.out().getPtr(), 256, "in"); 
        ostream stdinstr(&stdinbuf); 
        istream stdoutstr(&stdoutbuf); 
        OpenWBEM::BinarySerialization::writeObjectPath(stdinstr, origCop); 
        stdinstr.flush(); 
        rval.in()->close(); 
        CIMObjectPath newCop = OpenWBEM::BinarySerialization::readObjectPath(stdoutstr); 
        unitAssert(rval.getExitStatus() == 0); 
        unitAssert(newCop.getClassName() == "ClassName"); 
        unitAssert(newCop.getNameSpace() == "ns"); 
}
Ejemplo n.º 22
0
static void _inject_object_path(
    CIMInstance& instance,
    const CIMObjectPath& objectPath,
    const char* tag)
{
    Array<CIMKeyBinding> bindings;

    bindings.append(CIMKeyBinding("Tag", tag, CIMKeyBinding::STRING));

    bindings.append(CIMKeyBinding(
        "CreationClassName", "Benchmark2", CIMKeyBinding::STRING));

    instance.setPath(CIMObjectPath(
        objectPath.getHost(),
        objectPath.getNameSpace(),
        "Benchmark2",
        bindings));
}
Ejemplo n.º 23
0
static void valueToXML(CIMObjectPath const& x, ostream& out)
{
	if (x.getFullNameSpace().isLocal())
	{
		if (x.getNameSpace().empty())
		{
			CIMInstanceNametoXML(x, out);
		}
		else
		{
			CIMLocalInstancePathtoXML(x, out);
		}
	}
	else
	{
		CIMInstancePathtoXML(x, out);
	}
}
Ejemplo n.º 24
0
void CIMClassPathtoXML(CIMObjectPath const& cop, ostream& ostr)
{
	if (!cop.isClassPath())
	{
		OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, "cop is an instance path, not a class path as expected.");
	}
	if (!cop.getNameSpace().empty())
	{
		// do <CLASSPATH>
		ostr << "<CLASSPATH>";
		CIMNameSpacetoXML(cop.getFullNameSpace(),ostr);
		ostr << "<CLASSNAME NAME=\"" << cop.getClassName() << "\"/></CLASSPATH>";
	}
	else
	{
		// do <CLASSNAME>
		ostr << "<CLASSNAME NAME=\"" << cop.getClassName() << "\"/>";
	}
}
void UNIX_PROVIDER::enumerateInstanceNames(const OperationContext &ctx,
                            const CIMObjectPath &ref,
                            ObjectPathResponseHandler &handler)
{
    int pIndex;
    CLASS_IMPLEMENTATION _p;
    CIMName className = ref.getClassName();
    CIMNamespaceName nameSpace = ref.getNameSpace();

    // Validate the classname
    _checkClass(className);

    // Notify processing is starting
    handler.processing();

    // We are only going to respond to enumeration requests on
    // CLASS_UNIX_PROCESS
    if (className.equal (_getBaseClassCimName())
    || className.equal(_getClassCimName()))
    {
      // Get the process information and deliver an ObjectPath for
      // each process
      // Note that loadProcessInfo modifies pIndex to point to the
      // next process structure before the loop increments it!
      _p.initialize();
      for (pIndex = 0; _p.load(pIndex); pIndex++)
      {
        // Deliver the names
        handler.deliver(CIMObjectPath(String(""), // hostname
                                      nameSpace,
                                      _getClassCimName(),
                                      _constructKeyBindings(_p)));

      }
	  _p.finalize();
    }

    // Notify processing is complete
    handler.complete();

    return;

}  // enumerateInstanceNames
Ejemplo n.º 26
0
void
LinuxNetworkAdapterProvider::enumerateInstanceNames(
      				   const OperationContext& context,
				   const CIMObjectPath& ref,
				   ObjectPathResponseHandler& handler )
{
   int i;
   vector<String> adapter_names;
   NetworkAdapterData *iface;
   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() +
		                     "::enumerateInstanceNames");
   }

   adapter_names = NetworkAdapterData::list_all_adapters();

   handler.processing();

   for (i = 0; i < (int) adapter_names.size(); i++)
   {
      iface = LocateInterface(adapter_names[i]);
      if (iface != NULL && interface_is_my_type(classType, iface))
         handler.deliver(fill_reference(ref.getNameSpace(), 
				        className, iface));
      delete iface;
   }

   handler.complete();
}
void UNIX_PROVIDER::execQuery(
       const OperationContext& context,
       const CIMObjectPath& objectPath,
       const QueryExpression& query,
       InstanceResponseHandler& handler)
{
	CIMName className;
    CIMInstance instance;
    CLASS_IMPLEMENTATION _p;
    className = objectPath.getClassName();
    CIMNamespaceName nameSpace = objectPath.getNameSpace();
    int pIndex;
    // only return instances when enumerate on our subclass, CIMOM
    // will call us as natural part of recursing through subtree on
    // enumerate - if we return instances on enumerate of our superclass,
    // there would be dups
    if (className.equal (_getClassCimName()) ||
    	className.equal(_getBaseClassCimName()))
    {
        handler.processing();
        _p.initialize();
        for (pIndex = 0; _p.load(pIndex); pIndex++)
        {
        	CIMInstance ci = _constructInstance(_getClassCimName(),
                                           nameSpace,
                                           _p);
        	if (query.evaluate(ci))
	        {
	        	handler.deliver(ci);
	        }
		}
		_p.finalize();
        handler.complete();
    }
    else
    {
        throw CIMNotSupportedException(UNIX_PROVIDER_NAME
                "does not support class " + className.getString());
    }
    return;
}
Ejemplo n.º 28
0
void ParserTestProvider::enumerateInstances(
    const OperationContext & context,
    const CIMObjectPath & classReference,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & propertyList,
    InstanceResponseHandler & handler)
{
    // begin processing the request
    
    CIMName className = classReference.getClassName();
    CIMNamespaceName nameSpace = classReference.getNameSpace();
    //cout "[className: "<<className<<"], [in namespace: " << nameSpace << "]";

    handler.processing();
    Array<CIMKeyBinding> keys;

    keys.append(CIMKeyBinding("CName", 
                              String(CLASS_NAME),
                              CIMKeyBinding::STRING));
    keys.append(CIMKeyBinding("BadStringName",
                              String(BADSTR_1),
                              CIMKeyBinding::STRING));
    CIMInstance instance(CLASS_NAME);

    instance.setPath(CIMObjectPath(String::EMPTY,
                                   nameSpace,
                                   CLASS_NAME,
                                   keys));
    // keys
    instance.addProperty(CIMProperty("CName",
                                      String(CLASS_NAME)));
    instance.addProperty(CIMProperty("BadStringName",
                                      String(BADSTR_1)));

    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
        handler.deliver(_instances[i]);
                        //
    handler.deliver(instance);
    handler.complete();
}
Ejemplo n.º 29
0
/*
================================================================================
NAME              : enumerateInstances
DESCRIPTION       : Enumerates all of the IPProtocolEndpoint instances.
                  : An array of instance references is returned.
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             : LocalOnly, DeepInheritance and propertyList are not
                  : respected by this provider. Localization is not supported
PARAMETERS        :
================================================================================
*/
void BIPTLEpProvider::enumerateInstances(
	const OperationContext & context,
	const CIMObjectPath & classReference,
        const Boolean includeQualifiers,
        const Boolean includeClassOrigin,
	const CIMPropertyList & propertyList,
	InstanceResponseHandler & handler)
{
#ifdef DEBUG
    cout << "BIPTLEpProvider::enumerateInstances()" << endl;
#endif

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

    // Validate the classname
    _checkClass(className);

    // Notify processing is starting
    handler.processing();

    int i;
    InterfaceList _ifList;

    for (i = 0; i < _ifList.size(); i++)
    {
	IPInterface _ipif = _ifList.getInterface(i);

	if (_ipif.bindsToLANInterface())
	{
	    handler.deliver(
		_constructInstance(CLASS_PG_BINDS_IP_TO_LAN_ENDPOINT,
		     nameSpace, _ipif ) );
        }
    }

    // Notify processing is complete
    handler.complete();

    return;
}  // enumerateInstances
Ejemplo n.º 30
0
void
OperatingSystemProvider::enumerateInstances(
      				const OperationContext& context,
			        const CIMObjectPath& ref,
				const Boolean includeQualifiers,
				const Boolean includeClassOrigin,
			        const CIMPropertyList& propertyList,
			        InstanceResponseHandler& handler)
{
    CIMName className;
    CIMInstance instance;
    CIMObjectPath newref;

    className = ref.getClassName();

    // only return instances when enumerate on our subclass, CIMOM
    // will call us as natural part of recursing through subtree on
    // enumerate - if we return instances on enumerate of our superclass,
    // there would be dups
    if (className.equal (EXTENDEDOPERATINGSYSTEMCLASS))
    {
        handler.processing();
        newref = _fill_reference(ref.getNameSpace(), className);
        instance = _build_instance(ref);
        instance.setPath(newref);
        handler.deliver(instance);
        handler.complete();
    }
    else if (className.equal (STANDARDOPERATINGSYSTEMCLASS))
    {
        handler.processing();
        handler.complete();
    }
    else
    {
        throw CIMNotSupportedException("OperatingSystemProvider "
                "does not support class " + className.getString());
    }
    return;
}