It Seems good! I will try. But finally, I build a lower app to produce data, 
and use it by using CONTEXT.
Second, API is also a good way which can also return the data of instance, but 
it is a little bit difficult to develop.


Thank you very much! Are you a official developer of Ryu ? You are excellent!


------------------
Distance ????
_____________________________________________________
School of Information and Communication Engineering
Beijing University of Posts and Telecommunications
Beijing 100876, PR China

??????????????????????????????????????????
_____________________________________________________
Mobile Phone: 
(+86) 151-1698-3550 Beijing 
E-mail:
[email protected]
[email protected]
Homepage:
http://www.muzixing.com





 




------------------ ???????? ------------------
??????: "Yusuke Iwase";<[email protected]>;
????????: 2015??8??27??(??????) ????10:21
??????: "muzixing.com"<[email protected]>; 
????: "ryu-devel"<[email protected]>; 
????: Re: [Ryu-devel] How to get data from other module.



Hi,

On 2015??08??26?? 12:41, muzixing.com wrote:
> Hi, all.
>      If I want to get some data from other module of app, what should I do?
> 
>      I know we can use CONTEXT to get the app as a service, and then we can 
> get the data in that app. But, the logic of these two app is not about 
> producer and consumer.
>      The second method to get this data is using API. So, I have to build 
> some API just like topology' API. However , I notice that Switches in 
> topology just return the new data, if I want to write something into that 
> data, it won't change the real data.
>      Obviously, use import just can get the static defined data of using 
> methods, we can't get the data of an alive object.
> 
>      So, what I need is a method to share the data between tow apps. 

How about using app_manager.lookup_service_brick('Name of your RyuApp') method?
You can get a RyuApp instance by the name of your RyuApp.

e.g.)
$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 3e7c598..a0c69a8 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -32,6 +32,8 @@ class SimpleSwitch13(app_manager.RyuApp):
 
     @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
     def switch_features_handler(self, ev):
+        ofctl_rest_RyuApp = app_manager.lookup_service_brick('RestStatsApi')
+        self.logger.info('ofctl_rest=%s', ofctl_rest_RyuApp)
         datapath = ev.msg.datapath
         ofproto = datapath.ofproto
         parser = datapath.ofproto_parser
$ 
$ ryu-manager ryu.app.ofctl_rest ryu.app.simple_switch_13
loading app ryu.app.ofctl_rest
loading app ryu.app.simple_switch_13
loading app ryu.controller.ofp_handler
instantiating app None of DPSet
creating context dpset
creating context wsgi
instantiating app ryu.app.ofctl_rest of RestStatsApi
instantiating app ryu.app.simple_switch_13 of SimpleSwitch13
instantiating app ryu.controller.ofp_handler of OFPHandler
(6472) wsgi starting up on http://0.0.0.0:8080/
ofctl_rest=<ryu.app.ofctl_rest.RestStatsApi object at 0x7fe164a34d50>

Please comfirm that RyuApp is already instantiated when you call 
lookup_service_brick() method.

Thanks,
Iwase

>      
>      Thank you for your time.
> ------------------
> Distance ????
> 
> _____________________________________________________
> School of Information and Communication Engineering
> Beijing University of Posts and Telecommunications
> Beijing 100876, PR China
> 
> ??????????????????????????????????????????
> _____________________________________________________
> Mobile Phone: 
> (+86) 151-1698-3550 Beijing 
> E-mail:
> [email protected]
> [email protected]
> Homepage:
> http://www.muzixing.com
> 
>  
> 
> 
> ------------------------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to