It looks like you're never actually calling your send_flow_stats_request() 
method.  I'd suggest you add a timer (with post_callback()) to actually invoke 
send_flow_stats_request() periodically.

Also, since you've got your own code for sending requests and answering 
replies, I'm not sure why you're referencing the monitoring component -- I'd 
remove all mention of it from your application (because without looking back at 
the code, I can't remember for sure that it doesn't eat the stats events or 
something else that would get in your way).

-- Murphy
 
On Apr 7, 2013, at 3:31 PM, udita gangwal wrote:

> Yea, did that. and that error is no more showing up. There is no error now, 
> but still I do not get any stats reply from the switch, I have no idea why. 
> Do you see some error in the code? I guess the stats_request itself isn't 
> going till the switch, but dont know why. 
> 
> The modified code is now:
> 
> from nox.lib.core import *
> import nox.lib.pyopenflow as of
> from nox.netapps.monitoring.monitoring import Monitoring
> from twisted.python import log
> import logging
> 
> log = logging.getLogger('nox.coreapps.examples.mymonitor')
> 
> #global mymonitor instance
> #inst=None
> 
> 
> 
> 
> #for handling the flow stats in
> def flow_stats_in_handler(dpid, flows, more, xid):
>     print "---------Flow stats report----------"
>     print str(dpid)+" "+str(flows)
>     for i in flows:
>         print flows[i]
> 
> 
> 
> class MyMonitor(Component):
> 
>     def __init__(self, ctxt):
>         #global inst
>         Component.__init__(self, ctxt)
>         self.ctxt = ctxt
>         log.info("Reached the first chkpoint.")
>         self.Monitoring = 
> ctxt.resolve("nox.netapps.monitoring.monitoring.Monitoring")
>         log.info("I have come till second chkpoint")
> 
>     def install(self):
>         log.info("inside install")
>         self.register_for_flow_stats_in(flow_stats_in_handler)
> 
>     def getInterface(self):
>         log.info("inside interface")
>         return str(MyMonitor)
> 
>     #for sending flow stats request
>     def send_flow_stats_request():
>         global xid
>         flows = of.ofp_match()
>         flows.wildcards = of.OFPFW_ALL
>         self.Monitoring.send_flow_stats_request(dpid, flows, 0xff, xid)
>         xid += 1
> 
>     
> 
> 
> def getFactory():
>     class Factory:
>         def instance(self, ctxt):
>             return MyMonitor(ctxt)
> 
>     return Factory()
> 
> 
> 
> 
> 
> 
> On Sun, Apr 7, 2013 at 11:16 PM, Murphy McCauley <[email protected]> 
> wrote:
> Try adding a getInterface method to your component.  Something like:
> def getInterface (self):
>   return str(type(self))
> 
> -- Murphy
> 
> On Apr 7, 2013, at 12:49 PM, udita gangwal wrote:
> 
>> Hello All,
>> 
>> I have wriiten a module to obtain the individual flow entries from the OVS. 
>> I run it along with the monitoring component.
>> 
>> The code in the module is as follows:
>> 
>> from nox.lib.core import *
>> import nox.lib.pyopenflow as of
>> from nox.netapps.monitoring.monitoring import Monitoring
>> from twisted.python import log
>> import logging
>> 
>> log = logging.getLogger('nox.coreapps.examples.mymonitor')
>> 
>> #global mymonitor instance
>> #inst=None
>> 
>> class MyMonitor(Component):
>> 
>>     def __init__(self, ctxt):
>>         #global inst
>>         Component.__init__(self, ctxt)
>>         self.ctxt = ctxt
>>         log.info("Reached the first chkpoint.")
>>         self.Monitoring = 
>> ctxt.resolve("nox.netapps.monitoring.monitoring.Monitoring")
>>         log.info("I have come till second chkpoint")
>> 
>>     def install(self):
>>         self.register_for_flow_stats_in(flow_stats_in_handler)
>> 
>> 
>>     #for sending flow stats request
>>     def send_flow_stats_request():
>>         global xid
>>         flows = of.ofp_match()
>>         flows.wildcards = of.OFPFW_ALL
>>         self.Monitoring.send_flow_stats_request(dpid, flows, 0xff, xid)
>>         xid += 1
>> 
>> 
>>     #for handling the flow stats in
>>     def flow_stats_in_handler(dpid, flows, more, xid):
>>         print "---------Flow stats report----------"
>>         print str(dpid)+" "+str(flows)
>>         for i in flows:
>>             print flows[i]
>> 
>> 
>> def getFactory():
>>     class Factory:
>>         def instance(self, ctxt):
>>             return MyMonitor(ctxt)
>> 
>>     return Factory()
>> 
>> 
>> 
>> 
>> I run it from the command line as follows:
>> 
>> sudo ./nox_core -v -i ptcp:6633 pyswitch monitoring mymonitor
>> 
>> 
>> 
>> And I get the following error on running it:
>> 
>> 00001|nox|INFO:Starting nox_core 
>> (/home/openflow/noxcore/build/src/.libs/lt-nox_core)
>> 00002|monitoring|INFO:Simple monitoring started!
>> 00003|monitoring|INFO:Finished configuring monitoring
>> 00004|nox.coreapps.examples.mymonitor|INFO:Reached the first chkpoint.
>> 00005|nox.coreapps.examples.mymonitor|INFO:I have come till second chkpoint
>> 00006|nox|ERR:Cannot change the state of 'mymonitor' to INSTALLED:
>> 'mymonitor' ran into an error: 
>>     cannot retrieve the Python component interface description: 
>> 
>> 
>> I have also the added the folowing entry in the meta.json file present in 
>> the coreapps/example directory:
>> 
>> {
>>         "name": "mymonitor" ,
>>         "dependencies": [
>>         "python"
>>         ],
>>         "python": "nox.coreapps.examples.mymonitor"
>>     },
>> 
>> Has something else be added here?
>> 
>> 
>> Can someone please tell me what this error is and what has to be done to 
>> solve it?
>> 
>> Many Thanks,
>> Udita
>> 
>> 
>> On Sat, Apr 6, 2013 at 9:24 PM, Murphy McCauley <[email protected]> 
>> wrote:
>> On Apr 6, 2013, at 11:13 AM, udita gangwal wrote:
>> 
>> > I want to obtain the individual flow entries from the OVS and display them 
>> > on the NOX console. How can I do this?
>> 
>> By sending a flow_stats request and handling the response.
>> 
>> > What does the monitor module do in NOX?
>> 
>> It's described (briefly) on the NOX wiki:
>> https://github.com/noxrepo/nox-classic/wiki/Monitoring
>> 
>> It periodically sends stats requests.  You can probably either use it or 
>> base your own flow stats query code on it.
>> 
>> -- Murphy
>> 
> 
> 

Reply via email to