On Jun 25, 2013, at 3:28 PM, nibble nibble wrote:

> Hi,
> 
> I want to send a message from Pox controller to all the switches and ask them 
> to send back their flow table's Statics. I found a script to do it.
> 
> from pox.core import core
> 
> #from pox.lib.util import dpid_to_str
>  
> log = core.getLogger()
>  
> class MyComponent (object):
>   def __init__ (self):
>     core.openflow.addListeners(self)
>  
>   def _handle_ConnectionUp (self, event):
>     log.debug("Switch %s has come up.", dpid_to_str(event.dpid))
>  
> def launch ():
>   core.registerNew(MyComponent)
> #  core.registerNew(openlow_connections)

What's the point of the MyComponent class here?  It doesn't do anything but 
print out when switches connect (which the OpenFlow component already does).

> launch()

You shouldn't call launch() directly.  It will be called automatically when POX 
loads the component.

> # Listen for flow stats
> core.openflow.addListenerByName("FlowStatsReceived", handle_flow_stats)
>  
> # Now actually request flow stats from all switches
> core.registerNew(core.openflow._connections.values())
> for con in core.openflow._connections.keys(): # make this _connections.keys() 
> for pre-betta
>     con.send(of.ofp_stats_request(body=of.ofp_flow_stats_request()))

The example you found from the POX manual wiki is for running at the 
interactive prompt (with the "py" component), not for direct inclusion in a 
component.  The way you have it here will try to execute it when the module is 
loaded.  Even if this worked (which I won't swear to), it would be useless 
because no switches will have connected yet.  When do you want to query 
switches?  When they connect?  Every few seconds?  At some other time?  You 
need to figure that out and run this code at the correct time (e.g., in 
response to some event).

> But I am getting the following error:
> 
> core.registerNew(core.openflow._connections.values())

It appears you or someone else added this line to the example code from the 
wiki.  It's causing an exception because it doesn't make any sense.  
core.registerNew() creates a new instance of a class and registers it on core.  
core.openflow._connections.values() isn't a class, and you wouldn't want to 
register it on core.


Try looking at the "Statistics Collector Example" on the POX wiki in the 
"Third-Party" section.  It queries connected switches every few seconds.

-- Murphy

Reply via email to