From 416445b1dc6c4b4c93a09ccf226e0f79f3ca19a8 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Thu, 7 Nov 2019 15:06:26 +0900 Subject: tools: add python grpc ListPeer API example Signed-off-by: FUJITA Tomonori --- tools/grpc/python/list_peer.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tools/grpc/python/list_peer.py (limited to 'tools') 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() -- cgit v1.2.3