cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
826
Views
0
Helpful
8
Replies

Pyang trhows error for yang 1.1 and anydata

sm000x
Level 1
Level 1

Hi,

I need to generate xsd from yang 1.1.
The yang 1.1 compiled OK in NSO 6.1.

But I got the error with pyang.
I use the command:
pyang -f xsd -o ./ppp dnnapi.yang

pyang throws error:
/opt/ncs/current/src/ncs/yang/tailf-ncs-plan.yang:2: error: bad value "1.1" (should be version)
dnnapi.yang:3: error: bad value "1.1" (should be version)

It also throws error for "anydata":
error: unexpected keyword "anydata"

Did I do anything wrong?

THX
sm000x

8 Replies 8

What version of pyang are you using? If i recall, "anydata" keyword was introduced in YANG 1.1, so you need a version of pyang that understands YANG 1.1.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Hi, bigevilbeard:

I use NSO-6.1's pyang.
Here is the pyang information:

(venv) -bash-5.1# pyang --version
pyang 1.5
(venv) -bash-5.1#

(venv) -bash-5.1# type pyang
pyang is hashed (/opt/ncs/current/bin/pyang)
(venv) -bash-5.1#

(venv) -bash-5.1# ls -l /opt/ncs/current
lrwxrwxrwx 1 root root 7 Aug 28 13:13 /opt/ncs/current -> ncs-6.1
(venv) -bash-5.1#

THX
sm000x

Hey @sm000x  NSO-6.1's pyang version 1.5. so this version of pyang should be able to generate XSD from yang 1.1 files one would think, but based on your error there may be inconsistencies between the yang 1.1 schema and pyang's expectations. Its a long shot, but use a different YANG to XSD converter like yang2xsd or oxyyang.

Hopefully someone else will know or have seen this.

Hope this helps.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Hi, Engager:

Thank you for the information. I could not find either yang2xsd or oxyyang from NSO-6.1 or from google. I will ask my colleagues for the packages.

THX
sm000x

Hi 

How does your YANG module look like? I think you may missing the version in the module:

module name-of-module {
  yang-version 1.1;
<SNIP>
}

HTH
Marcel

Hi, Marcel:

Here is my yang file:
submodule dnnapi {

yang-version 1.1;

belongs-to "Dnn" {
prefix Dnn;
}

Pyang complains /opt/ncs/current/src/ncs/yang/tailf-ncs.yang:2: error: bad value "1.1" (should be version) also.

THX
sm000x

Marcel Zehnder
Spotlight
Spotlight

As @bigevilbeard mentioned, this might be a pyang version issue - consider updating pyang:

pip install pyang --upgrade

Hi, Marcel:

Thank you for the instruction. I will do upgrade and give it a try.

THX
sm000x