Annotate openconfig style state data

Hi,

I am using openconfig-system.yang for DNS servers. This yang model has config and state containers inside list.

container servers {
    list server {
         leaf address {
              type leafref {
                    path "../config/address";
             }
         }

         container config {
         }
         container state {
         }
    }
}

If config data is filled, then it is reflecting in state data as well. I want to update state data from code instead of autofill. callpoint addition in dns/servers/server/state is calling get_elem with existing entries in config data instead of calling get_next and loop through entries fetched in code.

could you please let me know how i can annotate and please share if you have any example.

Several examples in the ConfD distribution show how to use tailf:annotate-module + tailf:annotate-statement or tailf:annotate to add callpoints etc. to existing modules. But if you are asking specifically about how to annotate openconfig-system so that your callpoint is invoked with get_next callback, you cannot, really - the list server is configurable, so unless you implement the configuration in an external database (and that would not solve your problem either), you will never receive callbacks for that list.

Technically, there is another option: you can implement NMDA callbacks. But OpenConfig modules are not NMDA-compatible, the results would hardly be satisfactory.

Hi @mvf ,

Thanks for the reply

Could you please suggest me a better approach in this case to update dns server state info from code
I will change the backend code as per your suggestion.

Thanks,
Karthik

Hi @mvf ,

I tried removing leafref and replaced type of address with inet:ip-address.
still i see get_elem is getting called with configured list entries. How does confd fetching keys in this scenario?

     |  +--rw servers
     |  |  +--rw server* [address]
     |  |     +--rw address    oc-inet:ip-address
     |  |     +--rw config
     |  |     |  +--rw address?   oc-inet:ip-address
     |  |     |  +--rw port?      oc-inet:port-number
     |  |     +--ro state
     |  |        +--ro address?   oc-inet:ip-address
     |  |        +--ro port?      oc-inet:port-number

Thanks,
Karthik

Modifying types cannot help you here. The point is that the list entries are configured (presumably in CDB), so ConfD does not need to query any data provider about them.

I’m afraid there are no good solutions here. If the software that uses the north-bound interfaces of your system is capable of using NMDA, you can have a look at that - as I wrote, the data model does not work well with NMDA, but it is at least something. You can possibly also add an action, something like populate-dns-servers, that would do just that - take a list of DNS servers and modify the configuration accordingly. Again, it would be of any use if the management software is capable of invoking the action.

If I understood the use case, another solution could be to register a CDB subscriber for the configuration that, when it changes, you want to update state data. The state data would not have a callpoint and thus reside in the CDB operational data store. The state data would be written to the CDB operational data store using either the CDB API or MAAPI.

Thanks for the reply.

i have a use case where dns server configuration list will be empty, but state data will be present. so in that case subscribe would not help. When user queries for the state data, callback must be called to update CDB.

No, that’s a very bad practice from the network management perspective. You can use MAAPI to populate the configuration, but you should do that only when your user (human or software) is aware of that you are changing the configuration, such as when the user invokes the action mentioned above.