diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/pyang_plugins/bgpyang2golang.py | 20 | ||||
-rw-r--r-- | tools/pyang_plugins/gobgp.yang | 42 |
2 files changed, 57 insertions, 5 deletions
diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py index af440407..ff5900c0 100644 --- a/tools/pyang_plugins/bgpyang2golang.py +++ b/tools/pyang_plugins/bgpyang2golang.py @@ -23,7 +23,7 @@ _COPYRIGHT_NOTICE = """ // DO NOT EDIT // generated by pyang using OpenConfig https://github.com/openconfig/public // -// Copyright (C) 2014,2015 Nippon Telegraph and Telephone Corporation. +// Copyright (C) 2014-2016 Nippon Telegraph and Telephone Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -289,7 +289,10 @@ def emit_class_def(ctx, yang_statement, struct_name, prefix): if val_name == 'State': continue if typ == EQUAL_TYPE_LEAF: - print >> o, 'if lhs.{0} != rhs.{0} {{'.format(val_name) + if type_name == '[]byte': + print >> o, 'if bytes.Compare(lhs.{0}, rhs.{0}) != 0 {{'.format(val_name) + else: + print >> o, 'if lhs.{0} != rhs.{0} {{'.format(val_name) print >> o, 'return false' print >> o, '}' elif typ == EQUAL_TYPE_CONTAINER: @@ -301,11 +304,14 @@ def emit_class_def(ctx, yang_statement, struct_name, prefix): print >> o, 'return false' print >> o, '}' print >> o, 'for idx, l := range lhs.{0} {{'.format(val_name) - print >> o, 'if l != rhs.{0}[idx] {{'.format(val_name) + if type_name == '[][]byte': + print >> o, 'if bytes.Compare(l, rhs.{0}[idx]) != 0 {{'.format(val_name) + else: + print >> o, 'if l != rhs.{0}[idx] {{'.format(val_name) print >> o, 'return false' print >> o, '}' print >> o, '}' - elif typ ==EQUAL_TYPE_MAP: + elif typ == EQUAL_TYPE_MAP: print >> o, 'if len(lhs.{0}) != len(rhs.{0}) {{'.format(val_name) print >> o, 'return false' print >> o, '}' @@ -657,6 +663,7 @@ _type_translation_map = { 'inet:port-number': 'uint16', 'yang:timeticks': 'int64', 'ptypes:install-protocol-type': 'string', + 'binary': '[]byte', } @@ -688,7 +695,10 @@ def generate_header(ctx): print _COPYRIGHT_NOTICE print 'package config' print '' - print 'import "fmt"' + print 'import (' + print '"fmt"' + print '"bytes"' + print ')' print '' diff --git a/tools/pyang_plugins/gobgp.yang b/tools/pyang_plugins/gobgp.yang index f9aba5f7..9ccf1d4f 100644 --- a/tools/pyang_plugins/gobgp.yang +++ b/tools/pyang_plugins/gobgp.yang @@ -188,6 +188,23 @@ module gobgp { } + grouping gobgp-adjacent-table { + container adj-table { + leaf ADVERTISED { + type uint32; + } + + leaf RECEIVED { + type uint32; + } + + leaf ACCEPTED { + type uint32; + } + } + } + + grouping gobgp-timer { description "additional timer"; @@ -561,6 +578,27 @@ module gobgp { uses gobgp-message-counter; } + augment "/bgp:bgp/bgp:neighbors/bgp:neighbor/bgp:state" { + description "additional counters"; + uses gobgp-adjacent-table; + } + + + augment "/bgp:bgp/bgp:neighbors/bgp:neighbor/bgp:state" { + container Capabilities { + leaf-list remote { + type binary; + } + leaf-list local { + type binary; + } + } + + leaf received-open-message { + type binary; + } + } + augment "/bgp:bgp/bgp:neighbors/bgp:neighbor/bgp:config" { description "additional state elements"; @@ -580,6 +618,10 @@ module gobgp { "The state of administrative operation. If the state is true, it indicates the neighbor is disabled by the administrator"; } + leaf admin-state { + type string; + } + leaf established-count { type uint32; description |