diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-11 18:49:57 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-01-09 05:17:57 -0800 |
commit | 26c03bb779fbb59bb3de1c98a2c9d65e192b50bb (patch) | |
tree | f68629f1089561e494b26291bf3ec548c7eb93ef /tools/pyang_plugins/bgpyang2golang.py | |
parent | 6733b6afb27f3dd3943d8325d2656f9e98740c17 (diff) |
tools: avoid adding a new option to bgpyang2golang.py and fix gobgp.yang
pyang has an internal flag "multiple_modules" to handle multiple yang modules.
use it instead of introducing a new option --augment
also, fix warnings and errors in gobgp.yang which were there but not has been
detected for a while due to the usage of --augment.
by using "multiple_modules" flag, pyang detected them.
most notable error is wrong usage of list, which needs a key in its
substatement.
this patch adds key to some of them, and for others uses leaf-list
instead.
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 | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py index ed02b451..3b7702e9 100644 --- a/tools/pyang_plugins/bgpyang2golang.py +++ b/tools/pyang_plugins/bgpyang2golang.py @@ -45,21 +45,9 @@ def pyang_plugin_init(): class GolangPlugin(plugin.PyangPlugin): def add_output_format(self, fmts): + self.multiple_modules = True fmts['golang'] = self - - - def add_opts(self, optparser): - optlist = [ - optparse.make_option("--augment", - dest="augment", action="append", - help="Yang file which has augment statements"), - ] - g = optparser.add_option_group("GolangPlugin specific options") - g.add_options(optlist) - - - def emit(self, ctx, modules, fd): ctx.golang_identity_map = {} @@ -70,20 +58,8 @@ class GolangPlugin(plugin.PyangPlugin): ctx.prefix_rel = {} ctx.module_deps = [] - check_module_deps(ctx, modules[0]) - - # load augment module - if ctx.opts.augment: - aug_mod_path = ctx.opts.augment - for p in aug_mod_path: - with open(p) as fd: - try: - text = fd.read() - except IOError as ex: - sys.stderr.write("error %s: %s\n" % (aug_mod_path, str(ex))) - sys.exit(1) - aug_mod = ctx.add_module(p, text) - check_module_deps(ctx, aug_mod) + for m in modules: + check_module_deps(ctx, m) # visit yang statements visit_modules(ctx) @@ -207,6 +183,8 @@ def emit_class_def(ctx, yang_statement, struct_name, prefix): if is_leaflist(child): type_obj = child.search_one('type') type_name = type_obj.arg + val_name_go = val_name_go + 'List' + tag_name += '-list' # case leafref if type_name == 'leafref': @@ -532,7 +510,7 @@ _type_translation_map = { 'inet:ip-prefix': 'string', 'inet:ipv4-address': 'string', 'inet:as-number': 'uint32', - 'bgp-set-community-option-type' : 'string', + 'bgp-set-community-option-type': 'string', 'identityref' : 'string', 'inet:port-number': 'uint16', 'yang:timeticks': 'int64', |