Ryuのソースコードリーディング その6 Hello worldアプリケーションの作成
OpenflowのHelloメッセージを受信したら、画面にHello worldと出力するだけのもっとも単純なアプリケーションです。
from ryu.base import app_manager from ryu.controller import ofp_event from ryu.controller.handler import MAIN_DISPATCHER from ryu.controller.handler import set_ev_cls class Hello_world(app_manager.RyuApp): def __init__(self, *args, **kwargs): super(Hello_world, self).__init__(*args, **kwargs) @set_ev_cls(ofp_event.EventOFPEchoRequest, MAIN_DISPATCHER) def hello_handler(self): self.logger.info('Hello world.')
実効結果
# ryu-manager hello_world.py
loading app hello_world.py
loading app ryu.controller.ofp_handler
instantiating app hello_world.py of Hello_world
instantiating app ryu.controller.ofp_handler of OFPHandler
Hello world.
Hello world.
Hello world.