summaryrefslogtreecommitdiffhomepage
path: root/doc/source
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2014-06-20 15:51:58 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-06-22 12:32:39 +0900
commit24f4a01bc446713077e88f3c80a016fad5d963fd (patch)
treef1e0e9afb676ad94801ee240b6c7607ec68c1578 /doc/source
parenteb602ab71da6653e3c2dd99b433811e1da60d54b (diff)
library_bgp_speaker.rst: make an example more complete
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>
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/library_bgp_speaker.rst18
1 files changed, 15 insertions, 3 deletions
diff --git a/doc/source/library_bgp_speaker.rst b/doc/source/library_bgp_speaker.rst
index 443242cf..a03c91b5 100644
--- a/doc/source/library_bgp_speaker.rst
+++ b/doc/source/library_bgp_speaker.rst
@@ -20,8 +20,20 @@ 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
@@ -29,9 +41,9 @@ instance advertizes some prefixes.
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)