mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
531 stars 342 forks source link

DSDL plugin supports only YANG version 1. #426

Closed apmanol closed 5 years ago

apmanol commented 5 years ago

Hello yang gurus,

I was trying to follow the advises for instance validation but I got the following error:

DSDL plugin supports only YANG version 1

When I tried to create the DSDL schema. Is there any workaround for this limitation? The module tested requires yang-version 1.1; (actually I want to used for the emacs setup)

Thanks a lot!

mbj4668 commented 5 years ago

There is a half-undocumented option:

--dsdl-lax-yang-version
                    Try to translate modules with unsupported YANG
                    versions (use at own risk)

This will work for many 1.1 modules, but there are some constructs that it will not handle properly.

apmanol commented 5 years ago

Indeed it fails in some cases. Should I report those cases, or wait for some solution someday?

llhotka commented 5 years ago

Some YANG 1.1 changes would require massive work on the DSDL plugin. I have currently no capacity to do it, and I am not sure it is worth doing - other validating software is available.

apmanol commented 5 years ago

Thanks for the feedback.

What other options exists for software validation? I would prefere to follow a path relative to some emacs setup.

Also I read some mail with reference to YANG-I-D but I believe this is mostly for the yang modules not the instances.

Vafa-Andalibi commented 5 years ago

@apmanol may I ask what did you end up doing or which other software you picked? I'm having the same problem.

apmanol commented 5 years ago

@Vafa-Andalibi unfortunately nothing, I didn't find any other option.

wlupton commented 5 years ago

I suggest taking a look at yanglint (part of libyang). There are some interactive examples here and you can also use non-interactive mode. (I am not involved in the libyang project... just a satisfied user.)

apmanol commented 5 years ago

I did a 5-minute experiment and couldn't figure out how to correctly setup the search module paths so I give up with yanglint.

wlupton commented 5 years ago

I think it's worth the effort. Here's an actual command that you might be able to adapt (I believe that you need to specify explicit paths for files specified on the command line, and that imported/included files will use the supplied search path):

% /usr/local/bin/yanglint \
    --path=<IETF-YANG-LOCATION> --verbose --allimplemented  \
    --strict --type=config --merge --format=xml --default=all-tagged \
    --output=ietf-interfaces.xml.out \
    <IETF-YANG-LOCATION>/iana-if-type.yang \
    <OTHER-YANG-LOCATION>/ietf-bulk-data-export.yang \
    <OTHER-YANG-LOCATION>/ietf-ipfix.yang \
    <OTHER-YANG-LOCATION>/ietf-psamp.yang \
    ietf-interfaces.xml
Vafa-Andalibi commented 5 years ago

Thank you @wlupton and @apmanol for your prompt reply, I tried yangint and it seems to be doing the job well:

$ yanglint ../mud_yangs/ietf-mud@2019-01-28.yang ./luminaire.json
$ echo $?
0

Then after introducing some faults in the file:

$ yanglint ../mud_yangs/ietf-mud@2019-01-28.yang ./luminaire.json
err : Unknown element "ipv8". (/ietf-access-control-list:acls/acl[name='mud-21966-v4fr']/aces/ace[name='loc0-frdev']/matches)
apmanol commented 5 years ago

@wlupton Thanks for tip!