Operational data - list key

Hello,

I am facing a strange problem with operational data.
I have a list inside a container where the callpoint is registered.

grouping group_y
{
leaf nodeA{ type string;}
}
container stats{
uses group_x;
list nodes{
key nodeA
uses group_y;
}
}

I am using the usual CONFD_SET functions to set the params. After I compile using this yang file, I am not able to see the nodeA parameter.

When I remove it as key, I am able to see the param, but my keypath values in the application is getting goofed up!

Kindly help.

Best regards,
Poornima.M

You can refer to the intro/5-c_stats example in the ConfD example set for details on how to implement your own operational data providers.

Can you elaborate on what do you mean by not able to see the nodeA parameter? Through which north bound interface? Feel free to provide more details of your problem if you are not able to figure out your issue after going through that example.

I meant, after setting the parameter (following the proceedure explained in confd user guide), when I try to see the set parameter from confd_cli i dont see that in the params list. Should i define a callpoint for the list as well?

Best regards,
Poornima.M

I’m suspecting that something may be wrong with your data provider code. If you can share your code, I can help to debug.

If I define my YANG model as follows:

module test {
  namespace "http://tail-f.com/ns/example/test";
  prefix test;

  import ietf-inet-types {
    prefix inet;
  }
  import tailf-common {
    prefix tailf;
  }

  container stats {
    config false;
    tailf:callpoint stats;
    list nodes {
      key node;
      leaf node {
        type string;
      }
    }
  }
}

and implement my get_elem( ) and get_next( ) code as follows:

#include "test.h"

#define MAX_STATS_ENTRIES	3

/********************************************************************/
static char node[MAX_STATS_ENTRIES][BUFSIZ];

static int run_stats(void)
{
    for (int i=0; i<MAX_STATS_ENTRIES; i++) {
        snprintf(node[i], BUFSIZ, "%s%d", "Node", i);
    }
    return CONFD_OK;
}

/********************************************************************/

static int s_init(struct confd_trans_ctx *tctx)
{
    confd_trans_set_fd(tctx, workersock);
    return CONFD_OK;
}

static int s_finish(struct confd_trans_ctx *tctx)
{
    return CONFD_OK;
}

/********************************************************************/

static int get_next(struct confd_trans_ctx *tctx,
                         confd_hkeypath_t *keypath,
                         long next)
{
    confd_value_t v[1];

    if (next == -1) {  /* first call */
        next = 0;
    }
    else {
        next++;
        if (next >= MAX_STATS_ENTRIES) {
            confd_data_reply_next_key(tctx, NULL, -1, -1);
            return CONFD_OK;
        }
    } 

    /* 1 key */
    CONFD_SET_STR(&v[0], node[next]);
    confd_data_reply_next_key(tctx, &v[0], 1, (long)next);
    return CONFD_OK;
}


/* Keypath example */
/* /stats/nodes{node1} */
/*    2     1     0    */

static int get_elem(struct confd_trans_ctx *tctx,
                    confd_hkeypath_t *keypath)
{
    confd_value_t v;
    int i;

    char *nodeName = (char*)CONFD_GET_BUFPTR(&keypath->v[1][0]);
    for (i=0; i<MAX_STATS_ENTRIES; i++) {
        if (strcmp(nodeName, node[i]) == 0) {
            break;
        }
    }

    if (i >= MAX_STATS_ENTRIES) {
       confd_data_reply_not_found(tctx);
       return CONFD_OK;
    }

    switch (CONFD_GET_XMLTAG(&(keypath->v[0][0]))) {
    case test_node:
        CONFD_SET_STR(&v, node[i]);
        break;
    default:
        return CONFD_ERR;
    }
    confd_data_reply_value(tctx, &v);
    return CONFD_OK;
}

I get the following from confd_cli:

WAITAI-M-K092:tembo-stats waitai1$ make cli
$CONFD_DIR/bin/confd_cli --user=admin --groups=admin \
		--interactive || echo Exit

admin connected from 127.0.0.1 using console on WAITAI-M-K092
admin@WAITAI-M-K092> show stats
NODE   
-------
Node0  
Node1  
Node2  

[ok][2015-12-21 10:33:41]
admin@WAITAI-M-K092> show stats nodes Node
Possible completions:
  Node0  Node1  Node2
admin@WAITAI-M-K092> show stats nodes Node0
NODE   
-------
Node0  

[ok][2015-12-21 10:34:02]
admin@WAITAI-M-K092>

Hi,

Thanks for your help(with examples) in understanding confd. Suppose here i want to show output (which i got from HW api) like “RX count 10”. At case test_node: I called HW api and did CONFD_SET_STR(&v, buffer]); but not worked please guide me.

show stats nodes Node0
RX count 10

Thanks,
madhira

Hi madhirasasi,

A good example to begin with is:
examples.confd/intro/5-c_stats

In you case you may want to store status data in the CDB Operational datastore instead of registering a callback with a YANG tailf:callpoint, a good example for that that implements interface status data is:
examples.confd/cdb_oper/ifstatus

Also see ConfD User Guide Chapter on “Operational Data”