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

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)
registrationRegister provider

4. Configuration

  1. Only OpenDRIM provider using Code Generator (default)
    $ ./configure CIMSERVER=<YOUR_CIMSERVER_NAME>
    
  2. You can add to sample client
    $ ./configure CIMSERVER=<pegasus|tog-pegasus|tog-pegasus64> --with-client
    
  3. You can add to provider based on CMPI (DONOT use Code Generator)
    $ ./configure CIMSERVER=<YOUR_CIMSERVER_NAME> --with-cmpi-provider
    
  4. 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.

  1. ConnectExample
    $ ./ConnectExample
    Total Number of OS Instances: 1
    
  2. EnumInstancesOS
    $ ./EnumInstancesOS
    Total Number of OS Instances: 1
    Total Number of Processes: 104
    
  3. 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=""
    ...
    ...
    
  4. 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
    ...
    ...
    
  5. GetProcessInstanceExample
    $ ./GetProcessInstanceExample
    Process Information for PID 1 :
    The computer system name is localhost.localdomain
    Process name is init
    Process priority is 16
    
  6. 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
  1. 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"
    
  2. 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
    
  3. 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
    
  4. 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
    
  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