cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3586
Views
5
Helpful
12
Replies

[nso] L3VPN yang/template help

Carlos A. Silva
Level 3
Level 3

Hi, I'm trying to build a model for L3VPN provisioning with options. Options are: CE bgp routing  and CE static routing. I must add I'm a newbie to NSO.

Here's a snippet of my yang model. You'll see later on that variables like "intf-number" and "wan-ip-address" are being used properly, but variables within the "static" list are not. Or at least is not what I expected to happen and someone might offer me an explanation.

[snip]

      leaf intf-number {

        tailf:info "GigabitEthernet Interface ID";

        mandatory true;

        type string {

          pattern "[0-9]{1,2}(/[0-9]{1,2}){1,4}";

        }

      }

      leaf wan-ip-address {

        tailf:info "IP Address of WAN Interface (X.X.X.X)";

        mandatory true;

        type inet:ipv4-address {

          pattern "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+";

        }

      }

[snip]

      leaf routing-protocol {

        tailf:info "PE<-->CE Routing Protocol";

        mandatory true;

        type enumeration {

          enum bgp;

          enum static;

        }

      }

      list static  {

        tailf:info "Static Route for VRF";

        key static-prefix;

        when "../routing-protocol='static'";

        leaf static-prefix  {

          tailf:info "Static Route Prefix";

          mandatory true;

          type inet:ipv4-address;

        }

        leaf static-mask {

          tailf:info "Static Route Mask";

          mandatory true;

          type inet:ipv4-address;

        }

[snip]

Here's an extract of the XML template I'm using and that I expect the "static" list to fill out.

        <ip xmlns="http://tail-f.com/ned/cisco-ios-xr">

          <route tags='merge' when="{routing-protocol='static'}">

            <vrf>

              <name>{/vpn-name}</name>

              <dest>{/static-prefix}</dest>

              <dest-mask>{/static-mask}</dest-mask>

              <forwarding-address>{/static-next-hop}</forwarding-address>

            </vrf>

          </route>

        </ip>

Here's what you see in the tail-f cli.

admin@ncs(config)# services fullvpn test routing-protocol static static 1.1.1.0 static-mask 255.255.255.0 static-next-hop 172.16.1.2

Value for 'vpn-name' (<string>): test

Value for 'vpn-id' (<unsignedInt, 1 .. 9999>): 1

Value for 'vlan-id' (<unsignedInt, 1 .. 4000>): 1

Value for 'device' [IOS-0,IOS-1,XR-0,XR-1,...]: XR-0

Value for 'intf-number' (<string>): 0/0/0/0

Value for 'wan-ip-address' (<IPv4 address>): 172.16.1.1

admin@ncs(config-static-1.1.1.0)# commit dry-run outformat xml

result-xml {

    local-node {

        data <devices xmlns="http://tail-f.com/ns/ncs">

               <device>

                 <name>XR-0</name>

                 <config>

                   <vrf xmlns="http://tail-f.com/ned/cisco-ios-xr">

                     <vrf-list>

                       <name>test</name>

                       <address-family>

                         <ipv4>

                           <unicast>

                             <import>

                               <route-target>

                                 <address-list>

                                   <name>1:1</name>

                                 </address-list>

                               </route-target>

                             </import>

                             <export>

                               <route-target>

                                 <address-list>

                                   <name>1:1</name>

                                 </address-list>

                               </route-target>

                             </export>

                           </unicast>

                         </ipv4>

                       </address-family>

                     </vrf-list>

                   </vrf>

                   <ip xmlns="http://tail-f.com/ned/cisco-ios-xr">

                     <route>

                       <vrf>

                         <name>test</name>

                       </vrf>

                     </route>

                   </ip>

                   <interface xmlns="http://tail-f.com/ned/cisco-ios-xr">

                     <GigabitEthernet-subinterface>

                       <GigabitEthernet>

                         <id>0/0/0/0.1</id>

                         <ipv4>

                           <address>

                             <ip>172.16.1.1</ip>

                             <mask>255.255.255.252</mask>

                           </address>

                         </ipv4>

                         <vrf>test</vrf>

                         <encapsulation>

                           <dot1q>

                             <vlan-id>1</vlan-id>

                           </dot1q>

                         </encapsulation>

                       </GigabitEthernet>

                     </GigabitEthernet-subinterface>

                   </interface>

                   <router xmlns="http://tail-f.com/ned/cisco-ios-xr">

                     <bgp>

                       <bgp-no-instance>

                         <id>1</id>

                         <vrf>

                           <name>test</name>

                           <rd>1:1</rd>

                           <address-family>

                             <ipv4>

                               <unicast>

                                 <redistribute>

                                   <connected/>

                                   <static/>

                                 </redistribute>

                               </unicast>

                             </ipv4>

                           </address-family>

                         </vrf>

                       </bgp-no-instance>

                     </bgp>

                   </router>

                 </config>

               </device>

             </devices>

             <services xmlns="http://tail-f.com/ns/ncs">

               <fullvpn xmlns="http://com/example/fullvpn">

                 <name>test</name>

                 <vpn-name>test</vpn-name>

                 <vpn-id>1</vpn-id>

                 <vlan-id>1</vlan-id>

                 <device>XR-0</device>

                 <intf-number>0/0/0/0</intf-number>

                 <wan-ip-address>172.16.1.1</wan-ip-address>

                 <routing-protocol>static</routing-protocol>

                 <static>

                   <static-prefix>1.1.1.0</static-prefix>

                   <static-mask>255.255.255.0</static-mask>

                   <static-next-hop>172.16.1.2</static-next-hop>

                 </static>

               </fullvpn>

             </services>

    }

}

admin@ncs(config-static-1.1.1.0)#

As you can see, the XR static ip route is not filling out properly and the template uses only the variables that are outside of the static list node. Yet the services template at the very end sees the correct values in the variables, but under "services". All those variables are never configured in the router.

Any advice would be appreciated.

Thanks,

c.

1 Accepted Solution

Accepted Solutions

Larry, thank you very much for pointing to that section on that doc. That was it!

Thanks, everyone!

View solution in original post

12 Replies 12

snovello
Cisco Employee
Cisco Employee

Hello,

I would use the command

commit dry-run | debug template

which prints a trace of what the template evaluation. There is also an xpath.trace file in logs with traces of xpath evaluations that is sometimes helpful.

I will also guess at the problem - just by inspection because I have not tried to reproduce.

It would seem to me that the following when expression in your template is evaluated as false

<route tags='merge' when="{routing-protocol='static'}">

that would cause all the static route part of the config to be skipped.

Try adding a slash like '/routing-protocol'

cheers

Stefano

Hi, Stefano:

Tried adding the / and got the same results. The debug shows:

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/name (from file "fullvpn-template.xml", line 196)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 196)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "beti"

Setting /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/name to "beti"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/dest (from file "fullvpn-template.xml", line 197)

Evaluating "/static-prefix" (from file "fullvpn-template.xml", line 197)

Context node: /services/fullvpn:fullvpn[name='test']

Result: empty node

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/dest-mask (from file "fullvpn-template.xml", line 198)

Evaluating "/static-mask" (from file "fullvpn-template.xml", line 198)

Context node: /services/fullvpn:fullvpn[name='test']

Result: empty node

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/forwarding-address (from file "fullvpn-template.xml", line 199)

Evaluating "/static-next-hop" (from file "fullvpn-template.xml", line 199)

Context node: /services/fullvpn:fullvpn[name='test']

Result: empty node

Thanks!

c.

Actually, here's a few full debugs. (I think the incomplete previous one, might not be helpful).

admin@ncs(config-static-1.1.1.0)# commit dry-run | debug template

Evaluating "/device" (from file "fullvpn-template.xml", line 5)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "IOS-0"

Operation 'merge' on existing node: /devices/device[name='IOS-0'] (from file "fullvpn-template.xml", line 5)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 9)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "yeya"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya'] (from file "fullvpn-template.xml", line 9)

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/rd (from file "fullvpn-template.xml", line 10)

Fetching literal "1:" (from file "fullvpn-template.xml", line 10)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 10)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Setting /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/rd to "1:21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/address-family/ipv4 (from file "fullvpn-template.xml", line 12)

Fetching literal "1:" (from file "fullvpn-template.xml", line 15)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 15)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/address-family/ipv4/route-target/export[asn-ip='1:21'] (from file "fullvpn-template.xml", line 15)

Fetching literal "1:" (from file "fullvpn-template.xml", line 18)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 18)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/address-family/ipv4/route-target/import[asn-ip='1:21'] (from file "fullvpn-template.xml", line 18)

Evaluating "/intf-number" (from file "fullvpn-template.xml", line 27)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "0/2"

Fetching literal "." (from file "fullvpn-template.xml", line 27)

Evaluating "/vlan-id" (from file "fullvpn-template.xml", line 27)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21'] (from file "fullvpn-template.xml", line 27)

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/encapsulation/dot1Q/vlan-id (from file "fullvpn-template.xml", line 30)

Evaluating "/vlan-id" (from file "fullvpn-template.xml", line 30)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Setting /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/encapsulation/dot1Q/vlan-id to "21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/vrf/forwarding (from file "fullvpn-template.xml", line 34)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 34)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "yeya"

Setting /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/vrf/forwarding to "yeya"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/ip/address/primary/address (from file "fullvpn-template.xml", line 39)

Evaluating "/wan-ip-address" (from file "fullvpn-template.xml", line 39)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "172.16.1.1"

Setting /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/ip/address/primary/address to "172.16.1.1"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/ip/address/primary/mask (from file "fullvpn-template.xml", line 40)

Fetching literal "255.255.255.252" (from file "fullvpn-template.xml", line 40)

Setting /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/ip/address/primary/mask to "255.255.255.252"

Evaluating when-expression "boolean(/routing-protocol='static')" (from file "fullvpn-template.xml", line 47)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: true - continuing

Fetching literal "1" (from file "fullvpn-template.xml", line 48)

Operation 'merge' on existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1'] (from file "fullvpn-template.xml", line 48)

Fetching literal "unicast" (from file "fullvpn-template.xml", line 52)

Operation 'merge' on existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1']/address-family/with-vrf/ipv4[unicast-multicast='unicast'] (from file "fullvpn-template.xml", line 52)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 54)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "yeya"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1']/address-family/with-vrf/ipv4[unicast-multicast='unicast']/vrf[name='yeya'] (from file "fullvpn-template.xml", line 54)

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1']/address-family/with-vrf/ipv4[unicast-multicast='unicast']/vrf[name='yeya']/redistribute/connected (from file "fullvpn-template.xml", line 56)

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1']/address-family/with-vrf/ipv4[unicast-multicast='unicast']/vrf[name='yeya']/redistribute/static (from file "fullvpn-template.xml", line 57)

Evaluating when-expression "boolean(/routing-protocol='bgp')" (from file "fullvpn-template.xml", line 64)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: false - skipping siblings

Evaluating when-expression "boolean(/routing-protocol='static')" (from file "fullvpn-template.xml", line 84)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: true - continuing

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 86)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "yeya"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:ip/route/vrf[name='yeya'] (from file "fullvpn-template.xml", line 86)

Evaluating "/static-prefix" (from file "fullvpn-template.xml", line 88)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

Evaluating "/static-mask" (from file "fullvpn-template.xml", line 89)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

Evaluating "/static-next-hop" (from file "fullvpn-template.xml", line 90)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

Evaluating "/device" (from file "fullvpn-template.xml", line 99)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "IOS-0"

Operation 'merge' on existing node: /devices/device[name='IOS-0'] (from file "fullvpn-template.xml", line 99)

The device /devices/device[name='IOS-0'] does not support namespace 'http://tail-f.com/ned/cisco-ios-xr' for node "vrf" (from file "fullvpn-template.xml", line 101)

Skipping...

The device /devices/device[name='IOS-0'] does not support namespace 'http://tail-f.com/ned/cisco-ios-xr' for node "interface" (from file "fullvpn-template.xml", line 126)

Skipping...

The device /devices/device[name='IOS-0'] does not support namespace 'http://tail-f.com/ned/cisco-ios-xr' for node "router" (from file "fullvpn-template.xml", line undefined)

Skipping...

The device /devices/device[name='IOS-0'] does not support namespace 'http://tail-f.com/ned/cisco-ios-xr' for node "ip" (from file "fullvpn-template.xml", line undefined)

Skipping...

cli {

    local-node {

        data  devices {

                  device IOS-0 {

                      config {

                          ios:vrf {

             +                definition yeya {

             +                    rd 1:21;

             +                    address-family {

             +                        ipv4 {

             +                            route-target {

             +                                export 1:21;

             +                                import 1:21;

             +                            }

             +                        }

             +                    }

             +                }

                          }

                          ios:ip {

                              route {

             +                    vrf yeya {

             +                    }

                              }

                          }

                          ios:interface {

             +                GigabitEthernet 0/2.21 {

             +                    encapsulation {

             +                        dot1Q {

             +                            vlan-id 21;

             +                        }

             +                    }

             +                    vrf {

             +                        forwarding yeya;

             +                    }

             +                    ip {

             +                        address {

             +                            primary {

             +                                address 172.16.1.1;

             +                                mask 255.255.255.252;

             +                            }

             +                        }

             +                    }

             +                }

                          }

                          ios:router {

                              bgp 1 {

                                  address-family {

                                      with-vrf {

                                          ipv4 unicast {

             +                                vrf yeya {

             +                                    redistribute {

             +                                        connected {

             +                                        }

             +                                        static {

             +                                        }

             +                                    }

             +                                }

                                          }

                                      }

                                  }

                              }

                          }

                      }

                  }

              }

              services {

             +    fullvpn yeya {

             +        vpn-name yeya;

             +        vpn-id 21;

             +        vlan-id 21;

             +        device IOS-0;

             +        intf-number 0/2;

             +        wan-ip-address 172.16.1.1;

             +        routing-protocol static;

             +        static 1.1.1.0 {

             +            static-mask 255.255.255.0;

             +            static-next-hop 172.16.1.2;

             +        }

             +    }

              }

    }

}

admin@ncs(config-static-1.1.1.0)#

Actually, here's a few full debugs. (I think the incomplete previous one, might not be helpful).

admin@ncs(config-static-1.1.1.0)# commit dry-run | debug template

Evaluating "/device" (from file "fullvpn-template.xml", line 5)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "IOS-0"

Operation 'merge' on existing node: /devices/device[name='IOS-0'] (from file "fullvpn-template.xml", line 5)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 9)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "yeya"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya'] (from file "fullvpn-template.xml", line 9)

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/rd (from file "fullvpn-template.xml", line 10)

Fetching literal "1:" (from file "fullvpn-template.xml", line 10)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 10)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Setting /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/rd to "1:21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/address-family/ipv4 (from file "fullvpn-template.xml", line 12)

Fetching literal "1:" (from file "fullvpn-template.xml", line 15)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 15)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/address-family/ipv4/route-target/export[asn-ip='1:21'] (from file "fullvpn-template.xml", line 15)

Fetching literal "1:" (from file "fullvpn-template.xml", line 18)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 18)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:vrf/definition[name='yeya']/address-family/ipv4/route-target/import[asn-ip='1:21'] (from file "fullvpn-template.xml", line 18)

Evaluating "/intf-number" (from file "fullvpn-template.xml", line 27)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "0/2"

Fetching literal "." (from file "fullvpn-template.xml", line 27)

Evaluating "/vlan-id" (from file "fullvpn-template.xml", line 27)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21'] (from file "fullvpn-template.xml", line 27)

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/encapsulation/dot1Q/vlan-id (from file "fullvpn-template.xml", line 30)

Evaluating "/vlan-id" (from file "fullvpn-template.xml", line 30)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "21"

Setting /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/encapsulation/dot1Q/vlan-id to "21"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/vrf/forwarding (from file "fullvpn-template.xml", line 34)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 34)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "yeya"

Setting /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/vrf/forwarding to "yeya"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/ip/address/primary/address (from file "fullvpn-template.xml", line 39)

Evaluating "/wan-ip-address" (from file "fullvpn-template.xml", line 39)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "172.16.1.1"

Setting /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/ip/address/primary/address to "172.16.1.1"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/ip/address/primary/mask (from file "fullvpn-template.xml", line 40)

Fetching literal "255.255.255.252" (from file "fullvpn-template.xml", line 40)

Setting /devices/device[name='IOS-0']/config/ios:interface/GigabitEthernet[name='0/2.21']/ip/address/primary/mask to "255.255.255.252"

Evaluating when-expression "boolean(/routing-protocol='static')" (from file "fullvpn-template.xml", line 47)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: true - continuing

Fetching literal "1" (from file "fullvpn-template.xml", line 48)

Operation 'merge' on existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1'] (from file "fullvpn-template.xml", line 48)

Fetching literal "unicast" (from file "fullvpn-template.xml", line 52)

Operation 'merge' on existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1']/address-family/with-vrf/ipv4[unicast-multicast='unicast'] (from file "fullvpn-template.xml", line 52)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 54)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "yeya"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1']/address-family/with-vrf/ipv4[unicast-multicast='unicast']/vrf[name='yeya'] (from file "fullvpn-template.xml", line 54)

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1']/address-family/with-vrf/ipv4[unicast-multicast='unicast']/vrf[name='yeya']/redistribute/connected (from file "fullvpn-template.xml", line 56)

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:router/bgp[as-no='1']/address-family/with-vrf/ipv4[unicast-multicast='unicast']/vrf[name='yeya']/redistribute/static (from file "fullvpn-template.xml", line 57)

Evaluating when-expression "boolean(/routing-protocol='bgp')" (from file "fullvpn-template.xml", line 64)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: false - skipping siblings

Evaluating when-expression "boolean(/routing-protocol='static')" (from file "fullvpn-template.xml", line 84)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: true - continuing

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 86)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "yeya"

Operation 'merge' on non-existing node: /devices/device[name='IOS-0']/config/ios:ip/route/vrf[name='yeya'] (from file "fullvpn-template.xml", line 86)

Evaluating "/static-prefix" (from file "fullvpn-template.xml", line 88)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

Evaluating "/static-mask" (from file "fullvpn-template.xml", line 89)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

Evaluating "/static-next-hop" (from file "fullvpn-template.xml", line 90)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

Evaluating "/device" (from file "fullvpn-template.xml", line 99)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result:

For /services/fullvpn:fullvpn[name='yeya'], it evaluates to "IOS-0"

Operation 'merge' on existing node: /devices/device[name='IOS-0'] (from file "fullvpn-template.xml", line 99)

The device /devices/device[name='IOS-0'] does not support namespace 'http://tail-f.com/ned/cisco-ios-xr' for node "vrf" (from file "fullvpn-template.xml", line 101)

Skipping...

The device /devices/device[name='IOS-0'] does not support namespace 'http://tail-f.com/ned/cisco-ios-xr' for node "interface" (from file "fullvpn-template.xml", line 126)

Skipping...

The device /devices/device[name='IOS-0'] does not support namespace 'http://tail-f.com/ned/cisco-ios-xr' for node "router" (from file "fullvpn-template.xml", line undefined)

Skipping...

The device /devices/device[name='IOS-0'] does not support namespace 'http://tail-f.com/ned/cisco-ios-xr' for node "ip" (from file "fullvpn-template.xml", line undefined)

Skipping...

cli {

    local-node {

        data  devices {

                  device IOS-0 {

                      config {

                          ios:vrf {

             +                definition yeya {

             +                    rd 1:21;

             +                    address-family {

             +                        ipv4 {

             +                            route-target {

             +                                export 1:21;

             +                                import 1:21;

             +                            }

             +                        }

             +                    }

             +                }

                          }

                          ios:ip {

                              route {

             +                    vrf yeya {

             +                    }

                              }

                          }

                          ios:interface {

             +                GigabitEthernet 0/2.21 {

             +                    encapsulation {

             +                        dot1Q {

             +                            vlan-id 21;

             +                        }

             +                    }

             +                    vrf {

             +                        forwarding yeya;

             +                    }

             +                    ip {

             +                        address {

             +                            primary {

             +                                address 172.16.1.1;

             +                                mask 255.255.255.252;

             +                            }

             +                        }

             +                    }

             +                }

                          }

                          ios:router {

                              bgp 1 {

                                  address-family {

                                      with-vrf {

                                          ipv4 unicast {

             +                                vrf yeya {

             +                                    redistribute {

             +                                        connected {

             +                                        }

             +                                        static {

             +                                        }

             +                                    }

             +                                }

                                          }

                                      }

                                  }

                              }

                          }

                      }

                  }

              }

              services {

             +    fullvpn yeya {

             +        vpn-name yeya;

             +        vpn-id 21;

             +        vlan-id 21;

             +        device IOS-0;

             +        intf-number 0/2;

             +        wan-ip-address 172.16.1.1;

             +        routing-protocol static;

             +        static 1.1.1.0 {

             +            static-mask 255.255.255.0;

             +            static-next-hop 172.16.1.2;

             +        }

             +    }

              }

    }

}

admin@ncs(config-static-1.1.1.0)#

so it turns out my previous guess was wrong. Good thing is the trace tells you all about what is happening.

Evaluating when-expression "boolean(/routing-protocol='static')" (from file "fullvpn-template.xml", line 47)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: true - continuing

Above is where you see the evaluation of the when tstatement. It evaluates to true we would want in this case so its not the issue.

But further on when we are emitting the configuraion for the static route we see

Evaluating "/static-prefix" (from file "fullvpn-template.xml", line 88)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

Evaluating "/static-mask" (from file "fullvpn-template.xml", line 89)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

Evaluating "/static-next-hop" (from file "fullvpn-template.xml", line 90)

Context node: /services/fullvpn:fullvpn[name='yeya']

Result: empty node - skipping siblings

The problem is always the same. These leaves are in a list called 'static' so we should have it in our context or alternatively the xpath should not be the leaf but should mention the list 'static'.

Here is your template snippet again:

        <ip xmlns="http://tail-f.com/ned/cisco-ios-xr">

          <route tags='merge' when="{routing-protocol='static'}">

            <vrf>

              <name>{/vpn-name}</name>

              <dest>{/static-prefix}</dest>

              <dest-mask>{/static-mask}</dest-mask>

              <forwarding-address>{/static-next-hop}</forwarding-address>

            </vrf>

          </route>

        </ip>

Here are 2 alternative ways to change. Try them and look at the logs

<name>/static/vpn-name</name>

This changes the context so no need to change static-mask and static-next-hop

I would try this out, don't forget to try the case where you have multiple static routes, I think it may not work as needed for multiple nodes but you will see how the template evaluation works when an xpath expression returns a set of results

Alternatively use

<vrf foreach="{/static}">

Hi, Stefano:

First of all thank you very much for taking the time to help me learn this stuff.

I tried both your suggestions and still keep hitting empty nodes. I will keep moving stuff around, but here's the output for both your suggestions.

Thanks!

c.

xml template extract for suggestion 1:

        <ip xmlns="http://tail-f.com/ned/cisco-ios-xr">

          <route tags='merge' when="{/routing-protocol='static'}">

            <vrf>

              <name>{/static/vpn-name}</name>

              <dest>{/static-prefix}</dest>

              <dest-mask>{/static-mask}</dest-mask>

              <forwarding-address>{/static-next-hop}</forwarding-address>

            </vrf>

          </route>

        </ip>

Evaluating when-expression "boolean(/routing-protocol='static')" (from file "fullvpn-template.xml", line 194)

Context node: /services/fullvpn:fullvpn[name='test']

Result: true - continuing

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/name (from file "fullvpn-template.xml", line 196)

Evaluating "/static/vpn-name" (from file "fullvpn-template.xml", line 196)

Context node: /services/fullvpn:fullvpn[name='test']

Result: empty node

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/dest (from file "fullvpn-template.xml", line 197)

Evaluating "/static-prefix" (from file "fullvpn-template.xml", line 197)

Context node: /services/fullvpn:fullvpn[name='test']

Result: empty node

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/dest-mask (from file "fullvpn-template.xml", line 198)

Evaluating "/static-mask" (from file "fullvpn-template.xml", line 198)

Context node: /services/fullvpn:fullvpn[name='test']

Result: empty node

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/forwarding-address (from file "fullvpn-template.xml", line 199)

Evaluating "/static-next-hop" (from file "fullvpn-template.xml", line 199)

Context node: /services/fullvpn:fullvpn[name='test']

Result: empty node

xml template extract for suggestion 2:

admin@ncs(config-static-192.168.0.0)# commit dry-run outformat xml  

result-xml {

    local-node {

        data <devices xmlns="http://tail-f.com/ns/ncs">

               <device>

                 <name>XR-1</name>

                 <config>

                   <vrf xmlns="http://tail-f.com/ned/cisco-ios-xr">

                     <vrf-list>

                       <name>test</name>

                       <address-family>

                         <ipv4>

                           <unicast>

                             <import>

                               <route-target>

                                 <address-list>

                                   <name>1:101</name>

                                 </address-list>

                               </route-target>

                             </import>

                             <export>

                               <route-target>

                                 <address-list>

                                   <name>1:101</name>

                                 </address-list>

                               </route-target>

                             </export>

                           </unicast>

                         </ipv4>

                       </address-family>

                     </vrf-list>

                   </vrf>

                   <ip xmlns="http://tail-f.com/ned/cisco-ios-xr">

                     <route>

                       <vrf>

                         <name>test</name>

                       </vrf>

                     </route>

                   </ip>

                   <interface xmlns="http://tail-f.com/ned/cisco-ios-xr">

                     <GigabitEthernet-subinterface>

                       <GigabitEthernet>

                         <id>0/0/0/1.101</id>

                         <ipv4>

                           <address>

                             <ip>192.168.1.1</ip>

                             <mask>255.255.255.252</mask>

                           </address>

                         </ipv4>

                         <vrf>test</vrf>

                         <encapsulation>

                           <dot1q>

                             <vlan-id>101</vlan-id>

                           </dot1q>

                         </encapsulation>

                       </GigabitEthernet>

                     </GigabitEthernet-subinterface>

                   </interface>

                   <router xmlns="http://tail-f.com/ned/cisco-ios-xr">

                     <bgp>

                       <bgp-no-instance>

                         <id>1</id>

                         <vrf>

                           <name>test</name>

                           <rd>1:101</rd>

                           <address-family>

                             <ipv4>

                               <unicast>

                                 <redistribute>

                                   <connected/>

                                   <static/>

                                 </redistribute>

                               </unicast>

                             </ipv4>

                           </address-family>

                         </vrf>

                       </bgp-no-instance>

                     </bgp>

                   </router>

                 </config>

               </device>

             </devices>

             <services xmlns="http://tail-f.com/ns/ncs">

               <fullvpn xmlns="http://com/example/fullvpn">

                 <name>test</name>

                 <vpn-name>test</vpn-name>

                 <vpn-id>101</vpn-id>

                 <vlan-id>101</vlan-id>

                 <device>XR-1</device>

                 <intf-number>0/0/0/1</intf-number>

                 <wan-ip-address>192.168.1.1</wan-ip-address>

                 <routing-protocol>static</routing-protocol>

                 <static>

                   <static-prefix>192.168.0.0</static-prefix>

                   <static-mask>255.255.255.0</static-mask>

                   <static-next-hop>192.168.1.2</static-next-hop>

                 </static>

               </fullvpn>

             </services>

    }

}

admin@ncs(config-static-192.168.0.0)# commit dry-run | debug template

Evaluating "/device" (from file "fullvpn-template.xml", line 5)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "XR-1"

Operation 'merge' on existing node: /devices/device[name='XR-1'] (from file "fullvpn-template.xml", line 5)

The device /devices/device[name='XR-1'] does not support namespace 'urn:ios' for node "vrf" (from file "fullvpn-template.xml", line 7)

Skipping...

The device /devices/device[name='XR-1'] does not support namespace 'urn:ios' for node "interface" (from file "fullvpn-template.xml", line 25)

Skipping...

The device /devices/device[name='XR-1'] does not support namespace 'urn:ios' for node "router" (from file "fullvpn-template.xml", line undefined)

Skipping...

The device /devices/device[name='XR-1'] does not support namespace 'urn:ios' for node "ip" (from file "fullvpn-template.xml", line undefined)

Skipping...

Evaluating "/device" (from file "fullvpn-template.xml", line 99)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "XR-1"

Operation 'merge' on existing node: /devices/device[name='XR-1'] (from file "fullvpn-template.xml", line 99)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 103)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "test"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:vrf/vrf-list[name='test'] (from file "fullvpn-template.xml", line 103)

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:vrf/vrf-list[name='test']/address-family/ipv4/unicast (from file "fullvpn-template.xml", line 106)

Fetching literal "1:" (from file "fullvpn-template.xml", line 110)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 110)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "101"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:vrf/vrf-list[name='test']/address-family/ipv4/unicast/import/route-target/address-list[name='1:101'] (from file "fullvpn-template.xml", line 110)

Fetching literal "1:" (from file "fullvpn-template.xml", line 117)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 117)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "101"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:vrf/vrf-list[name='test']/address-family/ipv4/unicast/export/route-target/address-list[name='1:101'] (from file "fullvpn-template.xml", line 117)

Evaluating "/intf-number" (from file "fullvpn-template.xml", line 129)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "0/0/0/1"

Fetching literal "." (from file "fullvpn-template.xml", line 129)

Evaluating "/vlan-id" (from file "fullvpn-template.xml", line 129)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "101"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101'] (from file "fullvpn-template.xml", line 129)

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101']/ipv4/address/ip (from file "fullvpn-template.xml", line 132)

Evaluating "/wan-ip-address" (from file "fullvpn-template.xml", line 132)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "192.168.1.1"

Setting /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101']/ipv4/address/ip to "192.168.1.1"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101']/ipv4/address/mask (from file "fullvpn-template.xml", line 133)

Fetching literal "255.255.255.252" (from file "fullvpn-template.xml", line 133)

Setting /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101']/ipv4/address/mask to "255.255.255.252"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101']/vrf (from file "fullvpn-template.xml", line 136)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 136)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "test"

Setting /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101']/vrf to "test"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101']/encapsulation/dot1q/vlan-id (from file "fullvpn-template.xml", line 139)

Evaluating "/vlan-id" (from file "fullvpn-template.xml", line 139)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "101"

Setting /devices/device[name='XR-1']/config/cisco-ios-xr:interface/GigabitEthernet-subinterface/GigabitEthernet[id='0/0/0/1.101']/encapsulation/dot1q/vlan-id to "101"

Evaluating when-expression "boolean(/routing-protocol='static')" (from file "fullvpn-template.xml", line 146)

Context node: /services/fullvpn:fullvpn[name='test']

Result: true - continuing

Fetching literal "1" (from file "fullvpn-template.xml", line 148)

Operation 'merge' on existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:router/bgp/bgp-no-instance[id='1'] (from file "fullvpn-template.xml", line 148)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 150)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "test"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:router/bgp/bgp-no-instance[id='1']/vrf[name='test'] (from file "fullvpn-template.xml", line 150)

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:router/bgp/bgp-no-instance[id='1']/vrf[name='test']/rd (from file "fullvpn-template.xml", line 151)

Fetching literal "1:" (from file "fullvpn-template.xml", line 151)

Evaluating "/vpn-id" (from file "fullvpn-template.xml", line 151)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "101"

Setting /devices/device[name='XR-1']/config/cisco-ios-xr:router/bgp/bgp-no-instance[id='1']/vrf[name='test']/rd to "1:101"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:router/bgp/bgp-no-instance[id='1']/vrf[name='test']/address-family/ipv4/unicast (from file "fullvpn-template.xml", line 154)

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:router/bgp/bgp-no-instance[id='1']/vrf[name='test']/address-family/ipv4/unicast/redistribute/connected (from file "fullvpn-template.xml", line 156)

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:router/bgp/bgp-no-instance[id='1']/vrf[name='test']/address-family/ipv4/unicast/redistribute/static (from file "fullvpn-template.xml", line 157)

Evaluating when-expression "boolean(/routing-protocol='bgp')" (from file "fullvpn-template.xml", line 165)

Context node: /services/fullvpn:fullvpn[name='test']

Result: false - skipping siblings

Evaluating when-expression "boolean(/routing-protocol='static')" (from file "fullvpn-template.xml", line 194)

Context node: /services/fullvpn:fullvpn[name='test']

Result: true - continuing

Evaluating "/static" (from file "fullvpn-template.xml", line 195)

Context node: /services/fullvpn:fullvpn[name='test']

Result:

For /services/fullvpn:fullvpn[name='test']/static[static-prefix='192.168.0.0'], it evaluates to []

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/name (from file "fullvpn-template.xml", line 196)

Evaluating "/vpn-name" (from file "fullvpn-template.xml", line 196)

Context node: /services/fullvpn:fullvpn[name='test']/static[static-prefix='192.168.0.0']

Result:

For /services/fullvpn:fullvpn[name='test'], it evaluates to "test"

Setting /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/name to "test"

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/dest (from file "fullvpn-template.xml", line 197)

Evaluating "/static-prefix" (from file "fullvpn-template.xml", line 197)

Context node: /services/fullvpn:fullvpn[name='test']/static[static-prefix='192.168.0.0']

Result: empty node

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/dest-mask (from file "fullvpn-template.xml", line 198)

Evaluating "/static-mask" (from file "fullvpn-template.xml", line 198)

Context node: /services/fullvpn:fullvpn[name='test']/static[static-prefix='192.168.0.0']

Result: empty node

Operation 'merge' on non-existing node: /devices/device[name='XR-1']/config/cisco-ios-xr:ip/route/vrf/forwarding-address (from file "fullvpn-template.xml", line 199)

Evaluating "/static-next-hop" (from file "fullvpn-template.xml", line 199)

Context node: /services/fullvpn:fullvpn[name='test']/static[static-prefix='192.168.0.0']

Result: empty node

cli {

    local-node {

        data  devices {

                  device XR-1 {

                      config {

                          cisco-ios-xr:vrf {

             +                vrf-list test {

             +                    address-family {

             +                        ipv4 {

             +                            unicast {

             +                                import {

             +                                    route-target {

             +                                        address-list 1:101;

             +                                    }

             +                                }

             +                                export {

             +                                    route-target {

             +                                        address-list 1:101;

             +                                    }

             +                                }

             +                            }

             +                        }

             +                    }

             +                }

                          }

                          cisco-ios-xr:ip {

                              route {

                                  vrf {

             +                        name test;

                                  }

                              }

                          }

                          cisco-ios-xr:interface {

             +                GigabitEthernet 0/0/0/1.101 {

             +                    ipv4 {

             +                        address {

             +                            ip 192.168.1.1;

             +                            mask 255.255.255.252;

             +                        }

             +                    }

             +                    vrf test;

             +                    encapsulation {

             +                        dot1q {

             +                            101;

             +                        }

             +                    }

             +                }

                          }

                          cisco-ios-xr:router {

                              bgp {

                                  bgp-no-instance 1 {

             +                        vrf test {

             +                            rd 1:101;

             +                            address-family {

             +                                ipv4 {

             +                                    unicast {

             +                                        redistribute {

             +                                            connected {

             +                                            }

             +                                            static {

             +                                            }

             +                                        }

             +                                    }

             +                                }

             +                            }

             +                        }

                                  }

                              }

                          }

                      }

                  }

              }

              services {

             +    fullvpn test {

             +        vpn-name test;

             +        vpn-id 101;

             +        vlan-id 101;

             +        device XR-1;

             +        intf-number 0/0/0/1;

             +        wan-ip-address 192.168.1.1;

             +        routing-protocol static;

             +        static 192.168.0.0 {

             +            static-mask 255.255.255.0;

             +            static-next-hop 192.168.1.2;

             +        }

             +    }

              }

    }

}

admin@ncs(config-static-192.168.0.0)#

Yes trial and error can eventually get you to the result. However, instead of just 'moving stuff around', you may want to read through the NSO development Guide, Templates, Chapter 11, and especially the 'XPath Context in config-templates' sub-section in detail for a better understanding of what is happening in the template processing.

Thank you very much, Larry. I know I need all the help I can get.

I looked for the guide and couldn't find it. Is this an internal Cisco doc?

It’s in the doc directory of your NSO installation

Cheers,

KJ.

Thank you very much, KJ (and everyone). Really appreciate it.

Larry, thank you very much for pointing to that section on that doc. That was it!

Thanks, everyone!

Though this post is several years old, I thought I would share the exact thing that I did to solve this same issue.
I built a YANG model and XML template to configure ssl-vpn service settings on a firewall device. The way the settings are nested in NSO was unattractive from an operator perspective, so I grouped the nested containers from the NED, i.e:

....
    <vpn>
        <ssl>
            <settings>
                <cert>...</cert>
  <tunnel>...</tunnel>
<etc>...</etc> </settings> <web> <portal> <portal-list> <name>...</name> <mode>...</mode>
<etc>...</etc> </portal-list> <portal> </web> </ssl> </vpn> ...

in the YANG became:

    grouping version-grouping {
        container ssl-vpn-settings {
            leaf cert {
                ...
            }
            leaf tunnel {
                ...
            }
            leaf etc {
                ...
            }
        }

        container portal-settings {
            list portal {
                key name;
                
                leaf name {
                    ...
                }

                leaf mode {
                    ...
                }

                leaf etc {
                    ...
                }
            }
        }
    }

The problem was--since the YANG model/XPath refs did not map one-to-one with the nested "settings" tags--I had to add a "set-context-node" in the XML between the

<settings>
<?set-context-node {./ssl-vpn-settings}?>
<cert>{cert}</cert>
(*NOTE: ^^^^ no prepended '/' because context is already set.)
... </settings>

tags to reference my "ssl-vpn-settings" container and provide the right XPath context! Such a relief when I figured it out. I had been getting "Result: empty node" for a while.

The "portal-settings" list required a "foreach" statement, and keying off a list leaf-type changed the context automatically.

example:

...
</settings>
<web> <portal> <portal-list foreach="{../portal-settings/portal}">
... </portal-list> </portal> </web>
..

Anyway, I hope this helps someone else!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: