summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-06-29 14:46:45 +0900
committerSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-06-30 13:30:36 +0900
commite314f126c1c5dc81c0d8ab33a4b450a10674052c (patch)
tree5f1201ea40fa231e0121dda5334fd02135d8bbd9
parentba2ac3e45272f2231494195335e706f2374ec877 (diff)
grpc: Update Ruby sample for GoBGP v1.20 gRPC API
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
-rw-r--r--docs/sources/grpc-client.md20
-rw-r--r--tools/grpc/ruby/get_neighbors.rb11
2 files changed, 12 insertions, 19 deletions
diff --git a/docs/sources/grpc-client.md b/docs/sources/grpc-client.md
index 32acef14..3cb8e55c 100644
--- a/docs/sources/grpc-client.md
+++ b/docs/sources/grpc-client.md
@@ -64,19 +64,13 @@ $ protoc -I $GOBGP_API --ruby_out=. --grpc_out=. --plugin=protoc-gen-grpc=`whic
Let's run this script.
```bash
-$ruby -I . ./get_neighbors.rb
-BGP neighbor is 192.168.10.2, remote AS 65001
- BGP version 4, remote route ID <nil>
- BGP state = BGP_FSM_ACTIVE, up for 0
- BGP OutQ = 0, Flops = 0
- Hold time is 0, keepalive interval is 0 seconds
- Configured hold time is 90
-BGP neighbor is 192.168.10.3, remote AS 65001
- BGP version 4, remote route ID <nil>
- BGP state = BGP_FSM_ACTIVE, up for 0
- BGP OutQ = 0, Flops = 0
- Hold time is 0, keepalive interval is 0 seconds
- Configured hold time is 90
+$ ruby -I . ./get_neighbors.rb 172.18.0.2
+BGP neighbor is 10.0.0.2, remote AS 65002
+ BGP version 4, remote route ID
+ BGP state = active, up for 0
+ BGP OutQ = 0, Flops = 0
+ Hold time is 0, keepalive interval is 0 seconds
+ Configured hold time is 90
```
## <a name="cpp"> C++
diff --git a/tools/grpc/ruby/get_neighbors.rb b/tools/grpc/ruby/get_neighbors.rb
index 36347373..a451f67f 100644
--- a/tools/grpc/ruby/get_neighbors.rb
+++ b/tools/grpc/ruby/get_neighbors.rb
@@ -1,12 +1,11 @@
-require 'gobgp'
-require 'gobgp_services'
+require 'gobgp_pb'
+require 'gobgp_services_pb'
-host = 'localhost'
-host = ARGV[0] if ARGV.length > 0
+host = ARGV[0]
stub = Gobgpapi::GobgpApi::Stub.new("#{host}:50051", :this_channel_is_insecure)
-arg = Gobgpapi::Arguments.new()
-stub.get_neighbors(arg).each do |n|
+arg = Gobgpapi::GetNeighborRequest.new()
+stub.get_neighbor(arg).peers.each do |n|
puts "BGP neighbor is #{n.conf.neighbor_address}, remote AS #{n.conf.peer_as}"
puts "\tBGP version 4, remote route ID #{n.conf.id}"
puts "\tBGP state = #{n.info.bgp_state}, up for #{n.timers.state.uptime}"