Hi,

On Thu, 9 Jan 2014 15:43:57 +0530
vinay pai <[email protected]> wrote:

> I have traditionally been using POX but now am in need of OFv1.3
> controller. However in search of a starting point im trying to write OFv1.0
> applications. Im facing some issues regarding the same.
> 
> Snippets of the code are as below:
> 
> 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_0
> from ryu.ofproto import ofproto_v1_0_parser
> from ryu.lib.packet import packet
> from ryu.lib.packet import ethernet
> 
> class SimpleSwitch10(app_manager.RyuApp):
>     OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
> 
>     def __init__(self, *args, **kwargs):
>         super(SimpleSwitch10, self).__init__(*args, **kwargs)
>         self.mac_to_port = {}
> 
>     @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
>     def switch_features_handler(self, ev):
>         datapath = ev.msg.datapath
>         ofproto = datapath.ofproto
>         parser = datapath.ofproto_parser
> 
>         match = parser.OFPMatch()
>         actions = [parser.OFPActionOutput(2)]#Just a sample port
>         self.add_flow(datapath, 0, match, actions)
> 
>     def add_flow(self, datapath, priority, match, actions):
>         ofproto = datapath.ofproto
>         parser = datapath.ofproto_parser
> 
>         inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
>                                              actions)]
>         mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
> match=match,
> instructions=inst)
>         datapath.send_msg(mod)
> 
> 
> However I get the following error:
> 
> mininet@mininet-vm:~$ ryu-manager simple_switch_10.py
> loading app simple_switch_13.py

I'm confused here. You pass 'simple_switch_10.py' but
'simple_switch_13.py' is loaded. Something wrong here.

> loading app ryu.controller.ofp_handler
> instantiating app simple_switch_13.py of SimpleSwitch13
> instantiating app ryu.controller.ofp_handler of OFPHandler
> 
> hub: uncaught exception: Traceback (most recent call last):
>   File "/usr/local/lib/python2.7/dist-packages/ryu/lib/hub.py", line 48, in
> _launch
>     func(*args, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py",
> line 142, in _event_loop
>     handler(ev)
>   File "/home/mininet/simple_switch_13.py", line 51, in
> switch_features_handler
>     self.add_flow(datapath, 0, match, actions)
>   File "/home/mininet/simple_switch_13.py", line 57, in add_flow
>     inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
> AttributeError: 'module' object has no attribute 'OFPInstructionActions'
> 
> I understand what is there error but not understand how to bypass it
> because 1.3 and 1.2 use the same module and theres not much documentation
> regarding 1.0. I might be missing something very obvious.

If you want to write the code that can handle multiple of versions,
then you need to check the of version and 'if' or something like:

https://github.com/osrg/ryu/blob/master/ryu/topology/switches.py#L540

But I would recomment you to write the code for only OF1.3 if you need
OF1.3. That's more straightforward and easier. You can find the API
doc for OF1.3:

http://ryu.readthedocs.org/en/latest/ofproto_v1_3_ref.html

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to