cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
130
Views
10
Helpful
1
Replies
Beginner

YANG model editing newbie edition

I am developing a service to configure an interface on cisco ncs switch (runs ios-xr)

The configuration looks like this:

interface Loopback0
 ipv4 address 'masked'
 ipv6 address 'masked'
!
interface Bundle-Ether1
 description <<  Bundle-Ether 1 >>
 mtu 9180
ipv6 nd suppress-ra 	
ipv6 enable
load-interval 30
ipv4 address 'masked'
ipv6 address 'masked'
!
interface HundredGigE0/0/1/0
 description <<  Bundle-Ether1 >>
 bundle id 1 mode active
 shutdown
!
interface Bundle-Ether2
 description << Bundle-Ether 2 >>
 mtu 9180
 ipv6 nd suppress-ra
 ipv6 enable
 load-interval 30               
 ipv4 address  'masked'
 ipv6 address 'masked'
!
interface TenGigE0/0/0/0
 description  << channel1-bundle-Ether2 >>
 bundle id 2 mode active
!
interface TenGigE0/0/0/1
 shutdown
!

The yang model looks like this:

list my_interface {
    tailf:info "my interface setup";
    key "device interface";

    uses ncs:service-data;
    ncs:servicepoint my_interface-servicepoint;


    leaf device {
      tailf:info "Device name";
      type leafref {
        path "/ncs:devices/ncs:device/ncs:name";
      }
    }

    leaf interface {
      tailf:info "Interface name";
        type string;
    }

    leaf description {
      tailf:info "Mandatory description field";
      type string;
      mandatory true;
    }

    leaf v4-address {
      tailf:info "IPv4 address of the interface";
        type inet:ipv4-address;
    }

    leaf v4-mask {
      tailf:info "IPv4 subnet mask";
        type inet:ipv4-address;
    }

    leaf v6-address {
      tailf:info "IPv6 address of the interface";
      type inet:ipv6-address;
    }

    leaf v6-mask {
      tailf:info "IPv6 subnet mask";
        type inet:ipv6-address;
    }
  }
}

Am on the right track that I can create leaf objects for the attributes I need per the configuration?

Everyone's tags (4)
1 REPLY 1
Highlighted
Cisco Employee

Re: YANG model editing newbie edition

That looks to be on the right track.

Be aware that interfaces are a little bit tricky because the different interface types are actually different lists in the device model. If you want to support multiple interface types you might want some additional logic. You might want to use an enumeration to set the interface type, or you may just want to use the format of the string to figure it out, either way you probably will need some kind of conditional logic on your service to put your config in the right interface list.