cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2014
Views
0
Helpful
4
Replies

Yang module for List Interface on Device

Maurizio Bau
Level 1
Level 1

Hi Guys

 

I've a question about list of interfaces showing by means yang model.

Focus on cli section, when I try to configure an IOS-XR, I've display only particular port

### Cli Section ###

RP/0/RSP0/CPU0:9K3-MDR(config)#interface GigabitEthernet 0/6/0/?
0/6/0/0   0/6/0/1   0/6/0/10  0/6/0/11
0/6/0/12  0/6/0/13  0/6/0/14  0/6/0/15
0/6/0/16  0/6/0/17  0/6/0/18  0/6/0/19
0/6/0/2   0/6/0/3   0/6/0/4   0/6/0/5
0/6/0/6   0/6/0/7   0/6/0/8   0/6/0/9
R/S/I/P   
RP/0/RSP0/CPU0:9K3-MDR(config)#interface GigabitEthernet 0/6/0/

 

You can't configure, for example, Gigabitethernet 0/3/0/...

 

Is there the same condition on Yang model? I dont't want to use regular expression.

I have used the following references without success

 

leaf interfaceA {
                tailf:info "Interface Type";
                mandatory true;
                type leafref {
                    path "../../interface/name";

 

o

 

leaf interfaceA {
                tailf:info "Interface Type";
                mandatory true;
                type leafref {
                    path "/ncs:devices/ncs:device/ncs:config/ios:interface/ios:GigabitEthernet"

 

 

10ks

Maurizio

4 Replies 4

yfherzog
Cisco Employee
Cisco Employee

In terms of the data model, you CAN actually configure an interface which is not on the list.

GigabitEthernet is just a list in the NED YANG model, and the interface IDs which you see on the CLI autocomplete are instances of that list which already exists.

In case of a real device, it won't make much sense in most cases to create a new entry on that list through NSO, as there's no such physical interface on the device, but if you take for example a netsim IOS-XR device, then you should be able to freely create new interface on that list through NSO.

 

Having said that, while you can configure interfaces not on the list, you can't configure ANY interface name. The actual names you might be able to give a GigabitEthernet interface is dependent on the data type of the GigabitEthernet list key.

This type is probably a string with some sort of pattern limiting it, which is essentially a regular expression.

 

I'd suggest having a look into the src/yang directory inside the NED package to see the details.

 

 

With that being said, if you want a leaf in your model to only allow selection from existing instances on a given list (say, select from the currently existing GigabitEthernet interfaces), then you should be able to do it with a leafref.

 

You'd need to import the relevant NED into your module (in YANG and in the makefile), and then you should be able to write such leafref.

Can you provide any details on what wasn't working?

 

There were couple of such discussions before, so you can probably find a ready-made solution. Maybe the one here:

https://community.cisco.com/t5/nso-developer-hub-discussions/xpath-nested-deref-iterates-through-every-cdb-device/m-p/3582697/highlight/true#M2086

 

Hi yfherzog

 

I modified yang module like your indication without success

Please see the following code section

 

module E-LINERE {
  namespace "http://com/example/E-LINERE";
  prefix E-LINERE;

  import ietf-inet-types {
    prefix inet;
  }
  import tailf-ncs {
    prefix ncs;
  }
  import tailf-common {
    prefix tailf;
  }
  import tailf-ned-cisco-ios { 
	prefix ios; 
  } 
  
  description
    "This module contains a collection of YANG definitions for defining the PW service on TelecomItalia OPM network for the transport network End-2-End";
	
   revision 2018-11-15 {
    description
      "Prima revisione";
   }
  
  augment /ncs:services {
  list E-LINERE {
    key name;

    uses ncs:service-data;
    ncs:servicepoint "E-LINERE";

    leaf name {
      tailf:info "Service Instance Name";
          type string;
    }
	leaf deviceA {
		tailf:info "Selezionare il Primo Apparato";
		mandatory true;
		type leafref {
				path "/ncs:devices/ncs:device/ncs:name";
				}
	}
	
	choice interfaceA {
		case ios-GigabitEthernet {
				leaf GigabitEthernet {
					type leafref {
						/*path "/ncs:devices/ncs:device/ncs:config/ios:interface/ios:Ethernet/ios:name"; */
						path "/ncs:devices/ncs:device/ncs:config/ios:interface/GigabitEthernet/name";
						/* "deref(../../deviceA)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name"; */
								 }		
									}
								}
								
								
								
								
		case ios-TenGigabitEthernet {
				leaf TenGigabitEthernet {
					type leafref {
						path "deref(../../deviceA)/../ncs:config/ios:interface/ios:TenGigabitEthernet/ios:name";
								}
										}
									}
	}

My target is to list all available interface for a specific device when I'm configuring my service

 

admin@ncs(config)# services E-Line pippo deviceA A9K1-F1 interfaceA GigabitEthernet if_numberA ?
Description: Interface index
Possible completions:
  <string>


Similar when  I configure a device

admin@ncs(config)# devices device A9K1-F1 config cisco-ios-xr:interface GigabitEthernet 0/?
This line doesn't have a valid range expression
Possible completions:
  6/1/0      - === LINK per prove Urbini R. ===
  6/1/0.123  -
  6/1/0.230  - NSO - Servizio Punto-Punto -
  6/1/0.238  - NSO-PROVA
  6/1/1      -
  6/1/1.345  - NSO - Servizio Punto-Punto - A9K3-MDR to A9K1-F1 for Vlan 345
  6/1/2      -
  6/1/3      -
  6/1/4      -
  6/1/5      -
  6/1/6      -
--More--

 

 

Have a look at this code below:

 

    leaf device {
      type leafref {
        path "/ncs:devices/ncs:device/ncs:name";
      }
    }
    
    choice interface {
      case gig {
        leaf GigabitEthernet {
          type leafref {
            path "deref(../device)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name";
          }
        }
      }
      
      case ten-gig {         
        leaf TenGigabitEthernet {
          type leafref {
            path "deref(../device)/../ncs:config/ios:interface/ios:TenGigabitEthernet/ios:name";
          }
        }
      }
    }

 

In NSO it looks like this:

 

admin@ncs# show running-config devices device ios-0 config ios:interface 
devices device ios-0
 config
  ios:interface Loopback0
   ip address 127.0.0.1 255.0.0.0
   no shutdown
  exit
  ios:interface Ethernet0/0/0
   no switchport
   no ip address
   no shutdown
  exit
  ios:interface FastEthernet0
   no switchport
   no ip address
   no shutdown
  exit
  ios:interface FastEthernet0/0
   no switchport
   no ip address
   no shutdown
  exit
  ios:interface FastEthernet1/0
   no switchport
   no ip address
   no shutdown
  exit
  ios:interface FastEthernet1/1
   no switchport
   no ip address
   no shutdown
  exit
  ios:interface GigabitEthernet0
   no switchport
   no ip address
   no shutdown
  exit
  ios:interface GigabitEthernet0/0
   no switchport
   no ip address
   no shutdown
  exit
  ios:interface GigabitEthernet0/0/2
   description ggg
   no switchport
   no shutdown
  exit
  ios:interface GigabitEthernet0/1
   no switchport
   no ip address
   no shutdown
  exit
  ios:interface TenGigabitEthernet0/0/1
   no switchport
   no shutdown
  exit
  ios:interface TenGigabitEthernet0/0/2
   no switchport
   no shutdown
  exit
  ios:interface TenGigabitEthernet0/0/3
   no switchport
   no shutdown
  exit
 !
!
admin@ncs# config 
Entering configuration mode terminal
admin@ncs(config)# foo abc device ios-0                                              
admin@ncs(config-foo-abc)# GigabitEthernet ?
Possible completions:
  <0-66>/<0-128>   GigabitEthernet interface number
  0                
  0/0              
  0/0/2            ggg
  0/1              
admin@ncs(config-foo-abc)# TenGigabitEthernet ?
Possible completions:
  <0-66>/<0-128>   TenGigabitEthernet interface number
  0/0/1            
  0/0/2            
  0/0/3            
admin@ncs(config-foo-abc)#  

I think your leafref path had one too many "../".

You can use the xpath.trace log (under the logs directory) to debug such statements.

 

Yftach

hi yfherzog,

 

 

What if i want to do the same with ios xr?

Can i do a conditional code in the same service?

If so how can i access device type? (ios xr/xe - legacy ios?)

Is there any doc/pdf or cheatsheet about object properties and method (such ncs: xxxx or ncs:device[xxx = yyy] )


thanks!!!

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: