summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/bgp_configs.go14
-rw-r--r--tools/pyang_plugins/README.rst23
-rw-r--r--tools/pyang_plugins/bgpyang2golang.py9
-rw-r--r--tools/pyang_plugins/gobgp.yang8
4 files changed, 32 insertions, 22 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go
index 41d32d52..42c3e750 100644
--- a/config/bgp_configs.go
+++ b/config/bgp_configs.go
@@ -17,6 +17,12 @@ package config
import "fmt"
+// typedef for typedef openconfig-types:std-regexp
+type StdRegexp string
+
+// typedef for typedef openconfig-types:percentage
+type Percentage uint8
+
// typedef for typedef bgp-types:rr-cluster-id-type
type RrClusterIdType string
@@ -45,7 +51,7 @@ func (v RemovePrivateAsOption) Validate() error {
}
// typedef for typedef bgp-types:bgp-community-regexp-type
-type BgpCommunityRegexpType string
+type BgpCommunityRegexpType StdRegexp
// typedef for typedef bgp-types:community-type
type CommunityType string
@@ -103,9 +109,6 @@ func (v PeerTypeDef) Validate() error {
return nil
}
-// typedef for typedef bgp-types:percentage
-type Percentage uint8
-
// typedef for typedef bgp-types:bgp-session-direction
type BgpSessionDirection string
@@ -1742,6 +1745,9 @@ type BgpConditions struct {
// original -> bgp-pol:next-hop-in
//original type is list of inet:ip-address
NextHopIn []string
+ // original -> bgp-pol:afi-safi-in
+ //original type is list of identityref
+ AfiSafiIn []string
// original -> bgp-pol:local-pref-eq
LocalPrefEq uint32
// original -> bgp-pol:community-count
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; }