github.com/osrg/gobgp/v3@v3.30.0/tools/grpc/python/list_peer.py (about) 1 #!/usr/bin/env python 2 3 from __future__ import absolute_import 4 from __future__ import print_function 5 6 import grpc 7 from google.protobuf.any_pb2 import Any 8 9 import gobgp_pb2 10 import gobgp_pb2_grpc 11 import attribute_pb2 12 13 _TIMEOUT_SECONDS = 1000 14 15 16 def run(): 17 channel = grpc.insecure_channel('localhost:50051') 18 stub = gobgp_pb2_grpc.GobgpApiStub(channel) 19 20 peers = stub.ListPeer( 21 gobgp_pb2.ListPeerRequest( 22 ), 23 _TIMEOUT_SECONDS, 24 ) 25 26 for peer in peers: 27 print(peer) 28 29 30 if __name__ == '__main__': 31 run()