OpenSAF: Trying the Samples

Sample apps exist over in the “opensaf-4.0.M4/samples” directory. I started with the 1st one “avsv”.

AVSV Sample

This samples is located in the opensaf-4.0.M4/samples/avsv directory.

Building

First off, the compilation fails because it can’t find the default installed libraries, like this (for search engines):

root@eceni:/code/opensaf/opensaf-4.0.M4/samples/avsv# make
gcc -g -O2 -Wall -fPIC -I. -I/usr/include/opensaf -o amf_demo amf_demo.o -lSaAmf -lavsv_common -lopensaf_core
/usr/bin/ld: cannot find -lavsv_common
collect2: ld returned 1 exit status
make: *** [amf_demo] Error 1

So you really need to jam in a -L line into the link. As discussed in prior postings, in Ubuntu the libs were put in “/usr/local/lib/opensaf”. The cleanest way to get this to work is to edit the makefile in the avsv directory and fix it there. But we can also jam the value into a make variable that happens to be unused in the make, namely “CPPFLAGS”:


root@eceni:/code/opensaf/opensaf-4.0.M4/samples/avsv# make CPPFLAGS="-L /usr/local/lib/opensaf"
gcc -L /usr/local/lib/opensaf -g -O2 -Wall -fPIC -I. -I/usr/include/opensaf -o amf_demo amf_demo.o -lSaAmf -lavsv_common -lopensaf_core

Running

Running it is a bit tricky. How do you integrate this model within the existing default openSAF model so that the SAF AMF knows what to run? Well the model file (opensaf-4.0.M4/samples/avsv/AppConfig-2N.xml) suggests using the immxml-merge tool, which did not exist anywhere on my machine. But that’s ok, merging by hand is really quite simple. What you need to do is load /etc/opensaf/imm.xml and AppConfig-2N.xml into an editor. Then copy every “object” tag and all children to imm.xml. So basically you want to copy the entire file except the top-level “imm” tag. Copy it to the bottom of imm.xml, but INSIDE the “imm” tag in there…

Also, if you look at the xml file, you’ll see that the application’s directory is hard-coded to /opt/amf_demo (normal xml gt lt has been replaced with []):
[object class=”SaAmfNodeSwBundle”]
[dn]safInstalledSwBundle=safBundle=AmfDemo,safAmfNode=SC_2_2,safAmfCluster=myAmfCluster[/dn]
[attr]
[name]saAmfNodeSwBundlePathPrefix[/name]
[value]/opt/amf_demo[/value]

[/attr]
[/object]

So go ahead and create /opt/amf_demo and copy the executables over:

root@eceni:/# mkdir /opt/amf_demo
root@eceni:/code/opensaf/opensaf-4.0.M4/samples/avsv# cp amf_demo /opt/amf_demo/
root@eceni:/code/opensaf/opensaf-4.0.M4/samples/avsv# cp amf_demo_script /opt/amf_demo/
root@eceni:/code/opensaf/opensaf-4.0.M4/samples/avsv# cp amf_demo_package /opt/amf_demo/

Now you can start up openSAF in the usual fashion and the example should work!


root@eceni:/code/opensaf/opensaf-4.0.M4/samples/avsv# /etc/init.d/opensafd start
Mon Mar 1 16:11:16 EST 2010 - Starting OpenSAF
Mon Mar 1 16:11:16 EST 2010 - Starting Node Initialization Daemon: /usr/local/lib/opensaf/ncs_nid
Starting TIPC service... Done.
Starting RDF service... Done.
RDF-ROLE for this System Controller is: 0, ACTIVE
Starting DTSV service... Done.
Starting HLFM service... Done.
Starting IMMD service... Done.
Starting IMMND service... Done.
Starting LOGD service... Done.
Starting NTFD service... Done.
Starting EDSV service... Done.
Starting SCAP service... Done.
Node Initialization Successful.
SUCCESSFULLY SPAWNED ALL SERVICES!!!
Mon Mar 1 16:11:44 EST 2010 - OpenSAF Service Initialization Success

root@eceni:/code/opensaf/opensaf-4.0.M4/samples/avsv# ps -efww
root 2018 1 0 16:11 ? 00:00:00 /bin/bash /usr/local/lib/opensaf/nid_tipc start eth1 1234 NID_SVC_NAME=TIPC
root 2063 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_rde
root 2089 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_dts ROLE=1 NID_SVC_NAME=DTSV
root 2105 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/opensaf_fmsd ROLE=1 NID_SVC_NAME=HLFM
root 2120 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/opensaf_immd
root 2135 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/opensaf_immnd
root 2155 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/opensaf_saflogd
root 2178 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/opensaf_ntfd
root 2191 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_eds ROLE=1 NID_SVC_NAME=EDSV
root 2203 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/opensaf_scap ROLE=1 NID_SVC_NAME=SCAP
root 2232 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/opensaf_smfnd
root 2233 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/opensaf_smfd
root 2252 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_mqnd
root 2272 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_mqd
root 2296 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_glnd
root 2325 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_cpnd
root 2337 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_gld
root 2376 1 0 16:11 ? 00:00:00 /usr/local/lib/opensaf/ncs_cpd
root 2480 2018 0 16:15 ? 00:00:00 sleep 15
root 2491 1 0 16:15 ? 00:00:00 /opt/amf_demo/amf_demo instantiate comparg1 SC_2_1

As you can see by the “ps” the amf_demo program is running. And if you take a peek at the code you’ll see that it goes to syslog, so if you tail /var/log/messages you’ll see something like:

Mar 1 16:18:22 eceni amf_demo: #012#012 ##############################################
Mar 1 16:18:22 eceni amf_demo: # #
Mar 1 16:18:22 eceni amf_demo: # You are about to witness AvSv Demo !!! #
Mar 1 16:18:22 eceni amf_demo: # #
Mar 1 16:18:22 eceni amf_demo: ##############################################
Mar 1 16:18:22 eceni amf_demo: AMF thread entered
Mar 1 16:18:22 eceni amf_demo: AMF Initialization Done !!!
Mar 1 16:18:22 eceni amf_demo: #011AmfHandle: ff900001
Mar 1 16:18:22 eceni amf_demo: AMF Selection Object Get Successful !!!
Mar 1 16:18:22 eceni amf_demo: Component Name Get Successful !!!
Mar 1 16:18:22 eceni amf_demo: #011CompName: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo
Mar 1 16:18:22 eceni amf_demo: Component Registered !!!
Mar 1 16:18:22 eceni opensaf_immnd: Create runtime object ‘safSISU=safSu=SU1\#safSg=AmfDemo\#safApp=AmfDemo,safSi=AmfDemo,safApp=AmfDemo’ by Impl id: 4
Mar 1 16:18:22 eceni opensaf_immnd: Create runtime object ‘safCSIComp=safComp=AmfDemo\#safSu=SU1\#safSg=AmfDemo\#safApp=AmfDemo,safCsi=AmfDemo,safSi=AmfDemo,safApp=AmfDemo’ by Impl id: 4
Mar 1 16:18:22 eceni opensaf_scap: ‘safSu=SU1,safSg=AmfDemo,safApp=AmfDemo’ TERMINATING => INSTANTIATED
Mar 1 16:18:22 eceni amf_demo: Dispatched ‘CSI Set’ Callback for Component: ‘safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo’
Mar 1 16:18:22 eceni amf_demo: #011CSIName: safCsi=AmfDemo,safSi=AmfDemo,safApp=AmfDemo #012 HAState: Active #012 CSIFlags: Add One
Mar 1 16:18:22 eceni amf_demo: INVOKING saAmfHAStateGet() API !!!
Mar 1 16:18:24 eceni amf_demo: CompName: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 CSIName: safCsi=AmfDemo,safSi=AmfDemo,safApp=AmfDemo #012 HAState: Active
Mar 1 16:18:24 eceni amf_demo: DEMONSTRATING AMF-INITIATED HEALTHCHECK !!!
Mar 1 16:18:26 eceni amf_demo: Started AMF-Initiated HealthCheck (with Component Failover Recommended Recovery) #012 Comp: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:18:26 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:18:36 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:18:46 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:18:56 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:19:07 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:19:17 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:19:27 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:19:37 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:19:47 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:19:57 eceni amf_demo: #012 Dispatched ‘HealthCheck’ Callback #012 Component: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo #012 HealthCheckKey: AmfDemo
Mar 1 16:19:57 eceni amf_demo: #012 Stopped HealthCheck for Comp: safComp=AmfDemo,safSu=SU1,safSg=AmfDemo,safApp=AmfDemo with HealthCheckKey: AmfDemo
Mar 1 16:19:57 eceni amf_demo: #012#012 DEMONSTRATING COMPONENT FAILOVER THROUGH ERROR REPORT !!!

Great! Good job! You’ve gotten the demo app running on 1 node! Try doing 2 nodes. It should be the same process on the other node.

Advertisements

One Response to “OpenSAF: Trying the Samples”

  1. gandrewstone Says:

    Edit: Do not forget to change the /etc/opensaf/node_name file to contain an arbitrarily chosen node name. This node name MUST correspond to a node defined in the imm.xml file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: