Client/Provider Tutorial Code for Beginners
1. Introduction
The purpose of this package is to provide a code guideline for OpenDRIM developers which begin to study CIM and WBEM. This package uses the OpenDRIM Provider Code Generator, also contains client and provider files which refer to OpenPegasus Technical Workshop.
2. Requirements
- You must install open-pegasus-2.5.3 or higher and basic providers are running on your system
- You must install OpenDRIM Provider Common Library : Download Library?
- If you want to develope OpenDRIM provider, please read this document : OpenDRIM Provider Developement Guidelines
- If you don't install OpenPegasus, please read this document : CIM Server Installation guidelines
- Basic provider is that OpenPegasus provide us to understand CIM and WBEM, so you may certain the following commands.
$ cimprovider -l -s MODULE STATUS ComputerSystemModule OK OperatingSystemModule OK ProcessModule OK $ cimprovider -l -m OperatingSystemModule PG_OperatingSystemProvider $ cimprovider -l -m ProcessModule ProcessProvider ProcessStatProvider
- If you want to more understanding this sample code, visit to following sites.
- WBEM Client API : http://www.openpegasus.org/doc.tpl?CALLER=documents.tpl&dcat=&gdid=3450
- WBEM Provider API : http://www.openpegasus.org/doc.tpl?CALLER=documents.tpl&dcat=&gdid=3451
- WBEM CMPI-Provider : http://www.openpegasus.org/doc.tpl?CALLER=documents.tpl&dcat=&gdid=3390
3. Directory
| client | Sample code for wbem client code (dependent on OpenPegasus) |
| pegasus-provider | Provider code based on OpenPegasus |
| cmpi-provider | Provider code based on CMPI |
| PG_OperatingSystem | Provider code based on OpenDRIM using the Code Generator. |
| PG_UnixProcess | Provider code based on OpenDRIM using the Code Generator. |
| mof | CIM Schema files(s) |
| registration | Register provider |
4. Configuration
- Only OpenDRIM provider using Code Generator (default)
$ ./configure CIMSERVER=<YOUR_CIMSERVER_NAME>
- You can add to sample client
$ ./configure CIMSERVER=<pegasus|tog-pegasus|tog-pegasus64> --with-client
- You can add to provider based on CMPI (DONOT use Code Generator)
$ ./configure CIMSERVER=<YOUR_CIMSERVER_NAME> --with-cmpi-provider
- You can add to provider based on OpenPegasus (DONOT use Code Generator)
$ ./configure CIMSERVER=<pegasus|tog-pegasus|tog-pegasus64> --with-pegasus-provider
5. Sample Client
The client directory contains six examples. In this section, we execute those client with basic provider. You will probably modify Makefile that depend on your system and position of pegasus library. Each example shows us to real value on system.
- ConnectExample
$ ./ConnectExample Total Number of OS Instances: 1
- EnumInstancesOS
$ ./EnumInstancesOS Total Number of OS Instances: 1 Total Number of Processes: 104
- EnumInstanceNamesProcess
$ ./EnumInstanceNamesProcess Total Number of Processes: 103 PG_UnixProcess.CreationClassName="PG_UnixProcess",CSCreationClassName="CIM_UnitaryComputerSystem", CSName="localhost.localdomain",Handle="1",OSCreationClassName="CIM_OperatingSystem",OSName="" PG_UnixProcess.CreationClassName="PG_UnixProcess",CSCreationClassName="CIM_UnitaryComputerSystem", CSName="localhost.localdomain",Handle="2",OSCreationClassName="CIM_OperatingSystem",OSName="" ... ...
- EnumInstancesProcess
$ ./EnumInstancesProcess The process name for PID 1 is init The process name for PID 2 is migration/0 The process name for PID 3 is ksoftirqd/0 The process name for PID 4 is watchdog/0 ... ...
- GetProcessInstanceExample
$ ./GetProcessInstanceExample Process Information for PID 1 : The computer system name is localhost.localdomain Process name is init Process priority is 16
- InvokeMethodExample
$ ./InvokeMethodExample Error: CIM_ERR_METHOD_NOT_AVAILABLE: The extrinsic method could not be executed: "kill"
6. OpenDRIM Provider
In this section, we replace pegasus's basic providers with our providers which use to OpenDRIM Code Generator. Two provider is fake your system, it is not reflect real world. You can more easy implement various providers as using of OpenDRIM Code Generator and OpenDRIM Common Library.
$ ./configure CIMSERVER=tog-pegasus --with-client $ make $ make install $ make postinstall registration/Tutorial.sh root/cimv2 OpenDRIM tog-pegasus Pegasus's OperatingSystemModule is down Deleting provider module... Provider module deleted successfully. Pegasus's ProcessModule is down Deleting provider module... Provider module deleted successfully. $ client/EnumInstancesOS Total Number of OS Instances: 1 Total Number of Processes: 12345 $ client/GetProcessInstanceExample Process Information for PID 1 : The computer system name is OpenDRIM_Host Process name is OpenDRIM Process 1 Process priority is 2 $ client/InvokeMethodExample retCode = 0 ProcessName = Process 1 be killed, signal 5 $ make postuninstall registration/Tutorial-remove.sh root/cimv2 tog-pegasus Disabling provider module... Provider module disabled successfully. Deleting provider module... Provider module deleted successfully. <?xml version="1.0" encoding="utf-8"?> <CIM CIMVERSION="2.0" DTDVERSION="2.0"> <MESSAGE ID="1" PROTOCOLVERSION="1.0"> <SIMPLERSP> <IMETHODRESPONSE NAME="DeleteClass"> </IMETHODRESPONSE> </SIMPLERSP> </MESSAGE> </CIM> Disabling provider module... Provider module disabled successfully. Deleting provider module... Provider module deleted successfully. <?xml version="1.0" encoding="utf-8"?> <CIM CIMVERSION="2.0" DTDVERSION="2.0"> <MESSAGE ID="1" PROTOCOLVERSION="1.0"> <SIMPLERSP> <IMETHODRESPONSE NAME="DeleteClass"> </IMETHODRESPONSE> </SIMPLERSP> </MESSAGE> </CIM> Specified provider was not registered. Pegasus's OperatingSystemModule is up Specified provider was not registered. Pegasus's ProcessModule is up
7. Independent Provider
The cmpi_provider and pegasus_provider directory contains four examples. In this section, we replace pegasus's basic providers with our independent providers. Each provider is fake your system, it is not reflect real world. You can implement various providers and test functionality of provider through this examples.
$ ./configure CIMSEVER=tog-pegasus --with-client --with-pegasus-provider (or --with-cmpi-provider) $ make $ make install
- OperatingSystemException
$ make postinstall_except registration/Tutorial-provider.sh except tog-pegasus pegasus Pegasus's OperatingSystemModule is down Deleting provider module... Provider module deleted successfully. $ client/EnumInstancesOS Error: CIM_ERR_NOT_SUPPORTED: The requested operation is not supported: "PG_OperatingSystemProvider does not support enumerateInstances"
- OperatingSystemEnum
$ make postinstall_enum registration/Tutorial-provider.sh enum tog-pegasus pegasus Pegasus's OperatingSystemModule is down Deleting provider module... Provider module deleted successfully. $ client/EnumInstancesOS Total Number of OS Instances: 1 Total Number of Processes: 12345
- UnixProcessInstance
$ make postinstall_inst registration/Tutorial-provider.sh inst tog-pegasus pegasus Pegasus's ProcessModule is down Deleting provider module... Provider module deleted successfully. $ client/EnumInstanceNamesProcess Total Number of Processes: 9 PG_UnixProcess.CreationClassName="PG_UnixProcess",CSCreationClassName="PG_UnitaryComputerSystem", CSName="OpenDRIM_Host",Handle="1",OSCreationClassName="PG_OperatingSystem",OSName="OpenDRIM_OS" PG_UnixProcess.CreationClassName="PG_UnixProcess",CSCreationClassName="PG_UnitaryComputerSystem", CSName="OpenDRIM_Host",Handle="2",OSCreationClassName="PG_OperatingSystem",OSName="OpenDRIM_OS" ... $ client/EnumInstancesProcess The process name for PID 1 is OpenDRIM Process 1 The process name for PID 2 is OpenDRIM Process 2 The process name for PID 3 is OpenDRIM Process 3 The process name for PID 4 is OpenDRIM Process 4 The process name for PID 5 is OpenDRIM Process 5 The process name for PID 6 is OpenDRIM Process 6 The process name for PID 7 is OpenDRIM Process 7 The process name for PID 8 is OpenDRIM Process 8 The process name for PID 9 is OpenDRIM Process 9 $ client/GetProcessInstanceExample Process Information for PID 1 : The computer system name is OpenDRIM_Host Process name is OpenDRIM Process 1 Process priority is 2
- UnixProcessInvoke
$ make postinstall_invoke registration/Tutorial-provider.sh invoke tog-pegasus pegasus Pegasus's ProcessModule is down Deleting provider module... Provider module deleted successfully. $ client/InvokeMethodExample retCode = 0 ProcessName = Process 1 be killed, signal 5
- Deregister our providers
$ make postuninstall registration/Tutorial-provider-remove.sh tog-pegasus pegasus Pegasus's original OperatingSystemModule is up Deleting provider module... Provider module deleted successfully. Pegasus's original ProcessModule is up Deleting provider module... Provider module deleted successfully.
Tue Jan 6 20:23:42 2009
Hong, Sang-Hyun
shhong@lgnsys.com
Attachments
- OpenDRIM_Tutorial-070426.tar.gz (0.7 MB) - added by shhong on 04/26/07 11:33:31.
