Ejemplo n.º 1
0
/////////////////////////////////////////////////////////////////////////////
// WMIBaseProvider::getCIMInstance - retrieves a CIMInstance object
//
// ///////////////////////////////////////////////////////////////////////////
CIMInstance WMIBaseProvider::getCIMInstance(const String& nameSpace,
												const String& userName,
												const String& password,
												const CIMObjectPath &instanceName, 
												const CIMPropertyList &propertyList)
{

	CIMInstance cimInstance;
	CIMStatusCode errorCode = CIM_ERR_SUCCESS;
	String errorDescription;
	WMIInstanceProvider provider;

	PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIBaseProvider::getCIMInstance()");

	try
	{	
        // This fix uses the current boolean value stored in collector
        // to initialize it. 
        provider.initialize(_collector->isLocalConnection()); 

		cimInstance = provider.getInstance(nameSpace, 
										   userName, 
										   password, 
										   instanceName, 
										   false, 
										   false, 
										   false, 
										   propertyList);
		provider.terminate();
	}
	catch(CIMException& exception)
	{
		provider.terminate();
		errorCode = exception.getCode();
		errorDescription = exception.getMessage();
		throw PEGASUS_CIM_EXCEPTION(errorCode, errorDescription);
	}
	catch(Exception& exception)
	{
		provider.terminate();
		errorCode = CIM_ERR_FAILED;
		errorDescription = exception.getMessage();
		throw PEGASUS_CIM_EXCEPTION(errorCode, errorDescription);
	}
	catch(...)
	{
		provider.terminate();
		throw CIMException(CIM_ERR_FAILED);
	}

    PEG_METHOD_EXIT();

	return cimInstance;
}
Ejemplo 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);
}
Ejemplo n.º 3
0
CIMInstance WMIClientRep::getInstance(
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& instanceName,
    Boolean localOnly,
    Boolean includeQualifiers,
    Boolean includeClassOrigin,
    const CIMPropertyList& propertyList)
{
    CIMInstance cimInstance;
	CIMException cimException;

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

		//Performs the WMI call
		cimInstance = provider.getInstance(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			instanceName,
			localOnly,
			includeQualifiers,
			includeClassOrigin,
			propertyList);

		//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, "getInstance() failed!");
		throw cimException;
	}

	return(cimInstance);
}
Ejemplo n.º 4
0
void WMIClientRep::setProperty(
    const CIMNamespaceName& nameSpace,
    const CIMObjectPath& instanceName,
    const CIMName& propertyName,
    const CIMValue& newValue
)
{
    CIMException cimException;

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

		//Performs the WMI call
		provider.setProperty(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			instanceName,
			propertyName.getString(),
			newValue);

		//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, "setProperty() failed!");
		throw cimException;
	}
}
Ejemplo n.º 5
0
void WMIClientRep::modifyInstance(
    const CIMNamespaceName& nameSpace,
    const CIMInstance& modifiedInstance,
    Boolean includeQualifiers,
    const CIMPropertyList& propertyList)
{
    CIMException cimException;

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

		//Performs the WMI call
		provider.modifyInstance(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			modifiedInstance,
			includeQualifiers,
			propertyList);

		//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, "modifyInstance() failed!");
		throw cimException;
	}
}
Ejemplo n.º 6
0
Array<CIMObjectPath> WMIClientRep::enumerateInstanceNames(
    const CIMNamespaceName& nameSpace,
    const CIMName& className)
{
	Array<CIMObjectPath> instanceNames;
	CIMException cimException;
	
	try
	{
		//Initializes the WMI Provider Interface
    	WMIInstanceProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		instanceNames = provider.enumerateInstanceNames(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			className.getString());

		//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, "enumerateInstanceNames() failed!");
		throw cimException;
	}

	return(instanceNames);
}
Ejemplo n.º 7
0
CIMObjectPath WMIClientRep::createInstance(
    const CIMNamespaceName& nameSpace,
    const CIMInstance& newInstance)
{
    CIMObjectPath instanceName;
	CIMException cimException;

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

		//Performs the WMI call
		instanceName = provider.createInstance(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			newInstance);

		//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, "createInstance() failed!");
		throw cimException;
	}

	return (instanceName);
}