Using WS Eventing - Openwsman/openwsman GitHub Wiki
This HOWTO was to create a demo for MDC, see these slides for more information.
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:
[CIM_ProcessIndication]
provider: CPUUsage
location: processIndication
type: indication
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
-
- Run
sfcbreps -f
. This command rebuilds class repository
- Run
-
- Run
sfcbd
- Run
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
as an event sink. Utility wseventsink accepts incoming
events and prints them to stdout. Default service path is /eventsink
and port is 80.
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/cimv2 \
-r 600 \
-H 2 \
-h localhost -u wsman -p secret \
-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.
If this command fails for any reason, please see Debugging WS-Eventing for help.
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/cimv2 \
-r 600 \
-H 2 \
-h localhost -u wsman -p secret \
-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.
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/cimv2 \
-r 600 \
-H 2 \
-h localhost -u wsman -p secret \
-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.
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/cimv2 \
-r 600 \
-h localhost -u wsman -p secret \
-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:
<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">
<s:header>
<wsa:to>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:to>
<wsa:action>http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscribeResponse</wsa:action>
<wsa:relatesto>uuid:1f557836-3ec7-1ec7-8002-6ae2ccb7d000</wsa:relatesto>
<wsa:messageid>uuid:1f756cda-3ec7-1ec7-955e-6ae2ccb7d000</wsa:messageid>
</s:header>
<s:body>
<wse:subscriberesponse>
<wse:subscriptionmanager>
<wsa:address>http://localhost:8889/wsman</wsa:address>
<wsa:referenceparameters>
<wse:identifier>uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000</wse:identifier>
</wsa:referenceparameters>
</wse:subscriptionmanager>
<wse:expires>PT600.000000S</wse:expires>
<wsen:enumerationcontext>uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000</wsen:enumerationcontext>
</wse:subscriberesponse>
</s:body>
</s:envelope>
Then, corresponding command to pull events is shown below:
wsman pull "http://schemas.dmtf.org/wbem/wscim/1/*" \
-U uuid:26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000 \
-h localhost -u wsmantest -p wsmantest
If there is an event in the queue, the response will be like the following:
<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">
<s:header>
<wsa:action>http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/CIM_ProcessIndication</wsa:action>
<wsa:messageid>uuid:2782e580-3ec7-1ec7-8004-6ae2ccb7d000</wsa:messageid>
<wsa:relatesto>uuid:2782ce67-3ec7-1ec7-8002-6ae2ccb7d000</wsa:relatesto>
</s:header>
<s:body>
<wsen:pullresponse>
<wsen:enumerationcontext>uuid:26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000</wsen:enumerationcontext>
<n1:cim_processindication>
<n1:indicationidentifier>
ChangeOfUsers
</n1:indicationidentifier>
<n1:indicationtime></n1:indicationtime>
<n1:classname></n1:classname>
</n1:cim_processindication>
</wsen:pullresponse>
</s:body>
</s:envelope>
If there is no event in the queue, the response will be like:
<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">
<s:header>
<wsa:to>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:to>
<wsa:action>http://schemas.dmtf.org/wbem/wsman/1/wsman/fault</wsa:action>
<wsa:relatesto>uuid:3002e928-3ec7-1ec7-8002-6ae2ccb7d000</wsa:relatesto>
<wsa:messageid>uuid:3002ffb9-3ec7-1ec7-8005-6ae2ccb7d000</wsa:messageid>
</s:header>
<s:body>
<s:fault>
<s:code>
<s:value>s:Receiver</s:value>
<s:subcode>
<s:value>wsman:TimedOut</s:value>
</s:subcode>
</s:code>
<s:reason>
<s:text xml:lang="en">The operation has timed out.</s:text>
</s:reason>
</s:fault>
</s:body>
</s:envelope>
If the returned subscription Identifier is uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000
, renew this subscription to 200 seconds.
wsman renew -i uuid:26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000 \
-r 200 \
-h localhost -u wsman -p secret
If the returned subscription Identifier is uuid: 26dca9cb-3ec7-1ec7-8002-6ae2ccb7d000
, renew this subscription to 200 seconds.
wsman unsubscribe -i uuid:569f6af6-3ec7-1ec7-8002-6ae2ccb7d000 \
-h localhost -u wsman -p secret
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.