Using WS-Eventing

Introduction

This HOWTO was to create a demo for MDC, see the slides for more information.

Configure indication provider setting in CIMOM

First, download the latest sfcbd source code from SBLIM project repository. The latest sfcbd has some bugs fixed which enables WS-Eventing features in OpenWSMAN to run smoothly. Compile it with indication enabled and install it in your system. It is assumed that you have an indication provider – 'libprocessIndication.so', a corresponding registry file – "processIndication.reg", and a MOF file (if it is necessary). The content of registry file is like the following:

  1. [CIM_ProcessIndication]
  2. provider: CPUUsage
  3. location: processIndication
  4. type: indication
  5. namespace: root/cimv2

Steps to register a new indication provider in sfcbd are:

 

  • Copy provider image to one of provider directories. For example, /usr/local/lib/cmpi.
  • Register provider to sfcbd
    • Run “sfcbstage -n root/cimv2 -r processIndication.reg”. There is no MOF file here for CIM_ProcessIndication is a standard class included in CIM MOFs.
    • Run “sfcbreps -f”. This command rebuilds class repository
    • Run sfcbd

Configure indication source namespace setting in OpenWSMAN

If the indication namespace is different from CIM namespace defined in openwsman.conf or what you specify in wsmancli through the option “--namespace”, add indication source namespace configuration in OpenWSMAN configuration file. For example, if default_cim_namespace = root/interop, then we should add another option “indication_source_namespace = root/cimv2” in cim section of openwsman.conf in this case.

Run wseventsink utility as an event sink

Run wseventsink as an event sink. Utility wseventsink accepts incoming events and prints them to stdout. Default service path is /eventsink and port is 80.

Run wsmancli to subscribe

Push delivery mode, 2 seconds heartbeat and 3600 seconds expiration

Run command:

wsman subscribe http://schemas.dmtf.org/wbem/wscim/1/* -x "SELECT * FROM CIM_ProcessIndication" -D "http://schemas.microsoft.com/wbem/wsman/1/WQL" -Z http://127.0.0.1:80/eventsink  --namespace=root/interop -r 600 -H 2 -u wsmantest -p wsmantest -h localhost -G push –R

We will see incoming events from wseventsink. If there is no real event from indication provider, heartbeat events will be sent every 2 seconds.

PushWithAck delivery mode

Run command:

wsman subscribe http://schemas.dmtf.org/wbem/wscim/1/* -x "SELECT * FROM CIM_ProcessIndication" -D "http://schemas.microsoft.com/wbem/wsman/1/WQL"; -Z http://127.0.0.1:80/eventsink  --namespace=root/interop -r 600 -H 2 -u wsmantest -p wsmantest -h localhost -G pushwithack –R

We will see incoming real events and heartbeats from wseventsink. This delivery mode demands acknowledgement from event sink. If wseventsink is closed, this subscription will be terminated by openwsman when it cannot receive acknowledgment.

Batched delivery mode

Run command:

wsman subscribe http://schemas.dmtf.org/wbem/wscim/1/* -x "SELECT * FROM CIM_ProcessIndication" -D "http://schemas.microsoft.com/wbem/wsman/1/WQL" –Z http://127.0.0.1:80/eventsink  --namespace=root/interop -r 600 -H 2 -u wsmantest -p wsmantest -h localhost -G events –R

This delivery mode provides a way to deliver multiple events in a single SOAP event message. It also needs acknowledgement from event sink. The subscription will be terminated if Openwsman cannot receive acknowledgment of an event.

Pull delivery mode

wsman subscribe http://schemas.dmtf.org/wbem/wscim/1/* -x "SELECT * FROM CIM_ProcessIndication" -D "http://schemas.microsoft.com/wbem/wsman/1/WQL" -Z http://127.0.0.1:80/eventsink  --namespace=root/interop -r 600 -u wsmantest -p wsmantest -h localhost -G pull –R

This delivery mode borrows the wsen:Pull message to retrieve events from the logical queue. If the returned subscription response is like the following:

  1. <s:envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration">
  2. <s:header>
  3. <wsa:to>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:to>
  4. <wsa:action>http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscribeResponse</wsa:action>
  5. <wsa:relatesto>uuid:1f557836-3ec7-1ec7-8002-6ae2ccb7d000</wsa:relatesto>
  6. <wsa:messageid>uuid:1f756cda-3ec7-1ec7-955e-6ae2ccb7d000</wsa:messageid>
  7. </s:header>
  8. <s:body>
  9. <wse:subscriberesponse>
  10. <wse:subscriptionmanager>
  11. <wsa:address>http://localhost:8889/wsman</wsa:address>
  12. <wsa:referenceparameters>
  13. <wse:identifier>uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000</wse:identifier>
  14. </wsa:referenceparameters>
  15. </wse:subscriptionmanager>
  16. <wse:expires>PT600.000000S</wse:expires>
  17. <wsen:enumerationcontext>uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000</wsen:enumerationcontext>
  18. </wse:subscriberesponse>
  19. </s:body>
  20. </s:envelope>

Then, corresponding command to pull events is shown below:

  1. wsman pull <a href="http://schemas.dmtf.org/wbem/wscim/1/*" title="http://schemas.dmtf.org/wbem/wscim/1/*">http://schemas.dmtf.org/wbem/wscim/1/*</a> -U uuid:26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000 -u wsmantest -p wsmantest -h localhost

If there is an event in the queue, the response will be like the following:

  1. <s:envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:n1="http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/CIM_ProcessIndication">
  2. <s:header>
  3. <wsa:action>http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/CIM_ProcessIndication</wsa:action>
  4. <wsa:messageid>uuid:2782e580-3ec7-1ec7-8004-6ae2ccb7d000</wsa:messageid>
  5. <wsa:relatesto>uuid:2782ce67-3ec7-1ec7-8002-6ae2ccb7d000</wsa:relatesto>
  6. </s:header>
  7. <s:body>
  8. <wsen:pullresponse>
  9. <wsen:enumerationcontext>uuid:26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000</wsen:enumerationcontext>
  10. <n1:cim_processindication>
  11. <n1:indicationidentifier>
  12. ChangeOfUsers
  13. </n1:indicationidentifier>
  14. <n1:indicationtime>
  15. </n1:indicationtime>
  16. <n1:classname>
  17. </n1:classname>
  18. </n1:cim_processindication>
  19. </wsen:pullresponse>
  20. </s:body>
  21. </s:envelope>

If there is no event in the queue, the response will be like:

  1. <s:envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">
  2. <s:header>
  3. <wsa:to>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:to>
  4. <wsa:action>http://schemas.dmtf.org/wbem/wsman/1/wsman/fault</wsa:action>
  5. <wsa:relatesto>uuid:3002e928-3ec7-1ec7-8002-6ae2ccb7d000</wsa:relatesto>
  6. <wsa:messageid>uuid:3002ffb9-3ec7-1ec7-8005-6ae2ccb7d000</wsa:messageid>
  7. </s:header>
  8. <s:body>
  9. <s:fault>
  10. <s:code>
  11. <s:value>s:Receiver</s:value>
  12. <s:subcode>
  13. <s:value>wsman:TimedOut</s:value>
  14. </s:subcode>
  15. </s:code>
  16. <s:reason>
  17. <s:text xml:lang="en">The operation has timed out.</s:text>
  18. </s:reason>
  19. </s:fault>
  20. </s:body>
  21. </s:envelope>

Renew a Subscription

If the returned subscription Identifier is uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000, renew this subscription to 200 seconds.

  1. wsman renew -i uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000 -r 200 -u wsmantest -p wsmantest -h localhost

Unsubscribe a subscription

If the returned subscription Identifier is uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000, renew this subscription to 200 seconds.

  1. wsman unsubscribe -i uuid:569f6af6-3ec7-1ec7-8002-6ae2ccb7d000 --namespace=root/interop -u wsmantest -p wsmantest -h localhost

Demonstrate that a subscription is terminated if there is no acknowledgment from event sink.

If the delivery mode of a subscription is “pushwithack” or “events”, no acknowledgement from event sink will cause it to be terminated

  • Terminate wseventsink
  • Subscribe a subscription with “events” delivery mode and 2 seconds heartbeat
  • In 2 seconds, if we try to renew it or unsubscribe it, we will get failure response.

Subscribe to an existing filter

From 2.0.0Beta1 openwsman supports subscriptions to an existing filter. Suppose there is a CIM_IndicationFilter instance with Name "OperatingSystemFilter0" and query string "Select * from CIM_AlertIndication", we can subscribe to it by using the following wsman command line usage.
  1. wsman subscribe "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/CIM_IndicationFilter?Name=OperatingSystemFilter0&CreationClassName=CIM_IndicationFilter&SystemName=localhost.localdomain&SystemCreationClassName=CIM_ComputerSystem" -D "http://schemas.microsoft.com/wbem/wsman/1/WQL" -r 600 -Z "http://127.0.0.1:80/eventsink" -u wsmantest -p wsmantest -h localhost --namespace=root/interop -R