IOS-XR route-policies in NSO part 2

As an update to my previous post about route-policies in NSO, I managed to try out a very recent version of the Cisco IOS-XR NED that was more suited for the XR RPL behaviour.

Instead of defining a route-policy that contains one line with all prefixes, a prefix list is defined and a general route-policy that accepts a prefix-list name as a variable is created.

General route-policy:

route-policy INET_IN($PLIST)
  if destination in $PLIST then
    pass
  else
    drop
  endif
end-policy

The prefix-list is created in the xml template, iterating around the list of prefixes, and the prefix-list is reference through the general policy in the BGP neighbor definition

Partial XML template:

<prefix-set xmlns="http://tail-f.com/ned/cisco-ios-xr" tags="replace">
  <name tags="create">PL_INET_{$NAME}</name>
   <set>
    <value># {$CUSTOMER} - {$NAME} prefix set</value>
   </set>
   <?foreach {/prefixes}?>
    <!-- Test if prefix length is defined, then use it -->
    <?if {prfx_length} ?>
     <set>
      <value>{prefix} le {prfx_length}</value>
     </set>
    <!-- Test if prefix length is defined, if not don't use it -->
    <?else?>
     <set>
      <value>{prefix}</value>
     </set>
    <?end?>
   <?end?>
</prefix-set>
 
<router xmlns="http://tail-f.com/ned/cisco-ios-xr" tags="merge">
 <bgp>
  <bgp-no-instance>
   <id>1234</id>
   <vrf>
    <name>INET</name>
   <?foreach {bgp}?>
    <neighbor>
     <id>{customer_ip}</id>
      <remote-as>{customer_as}</remote-as>
       <address-family>
        <ipv4>
         <unicast>
          <route-policy>
           <direction>in</direction>
           <name>{concat('INET_IN(PL_INET_', $NAME, ')'}</name>
          </route-policy>
          <route-policy>
           <direction>out</direction>
           <name>DEFAULT</name>
          </route-policy>
          <maximum-prefix>
           <max-prefix-limit>{max_prefix}</max-prefix-limit>
           <threshold>90</threshold>
          </maximum-prefix>
         </unicast>
        </ipv4>
       </address-family>
       <!-- Test if BGP password is defined -->
       <?if {bgp_password}?>
       <password>
        <enc-type>clear</enc-type>
        <password>{bgp_password}</password>
       </password>
       <?end?>
    </neighbor>
   <?end?>
   </vrf>
  </bgp-no-instance>
 </bgp>
</router>