diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-04-21 08:48:24 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-04-21 08:57:21 +0000 |
commit | a34d8d2651877998fe01d35350259c979a49d295 (patch) | |
tree | 220802d9c7b596c8636a80d116b9b9a38518c825 /tools/pyang_plugins/bgpyang2golang.py | |
parent | c6ddfb1d8ecc5944a775a458fbce648713ae3b02 (diff) |
config: simplify config structures
stop generating self-contained leafref fields in openconfig model.
(e.g. bgp:neighbor/bgp:neighbor-address )
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'tools/pyang_plugins/bgpyang2golang.py')
-rw-r--r-- | tools/pyang_plugins/bgpyang2golang.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py index 0ab5ab59..1f6ee7d0 100644 --- a/tools/pyang_plugins/bgpyang2golang.py +++ b/tools/pyang_plugins/bgpyang2golang.py @@ -168,6 +168,8 @@ def emit_class_def(ctx, yang_statement, struct_name, prefix): # case leafref elif type_name == 'leafref': + if type_obj.search_one('path').arg.startswith('../config'): + continue t = dig_leafref(type_obj) if is_translation_required(t): print >> o, ' //%s:%s\'s original type is %s' \ @@ -243,7 +245,10 @@ def emit_class_def(ctx, yang_statement, struct_name, prefix): l = t.i_children[0] emit_type_name = '[]' + l.golang_name equal_type = EQUAL_TYPE_MAP - equal_data = t.i_children[0].search_one('key').arg + equal_data = l.search_one('key').arg + leaf = l.search_one('leaf').search_one('type') + if leaf.arg == 'leafref' and leaf.search_one('path').arg.startswith('../config'): + equal_data = 'config.' + equal_data else: emit_type_name = t.golang_name equal_type = EQUAL_TYPE_CONTAINER @@ -692,9 +697,9 @@ def translate_type(key): # 'hoge-hoge' -> 'HogeHoge' def convert_to_golang(type_string): - a = type_string.split('-') + a = type_string.split('.') a = map(lambda x: x.capitalize(), a) # XXX locale sensitive - return ''.join(a) + return '.'.join( ''.join(t.capitalize() for t in x.split('-')) for x in a) # 'hoge-hoge' -> 'HOGE_HOGE' |