This lesson will show you how build and install a Server Instrumentation Library (SIL) created from a YANG module.


Pre-Requisites


You should have completed "Installing YumaPro SDK” and "Prepare a YANG module”.


Loading ietf-interfaces into the Server



YumaPro SDK provides a pre-built implementation of the ietf-interfaces SIL with sample instrumentation for the operational state data in the library libietf-interfaces.so.To use the library you need the YANG modules required for the instrumentation to be loaded into the server. You can accomplish this by running the server with the command:



    mydir> netconfd-pro --log-level=debug4 --access-control=off \
    --module=iana-if-type --module=ietf-interfaces



In a second terminal window start yangcli-pro and connect to the server. You can now display the live data from the system interfaces. By executing “sget /interfaces-state/interface/statistics” multiple times. You will see the YANG leaf counters updating that will look something like this:



    john@localhost> sget /interfaces-state/interface/statistics
   
    Filling container /interfaces-state/interface/statistics:
    RPC Data Reply 1 for session 4 [default]:
   
    rpc-reply {
      data {
        interfaces-state {
          interface  lo {
            name lo
            statistics {
              in-octets 7027687
              in-unicast-pkts 78233
              in-multicast-pkts 0
              in-discards 0
              in-errors 0
              out-octets 7027687
              out-unicast-pkts 78233
              out-discards 0
              out-errors 0
            }
          }
          interface  enp0s3 {
            name enp0s3
            statistics {
              in-octets 261979910
              in-unicast-pkts 223539
              in-multicast-pkts 73300
              in-discards 0
              in-errors 0
              out-octets 10326048
              out-unicast-pkts 119365
              out-discards 0
              out-errors 0
            }
          }
        }
      }
    }



The pre-built library included support for standard Linux interfaces. You can compare the values (they may be a little off depending on how close the two samples are and the data rate) from the pre-built library with the Linux system by using the command ifconfig:



    mydir> ifconfig
    enp0s3    Link encap:Ethernet  HWaddr 07:c3:1a:98:d2:34  
              inet addr:192.168.0.89  Bcast:192.168.0.255  Mask:255.255.255.0
              inet6 addr: fe70::5d61:963d:b802:35e/64 Scope:Link
              inet6 addr: 2305:e000:7b92:3f00:f068:d9b8:28a1:fe81/64 Scope:Global
              inet6 addr: 2305:e000:7b92:3f00:5a9e:57cd:7d8b:f8ca/64 Scope:Global
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:298724 errors:0 dropped:0 overruns:0 frame:0
              TX packets:120206 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:262341941 (262.3 MB)  TX bytes:10422964 (10.4 MB)
   
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:79452 errors:0 dropped:0 overruns:0 frame:0
              TX packets:79452 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1
              RX bytes:7177588 (7.1 MB)  TX bytes:7177588 (7.1 MB)


You will see while yangcli-pro is displaying the operational data, in the terminal window that netconfd-pro is running in the logging output displays the messages between the yangcli-pro client and server. The response message includes the ietf-interfaces statistics RPC reply is something like:



    yuma-netconf:input {
       filter {
         ietf-interfaces:interfaces-state {
           interface {
             statistics
           }
         }
         filter.metaQ
           yuma-ncx:type subtree
       }
     }
   
    ...
   
    <?xml version="1.0" encoding="UTF-8"?>
    <rpc-reply message-id="1"
     xmlns:ncx="http://netconfcentral.org/ns/yuma-ncx"
     ncx:last-modified="2018-02-01T01:54:29Z" ncx:etag="57380"
     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <data>
      <interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
       <interface>
        <name>lo</name>
        <statistics>
         <in-octets>7027687</in-octets>
         <in-unicast-pkts>78233</in-unicast-pkts>
         <in-multicast-pkts>0</in-multicast-pkts>
         <in-discards>0</in-discards>
         <in-errors>0</in-errors>
         <out-octets>7027687</out-octets>
         <out-unicast-pkts>78233</out-unicast-pkts>
         <out-discards>0</out-discards>
         <out-errors>0</out-errors>
        </statistics>
       </interface>
       <interface>
        <name>enp0s3</name>

    ...

       </interface>
      </interfaces-state>
         </data>
    </rpc-reply>
    agt_cb: Enter run_command_complete
    ses_msg: free msg 0x1eb5f20 for session 4



Edit, Build and Re-install the SIL


You can experiment and modify the library code. Add a non-destructive log message by following these steps:



    mydir> cd <your_YumaPro_source_code>/libietf-interfaces/src
    src> <your_editor> u_ietf-interfaces.c



In your editor search for the leaf "in-octets". You should find an area of code that looks like this:



    /* leaf in-octets (uint64) */
            if (!xml_strcmp(objname, (const xmlChar *)"in-octets") &&
                entry->stats->inbytes_set) {
   
                retval =
                    agt_make_uint64_leaf(obj,
                                         objname,
                                         entry->stats->inbytes,
                                         &res);
                if (retval && res == NO_ERR) {
                    getcb_add_return_val(get2cb, retval);
                }
            }


Add the log_debug line below:



    /* leaf in-octets (uint64) */
            if (!xml_strcmp(objname, (const xmlChar *)"in-octets") &&
                entry->stats->inbytes_set) {
   
            log_debug("\n\n ********** HERE IS SOME TEXT THAT STANDS OUT!     *********************\n");
   
                retval =
                    agt_make_uint64_leaf(obj,
                                         objname,
                                         entry->stats->inbytes,
                                         &res);
                if (retval && res == NO_ERR) {
                    getcb_add_return_val(get2cb, retval);
                }
            }



Save your change and exit your editor. Change directory to the root directory for the library and rebuild and install the new version of the library:



    src> cd ..
    libietf-interfaces> make
   
    ...
   
    libietf-interfaces> sudo make install
   
    ...



Now when you run the server and yangcli-pro again as before entering “sget /interfaces-state/interface/statistics” in yangcli-pro will cause the new log message you created to be out put in the server log output, something like:



    ...
   
    getcb: start GET_VALUE for 'statistics'
   
     ********** HERE IS SOME TEXT THAT STANDS OUT! *********************
   
    getcb: end GET_VALUE for 'statistics', status (ok)
    ses_msg: send 1.1 buff:988 for s:3
   
    trace_buff:
    ity>
    #982
    <?xml version="1.0" encoding="UTF-8"?>
    <rpc-reply message-id="1"
     xmlns:ncx="http://netconfcentral.org/ns/yuma-ncx"
     ncx:last-modified="2018-02-01T03:14:06Z" ncx:etag="57380"
     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <data>
      <interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
       <interface>
        <name>lo</name>
        <statistics>
         <in-octets>7149401</in-octets>
   
    ...





Next Lesson:
Operational Data