Ryu applications are basically Python modules that define a subclass of ryu.base.app_manager.RyuApp
. Two or more classes could be defined in a single module but priority is given to the first module sorted by name order and this is processed by the app manager. One instance of any Ryu application can run at a time in an environment. To run an application in the environment, you need to run the following script:
% ryu-manager MyFirstApplication.py where MyFirstApplication refers to the application name which works as a simple Layer Two switch.
The application can be found as follows:
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 MyFirstApplication(app_manager.RyuApp): def __init__(self, *args, **kwargs): super(MyFirstApplication, self).__init__(*args, **kwargs) @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)...