Exemplo n.º 1
0
Array<CIMObject> WMIClientRep::associators(
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& objectName,
    const CIMName& assocClass,
    const CIMName& resultClass,
    const String& role,
    const String& resultRole,
    Boolean includeQualifiers,
    Boolean includeClassOrigin,
    const CIMPropertyList& propertyList)
{
	Array<CIMObject> cimObjects;
	CIMPropertyList myPropertyList(propertyList);
	CIMException cimException;
	
	try
	{
		//Initializes the WMI Provider Interface
    	WMIAssociatorProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		cimObjects = provider.associators(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			objectName,
			assocClass.getString(),
			resultClass.getString(),
			role,
			resultRole,
			includeQualifiers,
			includeClassOrigin,
			myPropertyList);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "associators() failed!");
		throw cimException;
	}

	return(cimObjects);
}
Exemplo n.º 2
0
Array<CIMInstance> WMIClientRep::enumerateInstances(
    const CIMNamespaceName& nameSpace,
    const CIMName& className,
    Boolean deepInheritance,
    Boolean localOnly,
    Boolean includeQualifiers,
    Boolean includeClassOrigin,
    const CIMPropertyList& propertyList)
{
    Array<CIMInstance> cimInstances;
	CIMPropertyList myPropertyList(propertyList);
	CIMException cimException;

	try
	{
		//Initializes the WMI Provider Interface
    	WMIInstanceProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		cimInstances = provider.enumerateInstances(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			className.getString(),
			deepInheritance,
			localOnly,
			includeQualifiers,
			includeClassOrigin,
			myPropertyList);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "enumerateInstances() failed!");
		throw cimException;
	}

	return(cimInstances);
}
static void
_test2 (CIMClient & client)
{
  Uint32 exceptions = 0;
  CIMObjectPath instanceName;
  Array < CIMKeyBinding > keyBindings;

  keyBindings.append (CIMKeyBinding ("ElementNameName",
                                     "TestCMPI_ExecQuery",
                                     CIMKeyBinding::STRING));

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName ("TestCMPI_ExecQuery");
  instanceName.setKeyBindings (keyBindings);

  /* Call the unsupported functions of the provider. */
  try
  {
    CIMInstance instance (client.getInstance (providerNamespace,
                                              instanceName));
  } catch (const CIMException &)
  {
     exceptions ++;
  }


  try
  {
    client.deleteInstance (providerNamespace, instanceName);

  } catch (const CIMException & )
  {
     exceptions ++;
  }
  CIMClass thisClass = client.getClass(
                           providerNamespace,
                           "TestCMPI_ExecQuery",
                           false,
                           true,
                           true,
                           CIMPropertyList());
  Array<CIMName> propertyNameList;
  propertyNameList.append(CIMName("ElementName"));
  CIMPropertyList myPropertyList(propertyNameList);
  // create the instance with the defined properties
  CIMInstance newInstance = thisClass.buildInstance(true, true, myPropertyList);
  newInstance.getProperty(0).setValue(CIMValue(String("TestCMPI_execQuery") ));
  try
  {

    CIMObjectPath objectPath (client.createInstance (providerNamespace,
                                                     newInstance));


  } catch (const CIMException &)
  {
     exceptions ++;
  }

  try
  {
    client.modifyInstance (providerNamespace, newInstance);

  } catch (const CIMException &)
  {
     exceptions ++;
  }
  try
  {

    Array < CIMInstance > instances =
      client.enumerateInstances (providerNamespace,
                                 CIMName ("TestCMPI_ExecQuery"));
  } catch (const CIMException &)
  {
     exceptions ++;
  }

  try
  {
    Array < CIMObjectPath > objectPaths =
      client.enumerateInstanceNames (providerNamespace,
                                     CIMName ("TestCMPI_ExecQuery"));
  } catch (const CIMException &)
  {
     exceptions ++;
  }

  PEGASUS_TEST_ASSERT(exceptions ==  6);

}