ConfD User Community

Refer to a column of a table


#1

I have a table modeled in YANG as follows:

	list InterfaceList {              
         description "interface entry";
         key "interfaceName";
         min-elements 1;
         
         leaf interfaceName {                      
             type String /*{
            pattern "gi[1-9][0-9]*";
            //pattern "^.*$";
          }*/;
          
         }
           
         leaf interfaceType {
          type interfaceType;
          description "interface type";
         }       
	} 

What means do I have in Yang to refer to all the values under interfaceType from somewhere else in the YANG module ? I considered leafref or identityref or but couldn’t see how this might help. Also can’t define a YANG compatible XPATH expression for this.


#2

If the “type interfaceType” is the same type as “somewhere else” then you can perhaps use tailf:link.

Say you have a similar interfaceList list somewhere else that you want to link interfaceType to:

tailf:link "/path/to/somewhere/else[interfaceName=current()/../interfaceName]/interfaceType";

#3

Thanks a lot, but your solution will provide the interface type only of a specific interface pointed to by the interface name. I’ll try to clarify: Suppose that somewhere else I have a leaf-list L of the same type as interface type. I want this leaf-list to refer to all interface types in the InterfaceList, that is per each interface type in the InterfaceList there should be a corresponding element in L.


#4

If you for example want a leaf-list to be populated by a list’s leaf child node that is not the list’s key node you get to use a transformation callpoint and write some code to go along with it.

See for example:
examples.confd/intro/10-c_transform


#5

Do you mean that there is no purely YANG solution to this problem ?


#6

Well, to be truthfull, all YANG become code and then 1s and 0s and so on. In this case you need to contribute with a small piece of code to help ConfD do what you want to do. ConfD accepts C, Python, Java, or Erlang at this time.