Thread: [Ryu-devel] How to get data from other module.
Brought to you by:
nz_gizmoguy
|
From: muzixing.c. <151...@qq...> - 2015-08-26 03:42:26
|
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.
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:
350...@qq...
lic...@gm...
Homepage:
http://www.muzixing.com |
|
From: Yusuke I. <iwa...@gm...> - 2015-08-27 02:21:27
|
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: > 350...@qq... > lic...@gm... > Homepage: > http://www.muzixing.com > > > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > Ryu-devel mailing list > Ryu...@li... > https://lists.sourceforge.net/lists/listinfo/ryu-devel > |
|
From: muzixing.c. <151...@qq...> - 2015-08-27 07:46:28
|
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: 350...@qq... lic...@gm... Homepage: http://www.muzixing.com ------------------ 原始邮件 ------------------ 发件人: "Yusuke Iwase";<iwa...@gm...>; 发送时间: 2015年8月27日(星期四) 上午10:21 收件人: "muzixing.com"<151...@qq...>; 抄送: "ryu-devel"<ryu...@li...>; 主题: 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: > 350...@qq... > lic...@gm... > Homepage: > http://www.muzixing.com > > > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > Ryu-devel mailing list > Ryu...@li... > https://lists.sourceforge.net/lists/listinfo/ryu-devel > ------------------------------------------------------------------------------ _______________________________________________ Ryu-devel mailing list Ryu...@li... https://lists.sourceforge.net/lists/listinfo/ryu-devel |