diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-04-24 20:30:30 +0900 |
---|---|---|
committer | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-04-24 20:33:17 +0900 |
commit | 99133709be6c555b814347f7deb34f45129be5dd (patch) | |
tree | 45c206c8c25814ed0e7a4381b73c932bb29e90c2 /tools/pyang_plugins/bgpyang2golang.py | |
parent | f7401e177a2a60d6537339e6ee11576d23f32c41 (diff) |
config: add bgp-policy configuration
Diffstat (limited to 'tools/pyang_plugins/bgpyang2golang.py')
-rw-r--r-- | tools/pyang_plugins/bgpyang2golang.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py index c61d9c85..765e2f12 100644 --- a/tools/pyang_plugins/bgpyang2golang.py +++ b/tools/pyang_plugins/bgpyang2golang.py @@ -14,6 +14,7 @@ # limitations under the License. +import optparse import StringIO import sys from pyang import plugin @@ -46,6 +47,19 @@ class GolangPlugin(plugin.PyangPlugin): def add_output_format(self, fmts): fmts['golang'] = self + + + def add_opts(self, optparser): + optlist = [ + optparse.make_option("--augment", + dest="augment", + 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 = {} @@ -57,6 +71,19 @@ class GolangPlugin(plugin.PyangPlugin): ctx.module_deps = [] check_module_deps(ctx, modules[0]) + + # load augment module + if ctx.opts.augment: + aug_mod_path = ctx.opts.augment + try: + fd = open(aug_mod_path) + 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(aug_mod_path, text) + check_module_deps(ctx, aug_mod) + # visit yang statements visit_modules(ctx) # emit bgp_configs |