cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
782
Views
5
Helpful
1
Replies

Referencing all lists inside of a container

siemhermans
Level 1
Level 1

 

Hi all,

 

I'm trying to reference all (pre-)configured monitors on an F5 LTM through a path deref. When running make, the following error is thrown:

rm -rf ../load-dir
mkdir -p ../load-dir
/home/user/nso-4.7/bin/ncsc `ls f5-virtual-ip-ann.yang > /dev/null 2>&1 && echo "-a f5-virtual-ip-ann.yang"` \
--yangpath ../../f5-bigip/src/ncsc-out/modules/yang --yangpath ../../infoblox-nios/src/ncsc-out/modules/yang --yangpath ./yang/ -c -o ../load-dir/f5-virtual-ip.fxs yang/f5-virtual-ip.yang
yang/f5-virtual-ip.yang:87: error: the leafref refers to non-leaf and non-leaf-list node 'monitor' in module 'tailf-ned-f5-bigip' at ../../f5-bigip/src/ncsc-out/modules/yang/tailf-ned-f5-bigip.yang:14095
Makefile:27: recipe for target '../load-dir/f5-virtual-ip.fxs' failed
make: *** [../load-dir/f5-virtual-ip.fxs] Error 1

Which is fair, as the path shown in the YANG below references a container 'monitor' with each monitor defined as a list within that container. In the end I'd like to reference either the red or blue portions of the XML shown below. Either would work.

 

<ltm>
  <config>
    <monitor>   <--- Container
      <diameter>  <--- List1
        <name>diameter</name>
        [... Omitted ...]      
</diameter>
<dns> <--- List2 <name>dns</name> [... Omitted ...] </dns> <external> <name>external</name> [... Omitted ...] </external> <firepass> <name>firepass</name> [... Omitted ...] </firepass> <ftp> <name>ftp</name> [... Omitted ...] </ftp> </monitor> </config> </ltm>

The relevant service YANG is shown below:

 

[... Omitted ...]
list device { key "name"; leaf name { mandatory true; type leafref { path "/ncs:devices/ncs:device/ncs:name"; } } container pool { tailf:cli-drop-node-name; list pool-instance { key "pool_name"; leaf pool_name { type string; } leaf pool_monitor { type leafref { path "deref(../../../name)/../ncs:config/bigip:ltm/bigip:monitor"; } } leaf pool_min-active-members { type int8; } } } [... Omitted... ]

Can someone help me troubleshoot this faulty reference and/or explain the xPath involved to correctly reference the coloured nodes? Is this possible at all?

 

Thanks in advance.

 

1 Reply 1

Michael Maddern
Cisco Employee
Cisco Employee

Hi,

 

A leafref has to point to a single leaf (or leaf-list) - i.e. each part you have highlighted in blue. So each leaf needs to be referenced by a sepearate leafref.

 

You could create a leaf for each monitor, then put these inside a choice:

 

choice monitor {
  leaf diameter {
    type leafref {
      path "deref(../../../name)/../ncs:config/bigip:ltm/bigip:monitor/bigip:diameter/bigip:name";
    }
  }
  leaf dns {
    type leafref {
      path "deref(../../../name)/../ncs:config/bigip:ltm/bigip:monitor/bigip:dns/bigip:name";
    }
  }
  ... etc
}

Since YANG 1.1 supports union of leafrefs, you could create a type which is union of all the leafrefs. However, NSO just treats this a string. From the man-page for ncsc:

 

Type leafref in unions are not validated, and treated as a string internally.

 

Also, if you decide to do this, make sure you specify yang-version 1.1 in the yang file.