summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-11-07 15:06:26 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-11-07 15:06:26 +0900
commit416445b1dc6c4b4c93a09ccf226e0f79f3ca19a8 (patch)
tree447092711ad73760d75da3ae4ced6b49982678f2 /tools
parent79a9e200966271975cb5bc90325c0d8d7b6aa40d (diff)
tools: add python grpc ListPeer API example
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/grpc/python/list_peer.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/grpc/python/list_peer.py b/tools/grpc/python/list_peer.py
new file mode 100644
index 00000000..6f56dd45
--- /dev/null
+++ b/tools/grpc/python/list_peer.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+from __future__ import absolute_import
+from __future__ import print_function
+
+import grpc
+from google.protobuf.any_pb2 import Any
+
+import gobgp_pb2
+import gobgp_pb2_grpc
+import attribute_pb2
+
+_TIMEOUT_SECONDS = 1000
+
+
+def run():
+ channel = grpc.insecure_channel('localhost:50051')
+ stub = gobgp_pb2_grpc.GobgpApiStub(channel)
+
+ peers = stub.ListPeer(
+ gobgp_pb2.ListPeerRequest(
+ ),
+ _TIMEOUT_SECONDS,
+ )
+
+ for peer in peers:
+ print(peer)
+
+
+if __name__ == '__main__':
+ run()