Skip to content

Commit

Permalink
library_bgp_speaker.rst: make an example more complete
Browse files Browse the repository at this point in the history
also, while i'm here, remove trailing whitespaces in the example.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
  • Loading branch information
yamt authored and fujita committed Jun 22, 2014
1 parent eb602ab commit 24f4a01
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions doc/source/library_bgp_speaker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,30 @@ instance advertizes some prefixes.
.. code-block:: python
import eventlet
# BGPSpeaker needs sockets patched
eventlet.patch()
# initialize a log handler
# this is not strictly necessary but useful if you get messages like:
# No handlers could be found for logger "ryu.lib.hub"
import logging
import sys
log = logging.getLogger()
log.addHandler(logging.StreamHandler(sys.stderr))
from ryu.services.protocols.bgp.bgpspeaker import BGPSpeaker
def dump_remote_best_path_change(event):
print 'the best path changed:', event.remote_as, event.prefix,\
event.nexthop, event.is_withdraw
if __name__ == "__main__":
speaker = BGPSpeaker(as_number=64512, router_id='10.0.0.1',
best_path_change_handler=dump_remote_best_path_change)
speaker.neighbor_add('192.168.177.32', 64513)
count = 1
while True:
eventlet.sleep(30)
Expand Down

0 comments on commit 24f4a01

Please sign in to comment.