-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: add python grpc ListPeer API example
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |