On Nov 6, 2013, at 11:47 AM, AMER <amer7...@hotmail.com> wrote:

> Hello,
>  
> Thank you, it is OK
> what I did:
>     from pox.openflow.of_json import *
>     core.openflow.addListeners(self)
>     core.openflow.addListenerByName("FlowStatsReceived", 
> self._handle_flowstats_received)
>     def _handle_flowstats_received (self, event)

So if you renamed the method to _handle_FlowStatsReceived, you wouldn't need 
the specific addListenerByName (the addListeners() call would take care of it).

>  Best regards,
> 
> 
> Eng Amer Alghadhban
> COE
> SANS-GCFW
> CEH, SCNP, CCNA
> 
>  
> Subject: Re: [pox-dev] Listeners in class
> From: murphy.mccau...@gmail.com
> Date: Wed, 6 Nov 2013 10:48:22 -0800
> CC: amer7...@hotmail.com; pox-dev@lists.noxrepo.org
> To: sul...@gmail.com
> 
> On Nov 6, 2013, at 9:39 AM, Sulabh Bista <sul...@gmail.com> wrote:
> 
> I don't think there are flow and port status events. I guess these are not 
> 'events' at all and you should fetch them when you require them.
> 
> There are, in fact (mentioned in the Statistics Events section of the 
> manual).  Though you may need to send requests to get them to fire. :)
> 
> On Wed, Nov 6, 2013 at 12:30 PM, Sulabh Bista <sul...@gmail.com> wrote:
> Use the event name with proper case as:
> self.addListenersByname("FlowStatsReceived", self._handle_flowstate_received)
> 
> This is good advice.  Also use the correct name, as done here (the original 
> had "flow*state*received" which I think would have raised an exception...).  
> Adding by name is sometimes convenient, but it's fairly "unstructured".  A 
> safer bet is to actually use the event class itself 
> (addListener(of.FlowStatsReceived, ...)).
> 
> But there's a bigger problem here.  Events are raised by specific objects.  
> Does "self" raise the FlowStatsReceived event?  Considering it wants to 
> *handle* that event, probably not.  (Continued below.)
> 
> On Wed, Nov 6, 2013 at 9:01 AM, Amer <amer7...@hotmail.com>wrote:
> Hello,
> 
> I would like to add listeners to flow and port status inl3.learning.py.
> There is a command
> Self.listento(core)
> 
> Sidenote: .listenTo() isn't used much anymore (the version of l3_learning in 
> dart doesn't, for example).  Use .addListenersByName().
> 
> But it is not calling flow or port status function
> 
> It wouldn't.  You're telling it to listen to events on the core object.  Take 
> a look at the events raised by the core object:
> https://github.com/noxrepo/pox/blob/carp/pox/core.py#L177
> 
> None of them have anything to do with OpenFlow.
> 
> I tried with self.addListenersByname("flowstatereceived", 
> self._handle_flowstate_received)
> and without self
> 
> But it is not work
> 
> Coming back to this, your event source here is "self", but this object 
> probably doesn't raise the flow stats event (neither does the core object as 
> mentioned just above).  POX raises OpenFlow events on the OpenFlow nexus 
> (core.openflow) and on individual Connection objects, so you need to listen 
> to those objects.  See:
> https://github.com/noxrepo/pox/blob/carp/pox/openflow/__init__.py#L306
> https://github.com/noxrepo/pox/blob/carp/pox/openflow/of_01.py#L571
> 
> You might want to skim through the "The Event System" and "OpenFlow Events" 
> section of the manual.
> 
> 
> TLDR:
> Examples...
> 
> If you want to listen to all OpenFlow events, name your methods correctly and 
> then use:
> core.openflow.addListeners(self)
> 
> If you want to listen to a specific event on a specific connection with a 
> specific method, try:
> some_connection.addListenerByName("FlowStatsReceived", 
> self._handle_flowstate_received)
> 
> Examples in code (there are many, but here are three at random):
> https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_learning.py#L182
> https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_learning.py#L86
> https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_pairs.py#L85
> 
> 
> Hope  that's helpful.
> 
> -- Murphy

Reply via email to