Responses inline. On Nov 25, 2010, at 9:29 PM, K Singh wrote:
> I was adding flow removed event in the pyswitch.py file. > > def install(self): > inst.register_for_packet_in(packet_in_callback) > inst.register_for_datapath_leave(datapath_leave_callback) > inst.register_for_datapath_join(datapath_join_callback) > inst.post_callback(1, timer_callback) > inst.register_for_flow_removed(flow_removed_callback) > > Then creating a callback function as below. > > def flow_removed_callback(dpid, duration_sec, duration_nsec, idle_timeout, > packet_count, byte_count, cookie): > print "---flow removed---" > return CONTINUE > > The parameter for flow removed event have been obtained from > ~/noxcore/src/include Tangential, but is this pulled from the noxcore_old repository? That's quite old now... > where the parameters are defined as > Flow_removed_event(datapathid datapath_id_, > uint32_t duration_sec_, uint32_t duration_nsec_, > uint16_t idle_timeout_, > uint64_t packet_count_, uint64_t byte_count_, > uint64_t cookie_) > > when i run this code i get this error message: > TypeError: flow_removed_callback() takes exactly 7 arguments (1 given) > > > if I change the code in pyswitch.py for the flow removed callback function > like below > > def flow_removed_callback(packet_count): > print "---flow removed---",packet_count > return CONTINUE > > the function executes but I see this printed on the terminal > ---flow removed---<nox.coreapps.pyrt.pycomponent.pyevent; proxy of <Swig > Object of type 'pyevent *' at 0xb5118128> > which is not a correct value i think. The event handler gets called with a single argument: a Flow_removed_event object (actually a Pythonized version of one, but whatever). This object has a number of fields: datapath_id, duration_sec, duration_nsec, byte_count, etc. So what you want is something like: def flow_removed_callback (e): print "---flow removed---", e.packet_count return CONTINUE > How can i obtain the values of the listed arguments when a flow > expires/removed. Also when a flow is created in switch, is there some > identification number attached to flows? How would I know which flow expired > when flow_removed event is triggered as I cannot see any flow identification > number. This would be essential if I would be dealing with multiple flow. So the Flow_removed_event has a .flow field which describes the flow (the match parameters). Is that good enough? Each flow does have an opaque "cookie" associated with it. The controller can specify this when it sets up the flow (you could just use a counter for it if you wanted a unique "identification number"), and the same cookie shows up in the flow removed event, which would let you associate it with something specific. Unfortunately, while the cookie is on the flow removed event, I don't think the functionality to SET it has been exposed to Python at this point, though it shouldn't be too hard to add in (or you could use pyopenflow to build a message with the cookie from scratch). I'm curious whether you really need it, though. What do you want to use it for? > > > -- > Regards, > Kavitesh Singh. -- Murphy _______________________________________________ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org