cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Community Helping Community

276
Views
0
Helpful
2
Replies
Cisco Employee

Yang model and xml template with lists

Hi Team,

I have a config for BGP ECMP that consists of the need to set multiple static routes, bgp neighbors etc. (see whole staros config below)  I modeled the recurring interfaces information using a container/list in yang. However when I apply it I had expected it to run each set of list (key/parameters) over the xml template - instead it seems to not be updating the key and applying the ip address  parameters to the same key (i.e. interface) So for instance - you see in the below config - need to create multiple interfaces - they key is the called the slot  (seen as slot/10 in the names) and the parameter is the ip address:

   container interface {
    list parameters {
       key slot-number;
       leaf slot-number {
            type uint8;
       }
       leaf ip-address {
       type inet:ipv4-address;
    }

(whole yang model below.)

When I create two instances of the list - it tries to apply the ip address to the same interface and of course results in an error - see below bolded information from the xpath log where the interface name should have been updated to: vlan231-port-4/10 where 4 is the slot and the key, but it is not. I've included the XML template below too.

Any ideas - is my xpath in the xml template incorrect - or what construct should I be using in my yang model?

Thanks, JA

xpath log:

  not(count(../../address)>1 and

(not(../../address/secondary)))

num_instances("/ncs:devices/device{VPC-DI}/config/context{sgi}/interface{bgp-peer}/ip/address") = 1

4-Aug-2015::19:05:09.674 XPath for: /ncs:devices/device{VPC-DI}/config/context{sgi}/interface{bgp-peer}/ip/address{10.231.231.3}/address returns true

4-Aug-2015::19:05:09.674 Evaluating XPath for: /ncs:devices/device{VPC-DI}/config/context{sgi}/interface{vlan231-port-3/10}:

  (count(./ip/address/secondary)+count(./ipv6/secondary))<=1

get_next(/ncs:devices/device{VPC-DI}/config/context{sgi}/interface{vlan231-port-3/10}/ip/address) = {10.0.231.3}

exists("/ncs:devices/device{VPC-DI}/config/context{sgi}/interface{vlan231-port-3/10}/ip/address{10.0.231.3}/secondary") = false

get_next(/ncs:devices/device{VPC-DI}/config/context{sgi}/interface{vlan231-port-3/10}/ip/address{10.0.231.3}) = {10.0.231.4}

exists("/ncs:devices/device{VPC-DI}/config/context{sgi}/interface{vlan231-port-3/10}/ip/address{10.0.231.4}/secondary") = false

get_next(/ncs:devices/device{VPC-DI}/config/context{sgi}/interface{vlan231-port-3/10}/ip/address{10.0.231.4}) = false

get_next(/ncs:devices/device{VPC-DI}/config/context{sgi}/interface{vlan231-port-3/10}/ipv6) = false

So here is the  staros config:

  context sgi

    ip pool test 10.10.231.0 255.255.255.0 private 0

    bfd-protocol

    #exit

    router bgp 100

      maximum-paths ebgp 10

      neighbor 10.231.231.1 remote-as 200

      neighbor 10.231.231.1 ebgp-multihop max-hop 3

      neighbor 10.231.231.1 update-source 10.231.231.3

      neighbor 10.231.231.2 remote-as 200

      neighbor 10.231.231.2 ebgp-multihop max-hop 3

      neighbor 10.231.231.2 update-source 10.231.231.3

      address-family ipv4

        redistribute connected

      #exit

    #exit

    interface bgp-peer loopback

      ip address 10.231.231.3 255.255.255.255

    #exit

    interface vlan231-port-3/10

      ip address 10.0.231.3 255.255.255.0

      bfd interval 50 min_rx 50 multiplier 3

    #exit

    interface vlan231-port-4/10

      ip address 10.0.231.4 255.255.255.0

      bfd interval 50 min_rx 50 multiplier 3

    #exit

    interface vlan231-port-5/10

      ip address 10.0.231.5 255.255.255.0

      bfd interval 50 min_rx 50 multiplier 3

    #exit

    interface vlan231-port-6/10

      ip address 10.0.231.6 255.255.255.0

      bfd interval 50 min_rx 50 multiplier 3

    #exit

    subscriber default

    exit

    aaa group default

    #exit

    gtpp group default

    #exit

    ip route static bfd  vlan231-port-3/10 10.0.231.1

    ip route static bfd  vlan231-port-4/10 10.0.231.1

    ip route static bfd  vlan231-port-5/10 10.0.231.1

    ip route static bfd  vlan231-port-6/10 10.0.231.1

    ip route 10.231.231.1 255.255.255.255 10.0.231.1 vlan231-port-3/10

    ip route 10.231.231.1 255.255.255.255 10.0.231.1 vlan231-port-4/10

    ip route 10.231.231.1 255.255.255.255 10.0.231.1 vlan231-port-5/10

    ip route 10.231.231.1 255.255.255.255 10.0.231.1 vlan231-port-6/10

    ip route 10.231.231.2 255.255.255.255 10.0.231.2 vlan231-port-3/10

    ip route 10.231.231.2 255.255.255.255 10.0.231.2 vlan231-port-4/10

    ip route 10.231.231.2 255.255.255.255 10.0.231.2 vlan231-port-5/10

    ip route 10.231.231.2 255.255.255.255 10.0.231.2 vlan231-port-6/10

    ip igmp profile default

    #exit

  #exit

whole yang model:

module bgp-ecmp-context {

  namespace "http://com/example/bgp-ecmp-context";

  prefix bgp;

  import ietf-inet-types {

    prefix inet;

  }

  import tailf-ncs {

    prefix ncs;

  }

  import ietf-yang-types {

    prefix yang;

  }

  import tailf-common {

    prefix tailf;

        }

augment /ncs:services {

    container bgp-ecmp-context {

      list context-parameters {

      key name;

      uses ncs:service-data;

      ncs:servicepoint "bgp-ecmp-context";

      leaf name {

        tailf:info "Context to configure BGP-ECMP routing";

        type string;

      }

      list vpc {

      key device-vpc;

      leaf device-vpc {

        type leafref {

          path "/ncs:devices/ncs:device/ncs:name";

        }

        mandatory true;

      }

        leaf bgp-as-number {

                type uint16;

                mandatory true;

                }

        leaf remote-as {

                type uint16;

                mandatory true;

                }

        leaf sf-port {

                type uint8;

        }

        leaf vlanid {

                type uint16;

        }

        leaf loopback-ip {

                type inet:ipv4-address;

        }

        container interface {

        list parameters {

           key slot-number;

           leaf slot-number {

                type uint8;

           }

           leaf ip-address {

           type inet:ipv4-address;

        }

        }

        }

        list router{

           key device-router;

          leaf device-router {

                type leafref {

                path "/ncs:devices/ncs:device/ncs:name";

                }

                mandatory true;

           }

        leaf router-loopback-ip {

                type inet:ipv4-address;

                }

        leaf router-interface-ip {

                type inet:ipv4-address;

                 }

        }

     }

}

}

}

}

Whole xml template:

gmp@lattice:~/ncs-vpc/packages/mobileCloud/templates$ more bgp-ecmp-context.xml

<config-template xmlns="http://tail-f.com/ns/config/1.0" servicepoint="bgp-ecmp-context">

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

  <device>

    <name>{/vpc/device-vpc}</name>

      <config>

      <context xmlns="http://tail-f.com/ned/cisco-staros"  >

        <name>{/name}</name>

        <bfd-protocol>

        </bfd-protocol>

        <ip>

          <route>

            <route>

              <ip>{/vpc/router/router-loopback-ip}</ip>

              <mask>255.255.255.255</mask>

              <gateway-or-nexthop-address>{/vpc/router/router-interface-ip}</gateway-or-nexthop-address>

              <interface>

                <name>vlan{/vpc/vlanid}-port-{/vpc/interface/parameters/slot-number}/{/vpc/sf-port}</name>

              </interface>

            </route>

            <static>

              <bfd>

                <interface>vlan{/vpc/vlanid}-port-{/vpc/interface/parameters/slot-number}/{/vpc/sf-port}</interface>

                <gw-address>{/vpc/router/router-interface-ip}</gw-address>

              </bfd>

            </static>

          </route>

        </ip>

        <interface>

          <name>bgp-peer</name>

          <mode>loopback</mode>

          <ip>

            <address>

              <address>{/vpc/loopback-ip}</address>

              <subnetmask>255.255.255.255</subnetmask>

            </address>

          </ip>

        </interface>

        <interface>

          <name>vlan{/vpc/vlanid}-port-{/vpc/interface/parameters/slot-number}/{/vpc/sf-port}</name>

          <bfd>

            <interval>

              <interval>50</interval>

              <min_rx>50</min_rx>

              <multiplier>3</multiplier>

            </interval>

          </bfd>

          <ip>

            <address>

              <address>{/vpc/interface/parameters/ip-address}</address>

              <subnetmask>255.255.255.0</subnetmask>

            </address>

          </ip>

        </interface>

        <router>

          <bgp>

            <as-num>{/vpc/bgp-as-number}</as-num>

            <maximum-paths>

              <ebgp>10</ebgp>

            </maximum-paths>

            <neighbor>

              <ip-address>{/vpc/router/router-loopback-ip</ip-address>

              <remote-as>{/vpc/remote-as}</remote-as>

              <ebgp-multihop>

                <max-hop>3</max-hop>

              </ebgp-multihop>

              <update-source>{/vpc/loopback-ip}</update-source>

            </neighbor>

            <address-family>

              <ipv4-no-vrf>

                <ipv4>

                  <redistribute>

                    <connected/>

                  </redistribute>

                </ipv4>

              </ipv4-no-vrf>

            </address-family>

          </bgp>

        </router>

        <subscriber>

          <default>

          </default>

        </subscriber>

      </context>

      <port xmlns="http://tail-f.com/ned/cisco-staros">

        <ethernet>

          <slot>{/vpc/interface/parameters/slot-number}</slot>

          <port>{/vpc/sf-port}</port>

          <shutdown>false</shutdown>

          <vlan>

            <tag-id>{/vpc/vlanid}</tag-id>

            <shutdown>false</shutdown>

            <bind>

              <interface>

                <interface>vlan{/vpc/vlanid}-port-{/vpc/interface/parameters/slot-number}/{/vpc/sf-port}</interface>

                <context>{/name}</context>

              </interface>

            </bind>

          </vlan>

        </ethernet>

      </port>

      </config>

  </device>

  </devices>

</config-template>

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Yang model and xml template with lists

Hi JA,

To solve this problem I would create a XML template with the config for 1 ACL entry and would use java or python to interact with the different values of your list.

Cheers, Gustavo

View solution in original post

2 REPLIES 2
Cisco Employee

Re: Yang model and xml template with lists

Hi,

does anyone have experience with applying an xml for-each (<xsl:for-each> Element)  per <xsl:for-each> Element  to resolve the above issue of needing to apply the template for multiple values in a list?

I tried this out and looks like NCS  does not like the xsl tag:

packages package mobileCloud

package-version 1.0

description     "Skeleton for a resource facing service - RFS"

ncs-min-version [ 3.0 ]

directory       ./state/packages-in-use/1/mobileCloud

templates       [ staros-mgt-fundamentals system-activation ]

component InvCmds

  callback java-class-name [ com.example.mobileCloud.InvCmds ]

oper-status file-load-error

oper-status error-info "[bgp-ecmp-context.xml:10: 'xsl' is an unknown prefix.]"

admin@ncs#

Thanks, JA

Highlighted

Re: Yang model and xml template with lists

Hi JA,

To solve this problem I would create a XML template with the config for 1 ACL entry and would use java or python to interact with the different values of your list.

Cheers, Gustavo

View solution in original post

Content for Community-Ad
FusionCharts will render here