acidjunk / acidjunk/pyang

Deviations and DSDL plugin may not play well together

Abierto
#77 0 comentarios 0 reacciones 0 asignados Ver en GitHub
auto-migrated Priority-Medium Type-Defect
Lenguaje dominante
Python
Estrellas
0
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

```
I believe I've found a bug related to deviations within pyang DSDL plugin.
Deviations allow you to reference targets via absolute-schema-node-id which
means that it can reference anything in the expanded children of a statement
(one of the entries within Statement.i_children in pyang terms).

For some reason dsdl.py avoids using Statement.i_children all together. It has
it's own “expansion phases” which take care of augmentations, refinements
and grouping usages. Yet these fail to take deviations into account.

If I want to deviate a schema node which appears within the original statement
structure of a module then it's probably going to be okay if I generate DSDL
based on the deviated module. Pyang validation will simply change the original
statement tree by applying the deviation. However, if I want to deviate a
schema node which gets added to the schema tree via a grouping usage for
example, then I'm going to have a bad time. The only place where the deviation
will take effect is within Statement.i_children which never gets used within
dsdl.py.

I've enclosed two sample modules which demonstrate the bug. One defines a
schema tree and the other applies deviations to it. I used type-stmt replacing
but this bug applies to any deviate-stmt which targets “virtual schema
nodes”. If you use pyang to generate DSDL with these two modules, then the
first deviation will fail to replace the type within hybrid schema and the
second will succeed.

You should apply deviations the same way you do this for augmentation,
refinement and grouping usage. The problem is that the original statement tree
may have already been changed through deviations during module validation and
you have no way of knowing that. Or you should somehow check if a statement has
been deviated and create a new rng:define for it, instead of rng:ref-using the
rng:define for a grouping, etc. Either way you cannot avoid using
Statement.i_children.

I hope I succeeded in describing the problem. Deviations suck! :)

P.S.: the enclosed module which defines the schema tree has a dependency.
```

Original issue reported on code.google.com by `jernej.t...@gmail.com` on 12 Sep 2012 at 11:25

Attachments:
- [sample-interfaces@2012-09-12.yang](https://storage.googleapis.com/google-code-attachments/pyang/issue-77/comment-0/sample-interfaces@2012-09-12.yang)
- [sample-interfaces-devs@2012-09-12.yang](https://storage.googleapis.com/google-code-attachments/pyang/issue-77/comment-0/sample-interfaces-devs@2012-09-12.yang)

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.