diff options
Diffstat (limited to 'tools/pyang_plugins')
-rw-r--r-- | tools/pyang_plugins/README.rst | 23 | ||||
-rw-r--r-- | tools/pyang_plugins/bgpyang2golang.py | 9 | ||||
-rw-r--r-- | tools/pyang_plugins/gobgp.yang | 8 |
3 files changed, 22 insertions, 18 deletions
diff --git a/tools/pyang_plugins/README.rst b/tools/pyang_plugins/README.rst index 10b44d71..b7dcf7ab 100644 --- a/tools/pyang_plugins/README.rst +++ b/tools/pyang_plugins/README.rst @@ -1,26 +1,23 @@ What's this ? ============= This is a pyang plugin to generate config/bgp_configs.go from -openconfig yang files. - -Currently, we made some modifications to the yang files: - - https://github.com/osrg/yang/tree/gobgp - +openconfig yang files (see [https://github.com/openconfig/public](https://github.com/openconfig/public)) How to use ========== :: - $ git clone -b gobgp https://github.com/osrg/yang - $ YANG_DIR=`pwd`/yang + $ git clone https://github.com/openconfig/public + $ git clone https://github.com/YangModels/yang + $ YANG_DIR=`pwd` $ cd $PYANG_INSTALL_DIR $ source ./env.sh $ PYTHONPATH=. ./bin/pyang --plugindir $GOBGP_PATH/tools/pyang_plugins \ - -p $YANG_DIR/standard/ietf/RFC \ - -p $YANG_DIR/experimental/openconfig/bgp \ - -p $YANG_DIR/experimental/openconfig/policy \ - -f golang $YANG_DIR/experimental/openconfig/bgp/bgp.yang \ - $YANG_DIR/bgp/bgp.yang $YANG_DIR/bgp/bgp-policy.yang \ + -p $YANG_DIR/yang/standard/ietf/RFC \ + -p $YANG_DIR/public/release/models \ + -p $YANG_DIR/public/release/models/bgp \ + -p $YANG_DIR/public/release/models/policy \ + -f golang $YANG_DIR/public/release/models/bgp/openconfig-bgp.yang \ + $YANG_DIR/public/release/modesl/policy/openconfig-routing-policy.yang \ $GOBGP_PATH/tools/pyang_plugins/gobgp.yang \ | gofmt > $GOBGP_PATH/config/bgp_configs.go diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py index ce64fce0..8acbfa02 100644 --- a/tools/pyang_plugins/bgpyang2golang.py +++ b/tools/pyang_plugins/bgpyang2golang.py @@ -448,7 +448,14 @@ def emit_typedef(ctx, module): else: print >> o, '// typedef for typedef %s:%s'\ % (prefix, type_name_org) - print >> o, 'type %s %s' % (type_name, t.arg) + + if not is_builtin_type(t): + m = ctx.golang_typedef_map + for k in t.arg.split(':'): + m = m[k] + print >> o, 'type %s %s' % (type_name, m.golang_name) + else: + print >> o, 'type %s %s' % (type_name, t.arg) print o.getvalue() diff --git a/tools/pyang_plugins/gobgp.yang b/tools/pyang_plugins/gobgp.yang index 73f886ad..701e408a 100644 --- a/tools/pyang_plugins/gobgp.yang +++ b/tools/pyang_plugins/gobgp.yang @@ -8,10 +8,10 @@ module gobgp { prefix "gobgp"; // import some basic types - import bgp { prefix bgp; } - import routing-policy {prefix rpol; } - import policy-types {prefix ptypes; } - import bgp-policy {prefix bgp-pol; } + import openconfig-bgp { prefix bgp; } + import openconfig-routing-policy {prefix rpol; } + import openconfig-policy-types {prefix ptypes; } + import openconfig-bgp-policy {prefix bgp-pol; } import ietf-inet-types { prefix inet; } import ietf-yang-types { prefix yang; } |