Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for "uses" and "grouping" #117

Closed
lou-garavaglia opened this issue Mar 10, 2017 · 4 comments
Closed

Support for "uses" and "grouping" #117

lou-garavaglia opened this issue Mar 10, 2017 · 4 comments

Comments

@lou-garavaglia
Copy link

I am running pyangbind against the mef-classifier.yang model. I get the following error message when the pybind plugin encounters the "uses" keyword:

TypeError: unhandled keyword with children case at ciena-mef-classifier.yang:302 (at ciena-mef-classifi er.yang:142)

line 302 in the met-classifier.yang:
uses classifier-group;

classifier-group is defined as:
grouping classifier-group {
list classifier {
ordered-by user; // User sets the order of this list.
key "name";
etc...

What would it take to add support for "uses" and "grouping"?
Any hints are welcome.

@robshakir
Copy link
Owner

This doesn't look like the right line of that file - since there is no case statement in the output.

Both uses and grouping are not schematree nodes, so pyangbind doesn't output code for them. What looks to be happening here is that there is a nested case statement somewhere. If you can link to the original YANG files, then this is something that we can look at.

@lou-garavaglia
Copy link
Author

Hi Rob:
You are correct. There are nested case statements. This is an example yang file that reproduces the problem:

module mef-classifier {

namespace "urn:ltg:mef-classifier";
prefix "classifier";
typedef classifier-ref {
    type leafref { path "/classifier:classifiers/classifier:classifier/classifier:name"; }
 }
feature filter-parameters-type { }
grouping classifier-group {
    list classifier {
        ordered-by user;
        key "name";
        leaf name { type string; }
        list filter-entry {
            key "filter-parameter";
            ordered-by user;
            leaf filter-parameter { type string; }
            leaf logical-not { type boolean; }

            choice filter-parameters {
                case vtag-stack {
                    choice vtag-stack-type {
                        case untagged {
                            leaf untagged-exclude-priority-tagged { type boolean; }
                        }

                        case l2cp {
                            leaf l2cp-exclude-priority-tagged { type boolean; }
                        }
                    }
                }
            }
        }
    }
}
container classifiers { uses classifier-group; }

}

Here is the traceback I got:
test 147> pyang -f pybind mef-classifier.yang

from operator import attrgetter
from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType, RestrictedClassType, TypedListType
from pyangbind.lib.yangtypes import YANGBool, YANGListType, YANGDynClass, ReferenceType
from pyangbind.lib.base import PybindBase
from decimal import Decimal
from bitarray import bitarray
import builtin
Traceback (most recent call last):
File "/home/lou/.local/bin/pyang", line 5, in
pkg_resources.run_script('pyang==1.7.1', 'pyang')
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1455, in run_script
execfile(script_filename, namespace, namespace)
File "/home/lou/.local/lib/python2.7/site-packages/pyang-1.7.1-py2.7.egg/EGG-INFO/scripts/pyang", line 433, in
run()
File "/home/lou/.local/lib/python2.7/site-packages/pyang-1.7.1-py2.7.egg/EGG-INFO/scripts/pyang", line 407, in run
emit_obj.emit(ctx, modules, fd)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 217, in emit
build_pybind(ctx, modules, fd)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 409, in build_pybind
get_children(ctx, fd, children, m, m)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 725, in get_children
parent_cfg=parent_cfg, choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 1390, in get_element
choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 725, in get_children
parent_cfg=parent_cfg, choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 1390, in get_element
choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 725, in get_children
parent_cfg=parent_cfg, choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 1390, in get_element
choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 719, in get_children
choice=(ch.arg, choice_ch.arg), register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 1390, in get_element
choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 725, in get_children
parent_cfg=parent_cfg, choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 1390, in get_element
choice=choice, register_paths=register_paths)
File "/home/lou/.local/lib/python2.7/site-packages/pyangbind/plugin/pybind.py", line 783, in get_children
(parent.keyword, parent.pos))
TypeError: unhandled keyword with children case at mef-classifier.yang:36 (at mef-classifier.yang:23)

module: mef-classifier
+--rw classifiers
+--rw classifier* [name]
+--rw name string
+--rw filter-entry* [filter-parameter]
+--rw filter-parameter string
+--rw logical-not? boolean
+--rw (filter-parameters)?
+--:(vtag-stack)
+--rw (vtag-stack-type)?
+--:(untagged)
| +--rw untagged-exclude-priority-tagged? boolean
+--:(l2cp)
+--rw l2cp-exclude-priority-tagged? boolean

@JoseIgnacioTamayo
Copy link
Collaborator

This might be fixed in #340

@JoseIgnacioTamayo
Copy link
Collaborator

#340 was merged and included in https://github.com/robshakir/pyangbind/releases/tag/0.8.5

Considering this issue fixed. Please re-open if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants