cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2466
Views
10
Helpful
3
Replies

Yang modelling error - pyang

Andre Castro
Level 1
Level 1

Dear friends,

I'm a beginner on NSO services modelling and running into an issue while trying to run pyang against a yang file - described in one of the NSO lab guides.

NSO version is 5.1

Pyang 1.5, but also tried 1.7.8 and 2.1. Got the same errors though.

 

module vlan {
  namespace "http://com/example/vlan";
  prefix vlan;

  import ietf-inet-types {
    prefix inet;
  }
  import tailf-ncs {
    prefix ncs;
  }
  import tailf-common{
	prefix tailf;
  }
  description
	"Description...";
	
	revision 2019-11-05 {
		description
		"Initial revision";
	}
	augment /ncs:services{
		  list vlan {
			tailf:info "VLAN Service";
			key name;
			unique vlan-id;

			uses ncs:service-data;
			ncs:servicepoint "vlan";

			leaf name {
			  tailf:info "Service Instance Name";
			  type string;
			}
			leaf vlan-id{
				tailf:info "Unique VLAN ID";
				type uint32{
					range "1..4096";
				}
			}
			list device{
				tailf:info "L3 switch";
				key name;
				leaf name{
					tailf:info "Device name";
					type leafref{
						path "/ncs:devices/ncs:device/ncs:name";
					}
				}
			}
			list interface{
				tailf:info "Ethernet interface";
				key "intf-type intf-id";
				leaf intf-type{
					tailf:info "Ethernet interface type";
					type enumeration{
						enum Ethernet;
						enum FastEthernet;
						enum GigabitEthernet;
					}
				}
				leaf intf-id{
					tailf:info "Ethernet interface ID";
					type string;
				}
			}
		}
	}
}

Errors:

user@mypc:~/ncs-run/packages$ pyang vlan/src/yang/vlan.yang
vlan/src/yang/vlan.yang:5: warning: imported module ietf-inet-types not used
/home/user/nso/src/ncs/yang/ietf-yang-schema-mount.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/ietf-yang-schema-mount.yang:9: error: unexpected keyword "reference"
/home/user/nso/src/ncs/yang/ietf-yang-schema-mount.yang:15: error: unexpected keyword "reference"
/home/user/nso/src/ncs/yang/tailf-ncs-cluster.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-common.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-compliance.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-customers.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-devices.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-devices.yang:3707: error: XPath function "derived-from-or-self" is not defined in the XPath context
/home/user/nso/src/ncs/yang/tailf-ncs-devices.yang:3907: error: XPath function "derived-from-or-self" is not defined in the XPath context
/home/user/nso/src/ncs/yang/tailf-ncs-java-vm.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-log.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-packages.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-plan.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-python-vm.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-service-progress-monitoring.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-services.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-smart-license.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-snmp-notification-receiver.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-software.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs-ssh.yang:2: error: bad value "1.1" (should be version)
/home/user/nso/src/ncs/yang/tailf-ncs.yang:2: error: bad value "1.1" (should be version)

Any insights will be much appreciated.

 

Thank you

 

Andre

 

3 Replies 3

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

in theory starting release 1.7 pyang should support YANG 1.1 and so this should not be an issue (essentially this error comes from being check against the re_version regex: https://github.com/mbj4668/pyang/blob/b7264db134929809c9749aed700f187ee4973482/pyang/syntax.py#L112

 

However what could be happening is the following: when you source ncsrc then it inserts pyang version 1.5 in your path (look at `which pyang`) and it won't necessary use the version you have installed on your system but the version that is shipped with NSO.

 

user@/tmp$ which pyang
/usr/local/bin/pyang
user@/tmp$ pyang --version
user@/tmp$ source /var/nso-5.2.1/ncsrc
user@/tmp$ which pyang
/var/nso-5.2.1/bin/pyang
user@/tmp$ pyang --version
pyang 1.5

 

In theory the error reported for yang 1.1 models should not be there in pyang >= 1.7 - regarding why pyang is not changed in newer NSO version have a look at this: https://www.tail-f.com/alternatives-to-pyang-tool/

 

 

Eventually gave up from version 5.1.. Tried to work back with version 4.7 and worked as expected..

Please try under commands on NSO 5.1 version

 

yanger [yangfilename].yang

 

NSO uses yanger to validate yang file for latest nso versions.

pyang is deprecated.