diff options
author | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2018-12-24 21:03:16 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2018-12-24 21:41:54 +0900 |
commit | 28d96f985bc59f344894f2e37cea5cb1bea062e5 (patch) | |
tree | 69f9272994d7e49918912d6200bb579a03188c10 /tools/grpc/python/get_neighbor.py | |
parent | 8e7741a0a80a1bd15a343563a29142f755c29f3f (diff) |
docs: update python gRPC API example
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'tools/grpc/python/get_neighbor.py')
-rw-r--r-- | tools/grpc/python/get_neighbor.py | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/tools/grpc/python/get_neighbor.py b/tools/grpc/python/get_neighbor.py deleted file mode 100644 index ff94569d..00000000 --- a/tools/grpc/python/get_neighbor.py +++ /dev/null @@ -1,29 +0,0 @@ -import gobgp_pb2_grpc -import gobgp_pb2 -import sys - -import grpc -from grpc.framework.interfaces.face.face import ExpirationError - -_TIMEOUT_SECONDS = 1 - - -def run(gobgpd_addr): - channel = grpc.insecure_channel(gobgpd_addr + ':50051') - stub = gobgp_pb2_grpc.GobgpApiStub(channel) - try: - peers = stub.GetNeighbor(gobgp_pb2.GetNeighborRequest()).peers - for peer in peers: - print("BGP neighbor is %s, remote AS %d" % (peer.conf.neighbor_address, peer.conf.peer_as)) - print(" BGP version 4, remote router ID %s" % (peer.conf.id)) - print(" BGP state = %s, up for %s" % (peer.info.bgp_state, peer.timers.state.uptime)) - print(" BGP OutQ = %d, Flops = %d" % (peer.info.out_q, peer.info.flops)) - print(" Hold time is %d, keepalive interval is %d seconds" % (peer.timers.state.negotiated_hold_time, peer.timers.state.keepalive_interval)) - print(" Configured hold time is %d, keepalive interval is %d seconds" % (peer.timers.config.hold_time, peer.timers.config.keepalive_interval)) - except ExpirationError, e: - print str(e) - sys.exit(-1) - -if __name__ == '__main__': - gobgp = sys.argv[1] - run(gobgp) |