cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1420
Views
0
Helpful
1
Replies

pyang : Misleading yang error

DTtb
Level 1
Level 1

Hi all,
I tried to validate my yang model of my ncs service by pyang.

 

$ pyang -p /var/opt/ncs/packages/cisco-iosxr/src/yang testservice.yang

I got following error message:

testservice/src/yang/testservice.yang:13: warning: imported module ietf-inet-types not used
testservice/src/yang/testservice.yang:83: error: tailf-ned-cisco-ios-xr:interface in the path for TenGigE at testservice/src/yang/testservice.yang:79 is not found

for following yang model:

module testservice{

namespace "http://example.com/testservice";
prefix testservice;

import ietf-inet-types {
  prefix inet;
}
import tailf-common { prefix tailf; }
import tailf-ncs { prefix ncs; }
import tailf-ned-cisco-ios-xr { prefix cisco-ios-xr; }
[..] list devices { key device; leaf device { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } } leaf-list TenGigE { type leafref { path "deref(../device)/../ncs:config/cisco-ios-xr:interface/cisco-ios-xr:TenGigE/cisco-ios-xr:id"; } } }

}

I cannot understand, why pyang throw an error for testservice/src/yang/testservice.yang:83.

Inside NCS,  I got a autocomplete for the defined yang path:

admin@ncs% set services testservice devices device1 TenGigE TenGigE [
Possible completions:
0/0/1/0 ** DESCRIPTION ***
0/0/1/1 ** DESCRIPTION ***

 

NCS-Version: 4.7.2.1

NED-name: cisco-iosxr

NED-version: 7.10.1

1 Accepted Solution

Accepted Solutions

ramkraja
Cisco Employee
Cisco Employee

$ pyang -p /var/opt/ncs/packages/cisco-iosxr/src/yang testservice.yang
I got following error message:
testservice/src/yang/testservice.yang:83: error: tailf-ned-cisco-ios-xr:interface in the path for TenGigE at testservice/src/yang/testservice.yang:79 is not found

I cannot understand, why pyang throw an error for testservice/src/yang/testservice.yang:83.


Hello,

As a general comment, please note that NSO does NOT use pyang internally, and the pyang tool is not officially supported in any capacity. If you must use pyang, please use the opensource version at https://github.com/mbj4668/pyang.

NSO uses a tool called "yanger" internally, to validate and compile yang models. It is released with NSO, and if you have "ncs" in your path, you should have "yanger" in your path too. So, just use "yanger -p ... <module_name>", just like with pyang.

Now, coming to the specific error message in this issue, pyang says that it cannot find the node "tailf-ned-cisco-ios-xr:interface" under "ncs:config", in the provided models (yanger will give the same error). You should provide the 'device-compiled' models, and not the native models in the ned. So, change your path to 

/var/opt/ncs/packages/cisco-iosxr/src/ncsc-out/modules/yang

The modules under $(NED_DIR)/src/yang are the native modules. Those under $(NED_DIR)/src/ncsc-out/modules/yang are the 'augmented' modules, where the native modules are augmented under the "ncs" namespace. So, here is where pyang/yanger can find the NED specific nodes under "ncs:config".

/Ram

 

View solution in original post

1 Reply 1

ramkraja
Cisco Employee
Cisco Employee

$ pyang -p /var/opt/ncs/packages/cisco-iosxr/src/yang testservice.yang
I got following error message:
testservice/src/yang/testservice.yang:83: error: tailf-ned-cisco-ios-xr:interface in the path for TenGigE at testservice/src/yang/testservice.yang:79 is not found

I cannot understand, why pyang throw an error for testservice/src/yang/testservice.yang:83.


Hello,

As a general comment, please note that NSO does NOT use pyang internally, and the pyang tool is not officially supported in any capacity. If you must use pyang, please use the opensource version at https://github.com/mbj4668/pyang.

NSO uses a tool called "yanger" internally, to validate and compile yang models. It is released with NSO, and if you have "ncs" in your path, you should have "yanger" in your path too. So, just use "yanger -p ... <module_name>", just like with pyang.

Now, coming to the specific error message in this issue, pyang says that it cannot find the node "tailf-ned-cisco-ios-xr:interface" under "ncs:config", in the provided models (yanger will give the same error). You should provide the 'device-compiled' models, and not the native models in the ned. So, change your path to 

/var/opt/ncs/packages/cisco-iosxr/src/ncsc-out/modules/yang

The modules under $(NED_DIR)/src/yang are the native modules. Those under $(NED_DIR)/src/ncsc-out/modules/yang are the 'augmented' modules, where the native modules are augmented under the "ncs" namespace. So, here is where pyang/yanger can find the NED specific nodes under "ncs:config".

/Ram

 

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: