Hi. I found the solution. In this case, I need to use this declaration
"_EVENTS = [event_message.EventMessage]" in my classes.
Ex:
***APP 1
class ConnectionManager(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
_EVENTS = [event_message.EventMessage]
def __init__(self, *args, **kwargs):
super(ConnectionManager, self).__init__(*args, **kwargs)
***APP 2
class ManagerRole(app_manager.
RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
_EVENTS = [event_message.EventMessage]
def __init__(self, *args, **kwargs):
super(ManagerRole, self).__init__(*args, **kwargs)
Thanks.
2014-02-05 10:34 GMT-02:00 Eros Spalla <[email protected]>:
> Yamamoto, thanks for the reply.
> Sorry, but my code was a little confused. The 'else' I told before, isn't
> part of __ini__ method.
> The correction is :
>
>
> ***APP 1
>
> class ConnectionManager(app_manager.
> RyuApp):
> OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
>
> def __init__(self, *args, **kwargs):
> super(ConnectionManager, self).__init__(*args, **kwargs)
>
>
> @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
> def init_test(self, ev):
> msg = ev.msg
> datapath = msg.datapath
> dp_id = datapath.id
> if dp_id == 3:
> print dp_id
> else:
> msg = 'teste'
> self.send_event_to_observers(event_message.EventMessage(msg))
> # Here, sounds that the event wasn't sent
> print >>sys.stderr, 'O cliente caiu' # This message is
> printed in my testes
>
> I used the --verbose option, but didn't see any 'EVENT LOST'. Do you have
> any other idea?
>
> Another question. How do I use the start() hook? Can I call 'start()' to
> call a function?
>
> Thanks.
>
>
> 2014-02-05 YAMAMOTO Takashi <[email protected]>:
>
> hi,
>>
>> > Hi I am running two applications in ryu controller, and would like to
>> > exchange my own events between the two. I wrote a code (below), but the
>> > function doesn't work.
>>
>> when RyuApp's __init__ is called, event pipelines are not available yet.
>> (run ryu-manager with --verbose to see 'EVENT LOST' messages.)
>> you need to send your event later. eg. start() time.
>>
>> YAMAMOTO Takashi
>>
>> >
>> >
>> > ***Event Class - Location /ryu/app/event_message
>> >
>> > from ryu.controller import ofp_event, event
>> >
>> > class EventMessage(event.EventBase):
>> > def __init__(self, message):
>> > super(EventMessage, self).__init__()
>> > self.message = message
>> >
>> > ***App 1
>> >
>> > from ryu.base import app_manager
>> > from ryu.controller import ofp_event, event
>> > from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
>> > from ryu.controller.handler import set_ev_cls, set_ev_handler
>> > from ryu.ofproto import ofproto_v1_3
>> > from ryu.app import event_message
>> >
>> > class ConnectionManager(app_manager.RyuApp):
>> > OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
>> >
>> > def __init__(self, *args, **kwargs):
>> > super(ConnectionManager, self).__init__(*args, **kwargs)
>> > . . .
>> > bla bla bla
>> >
>> > bla bla bla
>> > . . .
>> > else: # If something doesn't happen, a want to send a event
>> > print >>sys.stderr, 'O cliente caiu'
>> > msg = 'test'
>> >
>> self.send_event_to_observers(event_message.EventMessage(msg))
>> >
>> > ***App 2
>> >
>> > from ryu.base import app_manager
>> > from ryu.controller import ofp_event, event
>> > from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
>> > from ryu.controller.handler import set_ev_cls, set_ev_handler
>> > from ryu.ofproto import ofproto_v1_3
>> > from ryu.app import event_message
>> >
>> > class ManagerRole(app_manager.RyuApp):
>> > OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
>> >
>> > def __init__(self, *args, **kwargs):
>> > super(ManagerRole, self).__init__(*args, **kwargs)
>> >
>> > . . .
>> > bla bla bla
>> >
>> > bla bla bla
>> > . . .
>> >
>> > @set_ev_cls(event_message.EventMessage) # At this point, a message
>> > 'test' should be printed
>> > def event_Test(self, ev):
>> > print ev.message
>> >
>> >
>> > I don't know what is happening. If someone can help me, I'll be
>> grateful.
>> >
>> > Thanks.
>> >
>> > --
>> > *Eros S. Spalla* -
>>
>
>
>
> --
> *Eros S. Spalla* -
>
>
>
--
*Eros S. Spalla* -
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel