This lesson will show you how to prepare a YANG module and build the Server Instrumentation Library (SIL) that will be used to hold the instrumentation code you will write.



Pre-requisites


You should have installed and configured YumaPro SDK as described in the YumaPro SDK Installation Manual


Creating the SIL Source Code: make_sil_dir_pro


Instrumentation used by the server for various system attributes, interface counters, configuration data, etc., is provided by Server Instrumentation Libraries (SILs) which contain the code that hooks the YANG data model into the system. Creating SILs is heavily automated and shields the developer from the inner workings of NETCONF, the transaction model, protocol encoding, etc. The process is as follows:

 

  1. run make_sil_dir_pro with the YANG module you are working on to generate SIL source code
  2. add instrumentation to the code stubs in the source code files
  3. make and install
  4. load the SIL into the server


These steps will now be explained in more detail.


First, if you haven’t already done so, it is advisable to create a work directory so your work in progress will not conflict with existing modules such as those provided by YumaPro SDK. You can can either create your work in your $HOME/modules directory or you will need to add the work directory you choose to YumaPro SDK’s search path using the YUMAPRO_MODPATH environment variable:



    john> mkdir ~/work
    john> cd ~/work
    work> YUMAPRO_MODPATH=~/work
    work> export YUMAPRO_MODPATH



You will probably want to set YUMAPRO_MODPATH to your work directory in your system startup so it is set for your work even after a reboot.


For more on YumaPro environment variables see YumaPro User Manual section 4.1 Environment Variables



Then copy the YANG module you will be working on into your working directory. For the example in this lesson we are going to use the ietf-interfaces.yang module. Create the SIL source code that will be used for development using the YumaPro SDK tool make_sil_dir_pro as shown below:



    work> cp /usr/share/yumapro/modules/ietf/RFC/ietf-interfaces.yang  .
    work> make_sil_dir_pro --split ietf-interfaces --sil-get2 --sil-edit2



The output will look something like:



    modparms =  --sil-get2 --sil-edit2
   
    *** /home/john/work/ietf-interfaces.yang
    *** 0 Errors, 0 Warnings
     
   
    *** /home/john/work/ietf-interfaces.yang
    *** 0 Errors, 0 Warnings
   
   
    *** /home/john/work/ietf-interfaces.yang
    *** 0 Errors, 0 Warnings
   
   
    *** /home/john/work/ietf-interfaces.yang
    *** 0 Errors, 0 Warnings
  

    work> ls -al ietf-interfaces/src
    total 64
    drwxrwxr-x 2 john john  4096 Jan 11 12:38 ./
    drwxrwxr-x 5 john john  4096 Jan 11 12:38 ../
    -rw-rw-r-- 1 john john  6990 Jan 11 12:38 Makefile
    -rw-rw-r-- 1 john john 15426 Jan 11 12:38 u_ietf-interfaces.c
    -rw-rw-r-- 1 john john  8155 Jan 11 12:38 u_ietf-interfaces.h
    -rw-rw-r-- 1 john john 13712 Jan 11 12:38 y_ietf-interfaces.c
    -rw-rw-r-- 1 john john  4829 Jan 11 12:38 y_ietf-interfaces.h



This creates a directory with the same name as the YANG module, in this instance ietf-interfaces. Within that directory there is a bin, lib and src directory. The src directory contains the generated source files used to build the SIL:



Generated files
Description
Makefile
makefile to control the building and installation of the SIL
u_ietf-interfaces.c
user source code for the YANG module
u_ietf-interfaces.h
user header file for the YANG module
y_ietf-interfaces.c
YumaPro system source code for the YANG module
y_ietf-interfaces.h
YumaPro system header file for the YANG module



There are two types of source files, u_* user files and y_* YumaPro system files:


The u_* files contains the user callback functions needed to hook the YANG defined operational and configuration data to the underlying system. The code stubs in this file are typically replaced by the developer with system-specific function calls to commit database changes or retrieve data.  


The y_* files contain the system code that allows SILs to be protocol and encoding independent and includes the integration code to hook the user callback code into the transaction engine. You shouldn’t modify these files.



For more information see the YumaPro Developer Manual section 8.2 SIL Shared Libraries  and the make_sil_dir_pro manual page:

    mydir> man make_sil_dir_pro




Next Lesson:
 YANG and SIL Module Components