Hi all,
I have tried simple_switch.py given in ryu and I was able to run it without
any error..
Then I wrote a program to add flows when a switch comes up and I saved it
in the ryu/app directory. My file name is "test.py"..
When I try to start the ryu-manager, I get following error,
u99319@ws116615-ubuntu:~/ryu$ ryu-manager ryu.app.test
loading app ryu.app.test
Traceback (most recent call last):
File "/usr/local/bin/ryu-manager", line 9, in <module>
load_entry_point('ryu==3.3', 'console_scripts', 'ryu-manager')()
File "/usr/local/lib/python2.7/dist-packages/ryu/cmd/manager.py", line
67, in main
app_mgr.load_apps(app_lists)
File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py",
line 170, in load_apps
cls = self.load_app(app_cls_name)
File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py",
line 154, in load_app
mod = utils.import_module(name)
File "/usr/local/lib/python2.7/dist-packages/ryu/utils.py", line 86, in
import_module
__import__(name)
ImportError: No module named test
-------------------------------------------------------------------------------------
Here is my code
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.topology import switches
from ryu.topology.event import EventSwitchEnter, EventSwitchLeave
class SwitchEventApp(app_manager.RyuApp):
_CONTEXTS = {'switches': switches.Switches,}
def __init__(self, *args, **kwargs):
super(SwitchEventApp, self).__init__(*args, **kwargs)
@set_ev_cls(EventSwitchEnter)
def _ev_switch_enter_handler(self, ev):
print('enter: %s' % ev)
datapath = ev.msg.dp
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
actions =
[parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,ofproto.OFPCML_NO_BUFFER)]
self.add_flow(datapath, "2","00:00:00:00:00:03", actions)
def add_flow(self, datapath, in_port, dst, actions):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
match = parser.OFPMatch(in_port=in_port, dl_dst=haddr_to_bin(dst))
inst =
[parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,actions)]
mod = parser.OFPFlowMod(datapath=datapath, priority=priority,match =
match, instructions=inst)
datapath.send_msg(mod)
Best Regards,
Windhya Rankothge,
Universitat Pompeu Fabra,
Barcelona.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel