summaryrefslogtreecommitdiffhomepage
path: root/tools/pyang_plugins/bgpyang2golang.py
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-20 02:52:59 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-20 02:52:59 +0900
commitb6e606a99480cffd47e73e7b74aa3a10df5ad47d (patch)
treead34613d89ea3316271ff6c2f82caff804ff9c81 /tools/pyang_plugins/bgpyang2golang.py
parent49e45d4e0c0a81dc8f9ec4b3a39433b22af04f16 (diff)
remove gRPC dependency from peer.go
move gRPC dependency from peer.go to grpc_server.go Preparation for the removal of gRPC dependency from packages except for api package. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'tools/pyang_plugins/bgpyang2golang.py')
-rw-r--r--tools/pyang_plugins/bgpyang2golang.py20
1 files changed, 15 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 ''