Example #1
0
/** testReferences -
 *
 */
int testReferences(const CIMObjectPath& objectName, const CIMName& resultClass,
    const String& role, CIMPropertyList& propertyList, Uint32 expectedCount )
{
    CDEBUG ("testRefrenceNames " << objectName.toString() << " resultClass " << resultClass << " role " << role);
    Array<CIMObject> result = c.references(
        	NAMESPACE,
        	objectName,
        	resultClass,
        	role,
            false,
            false,
            propertyList);

    CDEBUG(" Rtned from c.references ");
    if (verbose)
    {
        for (Uint32 i = 0; i < result.size(); i++)
        {
            cout << "[" << result[i].getPath().toString() << "]" << endl;
        }
    }
    CDEBUG(" Now try the size comparison with input ");

    if (result.size() != expectedCount)
    {
        cout << "ReferenceName Error Object " << objectName.toString() << "Expected count = " << expectedCount << " received " << result.size();
    }

    return 0;

}
Example #2
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();
}
Example #3
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;
}
Example #4
0
void
test04 (CIMClient & client)
{
  CIMObjectPath instanceName;

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  /*     [EmbeddedObject] String returnInstance(); */

  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "returnInstance",
                       inParams,
                       outParams);

  PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_OBJECT);
  PEGASUS_TEST_ASSERT (!retValue.isArray ());
  PEGASUS_TEST_ASSERT (!retValue.isNull ());

  CIMObject result;
  retValue.get (result);

  CIMObjectPath objPath  = result.getPath();
  PEGASUS_TEST_ASSERT (objPath.toString() == "TestCMPI_Instance");

}
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();
}
Example #6
0
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 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;
}
Example #8
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();
}
Example #9
0
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();
}
Example #10
0
/**
 ***************************************************************************
   _filterAssociationInstances is used to filter the set of possible return
   instances against the filters (resultClass and resultRole) provided with
   the associators and associatorNames operations.  It returns the ObjectPaths
   of the set of objects that pass the filter tests.

    @param assocInstance     - The target association class instance
    @param sourceObjectPath  - The source ObjectPath
    @param resultClass       - The result class. If there is no resultClass,
                               this is String::EMPTY.
    @param resultRole        - The result role. If there is no role, this is
                               String::EMPTY

    @return   the ObjectPaths of the set of association instances that pass
              the filter tests.
 ***************************************************************************
*/
Array<CIMObjectPath> ANHProvider::_filterAssociationInstances(
    CIMInstance& assocInstance,
    const CIMObjectPath& sourceObjectPath,
    CIMName resultClass,
    String resultRole)
{
    Array<CIMObjectPath> returnPaths;

    // get all Reference properties
    for (Uint32 i = 0, n = assocInstance.getPropertyCount(); i < n; i++)
    {
        CIMProperty p = assocInstance.getProperty(i);

        if (p.getType() == CIMTYPE_REFERENCE)
        {
            CIMValue v = p.getValue();
            CIMObjectPath path;
            v.get(path);

            if (!sourceObjectPath.identical(path))
            {
                if (resultClass.isNull() || resultClass == path.getClassName())
                {
                    if (resultRole == String::EMPTY ||
                        (p.getName() == CIMName(resultRole)))
                    {
                        returnPaths.append(path);
                    }
                }
            }
        }
    }
    return returnPaths;
}
Example #11
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();
}
Example #12
0
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 );
    }
}
Example #13
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;
            }
        }
    }
}
Example #14
0
void testCreateInstance(CIMClient& client, const char* ns)
{
  CIMObjectPath path;
  Array<CIMInstance> instances;
  CIMName keyName;
  String keyValue;

  instances = client.enumerateInstances(ns, CIM_QUERYCAPCLASS_NAME);

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

  keys[0].setValue("100");

  path = instances[0].getPath();
  path.setKeyBindings(keys);

  try
  {
    path = client.createInstance(ns, instances[0]);
  }
  catch(Exception)
  {
    // Do nothing. This is expected since createInstance is NOT
    // supported.
    return;
  }

  throw Exception("createInstance is supported");
}
Example #15
0
void CIMInstanceNametoXML(CIMObjectPath const& cop, ostream& ostr)
{
	ostr << "<INSTANCENAME CLASSNAME=\"";
	ostr << cop.getClassName() << "\">";
	//
	// If keys > 1 then must use KEYBINDING - we also use it for
	// the key == 1 case - most implementations can't cope with
	// a single KEYVALUE without a KEYBINDING element
	//
	if (cop.isInstancePath())
	{
		size_t numkeys = cop.getKeys().size();
		for (size_t i = 0; i < numkeys; i++)
		{
			CIMProperty cp = cop.getKeys()[i];
			ostr << "<KEYBINDING NAME=\"";
			ostr << cp.getName() << "\">";
			outputKEYVALUE(ostr, cp);
			ostr << "</KEYBINDING>";
		}
	}
	else
	{
		// A singleton, a class without keys
	}
	ostr << "</INSTANCENAME>";
}
Example #16
0
void
test06 (CIMClient & client)
{
  CIMObjectPath instanceName;
  Uint32 exception  =0;
  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  /*     String returnDateTime(); */
  try {
  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "noSuchFunction",
                       inParams,
                       outParams);
  } catch (const CIMException &e)
  {
      exception ++;
    PEGASUS_TEST_ASSERT (e.getCode() == CIM_ERR_NOT_FOUND);
  }
  PEGASUS_TEST_ASSERT (exception == 1);
}
Example #17
0
// This method calls CMPIProviderManager::handleInvokeMethodRequest and
// 'if(rc.rc != CMPI_RC_OK)' condition  in CMPIProviderManager.cpp succeeds.
void _testMethodError(CIMClient & client)
{
    CIMObjectPath instanceName;
    instanceName.setNameSpace (providerNamespace);
    instanceName.setClassName (CMPI_TEST_FAIL);

    Array < CIMParamValue > inParams;
    Array < CIMParamValue > outParams;
    Boolean caughtException;

    caughtException = false;
    try
    {
        CIMValue retValue = client.invokeMethod(
             providerNamespace,
             instanceName,
             "test",
             inParams,
             outParams);
    }
    catch (const CIMException &e)
    {
        if (e.getCode() == CIM_ERR_NOT_SUPPORTED)
        {
            caughtException = true;
        }
    }
    PEGASUS_TEST_ASSERT (caughtException);
}
Example #18
0
IndicationStressTestProvider::IndicationStressTestProvider (void) throw ()
{
  // Set the destination of indications for all threads once

            path.setNameSpace("test/TestProvider");
            path.setClassName("IndicationStressTestClass");
}
Example #19
0
CIMObjectPath CreateFilterInstance (CIMClient& client,
                                    const String query,
                                    const String qlang,
                                    const String name,
                                    const CIMNamespaceName & filterNS)
{
    CIMInstance filterInstance(PEGASUS_CLASSNAME_INDFILTER);
    filterInstance.addProperty(CIMProperty (CIMName ("SystemCreationClassName"),
        System::getSystemCreationClassName()));
    filterInstance.addProperty(CIMProperty(CIMName ("SystemName"),
        System::getFullyQualifiedHostName()));
    filterInstance.addProperty(CIMProperty(CIMName ("CreationClassName"),
        PEGASUS_CLASSNAME_INDFILTER.getString()));
    filterInstance.addProperty(CIMProperty(CIMName ("Name"),
        String(name)));
    filterInstance.addProperty (CIMProperty(CIMName ("Query"),
        String(query)));
    filterInstance.addProperty (CIMProperty(CIMName ("QueryLanguage"),
        String(qlang)));
    filterInstance.addProperty (CIMProperty(CIMName ("SourceNamespace"),
        String("test/TestProvider")));

    CIMObjectPath Ref = client.createInstance(filterNS, filterInstance);
    Ref.setNameSpace (filterNS);
    return (Ref);
}
/**
    Returns the instance names of the errorInstance or indicationInstance
    stored in this class.
*/
void EmbeddedInstanceProvider::enumerateInstanceNames(
    const OperationContext& context,
    const CIMObjectPath& ref,
    ObjectPathResponseHandler& handler)
{
    handler.processing();
    if (ref.getClassName().equal(CIMName("PG_EmbeddedError")))
    {
        CIMObjectPath errorInstancePath = errorInstance->getPath();
        handler.deliver(errorInstancePath);
        handler.deliver(errorInstancePath);
        handler.deliver(errorInstancePath);
        handler.deliver(errorInstancePath);
        handler.deliver(errorInstancePath);
    }
    else if (ref.getClassName().equal(CIMName("PG_InstMethodIndication")))
    {
        CIMObjectPath indicationInstancePath = indicationInstance->getPath();
        handler.deliver(indicationInstancePath);
        handler.deliver(indicationInstancePath);
        handler.deliver(indicationInstancePath);
        handler.deliver(indicationInstancePath);
        handler.deliver(indicationInstancePath);
    }
    handler.complete();
}
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;
}
Example #22
0
void _testHostedIndicationServiceInstance(CIMClient &client)
{
    cout << "Testing Association Class "
        << (const char *)PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE.
             getString().getCString()
        << "...";
    // Get PG_HostedIndicationService Instances
    Array<CIMInstance> hostedInstances = client.enumerateInstances(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(hostedInstances.size() == 1);

    // Get PG_HostedIndicationService Instance names
    Array<CIMObjectPath> hostedPaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(hostedPaths.size() == 1);

    // Get CIM_IndicationService instance names
    Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
    PEGASUS_TEST_ASSERT(servicePaths.size() == 1);

    // Test the CIM_IndicationService value.
    CIMValue capValue = hostedInstances[0].getProperty(
        hostedInstances[0].findProperty("Dependent")).getValue();
    CIMObjectPath testPath;
    capValue.get(testPath);
    testPath.setNameSpace(CIMNamespaceName());
    PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0]));

    cout << "Test Complete" << endl;
}
void TestGroupingProvider2::invokeMethod(
    const OperationContext& context,
    const CIMObjectPath& objectReference,
    const CIMName& methodName,
    const Array<CIMParamValue>& inParameters,
    MethodResultResponseHandler& handler)
{
    if (!objectReference.getClassName().equal("Test_GroupingClass2"))
    {
        throw CIMNotSupportedException(
            objectReference.getClassName().getString());
    }

    handler.processing();
    if (methodName.equal("getNextIdentifier"))
    {
        handler.deliver(CIMValue(Uint32(getNextIdentifier())));
    }
    else if (methodName.equal("getSubscriptionCount"))
    {
         handler.deliver(CIMValue(_subscriptionCount));
    }

    handler.complete();
}
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();
}
Example #25
0
int _getInstance(const int argc, const char **argv)
{
  if (argv[0] == 0)
  {
    _giUsage();
    return 1;
  }
  
  // need to get class definition to find keys
  // first arg is name of class
  CIMClass cldef;
  try
  {
    cldef = _c.getClass( _nameSpace, argv[0] );
  }
  catch(Exception& e)
  {
    cerr << /* "getInstance: " << */ e.getMessage() << endl;
    return 1;
  }

  CIMObjectPath ref;
  CIMInstance inst;

  // If there are no more args, prompt user for keys
  if (argv[1] == 0) ref = CIMObjectPath(String::EMPTY, // hostname left blank
                                       _nameSpace,
                                       argv[0],
                                       _inputInstanceKeys(cldef));
  
  // else if there's another arg and it's "list", enumInstNames and print
  // a list from which user will select (return if none)
  else if (String::equalNoCase("list",argv[1]))
  {
    ref = _selectInstance(argv[0]);
    // An empty ObjectPath means nothing was selected
    if (ref.identical(CIMObjectPath())) return 0;
  }
    
  // else there's another arg but it's invalid
  else
  {
    _giUsage();
    return 1;
  }

  // get the specified instance
  try
  {
    inst = _c.getInstance(_nameSpace,ref);
  }
  catch(Exception& e)
  {
    cerr << /* "getInstance: " << */ e.getMessage() << endl;
    return 1;
  }
  _displayInstance(inst);
  return 0;
}
Example #26
0
CIMObjectPath::CIMObjectPath(const String& objectName)
{
    // Test the objectName out to see if we get an exception
    CIMObjectPath tmpRef;
    tmpRef.set(objectName);

    _rep = new CIMObjectPathRep(*tmpRef._rep);
}
Example #27
0
int testReferenceNames(const CIMObjectPath& objectName, const CIMName& resultClass,
    const String& role, Uint32 expectedCount )
{

    //CIMObjectPath instanceName = CIMObjectPath ("Person.name=\"Mike\"");
    CDEBUG ("testReferenceNames " << objectName.toString() << " resultClass "
        << resultClass << " role " << role);

    Array<CIMObjectPath> result = c.referenceNames(
        	NAMESPACE,
        	objectName,
        	resultClass,
        	role);
    CDEBUG("Return from Instance Names");
    Array<CIMObject> resultObjects = c.references(
        	NAMESPACE,
        	objectName,
        	resultClass,
        	role);

    CDEBUG("Return from calls. compare sizes");
    if (result.size() != resultObjects.size())
    {
        cout << "ERROR, Reference and reference Name size difference" << endl;
    }
    CDEBUG("Size tests finished, now compare the returns");
    for (Uint32 i = 0; i < result.size(); i++)
    {
        if (resultObjects[i].getPath().toString() != result[i].toString())
        {
            cout << "Name response Error: "
                 << resultObjects[i].getPath().toString()
                 << " != "
                 << result[i].toString()
                 << endl;
        }
    }
    CDEBUG("Returns Compared. Now to the display");
    if (verbose)
    {
        cout << "REQUEST: References, Object: " << objectName << " Filter: "
                << resultClass << " role: " << role << endl
                << "RESPONSE:";
        for (Uint32 i = 0; i < result.size(); i++)
            cout << " " << result[i].getClassName().getString() << "";
        cout << endl;
    }

    if (result.size() != expectedCount)
    {
        cout << "ReferenceName Error Object " << objectName.toString()
        << "Expected count: " << expectedCount << " Received: " << result.size()
        <<endl;

        return 0;
    }
    return 0;
}
Example #28
0
int testAssocNames(const CIMObjectPath& objectName,
                   const CIMName& assocClass,
                   const CIMName& resultClass,
                   const String& role,
                   const String& resultRole,
                   Uint32 expectedCount )
{
    //CIMObjectPath instanceName = CIMObjectPath ("Person.name=\"Mike\"");
    CDEBUG ("testReferenceNames " << objectName.toString() << " resultClass " << resultClass << " role " << role);

    Array<CIMObjectPath> result = c.associatorNames(
        	NAMESPACE,
        	objectName,
            assocClass,
        	resultClass,
        	role,
            resultRole);
    Array<CIMObject> resultObjects = c.associators(
        	NAMESPACE,
        	objectName,
            assocClass,
        	resultClass,
        	role,
            resultClass);

    if (result.size() != resultObjects.size())
    {
        cout << "ERROR, Associator and AssociatorName count returned difference" << endl;
    }
    for (Uint32 i = 0; i < result.size(); i++)
    {
        if (resultObjects[i].getPath().toString() != result[i].toString())
        {
            cout << "Name response Error" << endl;
        }
    }
    if (verbose)
    {
        cout << "REQUEST: Associators, Object: " << objectName
                << " assocClass " << assocClass
                << " resultClass " << resultClass
                << " role " << role
                << " resultClass " << resultClass
                << endl
                << "RESPONSE: ";
        for (Uint32 i = 0; i < result.size(); i++)
            cout << " " << result[i].toString() << " ";
        cout << endl;
    }

    if (result.size() != expectedCount)
    {
        cout << "AssociatorName Error Object " << objectName.toString() << "Expected count = " << expectedCount << " received " << result.size();
        return 1;
    }
    return 0;

}
Example #29
0
/*
================================================================================
NAME              : _constructKeyBindings
DESCRIPTION       : Constructs an array of keybindings for an IP Interface
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             :
PARAMETERS        : className, Process
================================================================================
*/
Array<CIMKeyBinding> BIPTLEpProvider::_constructKeyBindings(
					const CIMNamespaceName &nameSpace,
					const IPInterface &_ipif)
{
#ifdef DEBUG
  cout << "BIPTLEpProvider::_constructKeyBindings()" << endl;
#endif

  Array<CIMKeyBinding> keyBindings;
  String s, sn;
  CIMObjectPath op;

  if (_ipif.getSystemName(sn) == false)
  {
	throw CIMNotSupportedException(
		String("Host-specific module doesn't support Key `") +
		PROPERTY_SYSTEM_NAME.getString() + String("'"));
  }

  // Construct the key bindings
  op = CIMObjectPath(sn, //hostname
		       nameSpace,
		       CLASS_CIM_LAN_ENDPOINT,
                       _constructReference(
		                   CLASS_CIM_LAN_ENDPOINT,
				   sn,_ipif.get_LANInterfaceName()) );

  keyBindings.append(CIMKeyBinding(PROPERTY_ANTECEDENT,
                                   op.toString(),
                                   CIMKeyBinding::REFERENCE));

  if (_ipif.getName(s))
  {
	  op = CIMObjectPath(sn, //hostname
			       nameSpace,
			       CLASS_CIM_IP_PROTOCOL_ENDPOINT,
                               _constructReference(
			                   CLASS_CIM_IP_PROTOCOL_ENDPOINT,
					   sn,s) );

	  keyBindings.append(CIMKeyBinding(PROPERTY_DEPENDENT,
			     op.toString(),
                             CIMKeyBinding::REFERENCE));
  }
  else
  {
	throw CIMNotSupportedException(
		String("Host-specific module doesn't support Key `") +
		PROPERTY_NAME.getString() + String("'"));
  }

#ifdef DEBUG
  cout << "BIPTLEpProvider::_constructKeyBindings() -- done" << endl;
#endif

  return keyBindings;
}
Example #30
0
CIMObjectPath ObjectNormalizer::processClassObjectPath(
    const CIMObjectPath& cimObjectPath) const
{
    // pre-check
    if (!_enableNormalization || _cimClass.isUninitialized())
    {
        // do nothing
        return cimObjectPath;
    }

    /*
    // ATTN: moving similar logic to the response handlers because this
    // type of error should be checked regardless with or without
    // normalization enabled.
    if (cimObjectPath.getClassName().isNull())
    {
        throw CIMException(CIM_ERR_FAILED, "uninitialized object path");
    }
    */

    /*
    // ATTN: The following code is currently redundant because the CIMName
    // object validates legal names when it is constructed. It is included
    // here for completeness.
    // check class name
    if (!CIMName(cimObjectPath.getClassName()).legal())
    {
        MessageLoaderParms message(
            "Common.ObjectNormalizer.INVALID_CLASS_NAME",
            "Invalid class name: $0",
            cimObjectPath.getClassName().getString());

        throw CIMException(CIM_ERR_FAILED, message);
    }
    */

    // check class type
    if (!_cimClass.getClassName().equal(cimObjectPath.getClassName()))
    {
        MessageLoaderParms message(
            "Common.ObjectNormalizer.INVALID_CLASS_TYPE",
            "Invalid class type: $0",
            cimObjectPath.getClassName().getString());

        throw CIMException(CIM_ERR_FAILED, message);
    }

    CIMObjectPath normalizedObjectPath(
        _cimClass.getPath().getHost(),
        _cimClass.getPath().getNameSpace(),
        _cimClass.getClassName());

    // ignore any keys, they are not part of a class object path

    return normalizedObjectPath;
}