Hi,Minoru, It perfectly works!
Thank you very much. Weiyang ________________________________________ From: Minoru TAKAHASHI [[email protected]] Sent: Thursday, November 27, 2014 12:32 AM To: Weiyang Mo Cc: [email protected] Subject: Re: [Ryu-devel] Send msg to a specific dpid? Hi, I think, it seems can be realized by "ofp_event.EventOFPStateChange". I've done a quick & dirty hack for this purpose.I hope this will help. sw_register.py --------------------------------- from ryu.base import app_manager from ryu.controller import ofp_event from ryu.controller import handler from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER from ryu.controller.handler import set_ev_cls from ryu.ofproto import ofproto_v1_3 from ryu.lib import dpid as dpid_lib class Register(app_manager.RyuApp): def __init__(self): super(Register, self).__init__() self.sw_list = {} @set_ev_cls(ofp_event.EventOFPStateChange, [handler.MAIN_DISPATCHER, handler.DEAD_DISPATCHER]) def dispacher_change(self, ev): assert ev.datapath is not None dp = ev.datapath if ev.state == handler.MAIN_DISPATCHER: self.sw_list[dp.id] = dp msg = 'Join SW.' elif ev.state == handler.DEAD_DISPATCHER: ret = self.sw_list.pop(dp.id, None) if ret is None: msg = 'Leave unknown SW.' else: msg = 'Leave SW.' self.logger.info('dpid=%s : %s %s', dpid_lib.dpid_to_str(dp.id), msg, self.sw_list) --------------------------------- $ ryu-manager sw_register.py loading app sw_register.py loading app ryu.controller.ofp_handler instantiating app sw_register.py of Register instantiating app ryu.controller.ofp_handler of OFPHandler <SW startup> dpid=0000000000000002 : Join SW. {2: <ryu.controller.controller.Datapath object at 0x7f7298f2b7d0>} dpid=0000000000000001 : Join SW. {1: <ryu.controller.controller.Datapath object at 0x7f7298f2be10>, 2: <ryu.controller.controller.Datapath object at 0x7f7298f2b7d0>} <SW stopped> dpid=0000000000000002 : Leave SW. {1: <ryu.controller.controller.Datapath object at 0x7f7298f2be10>} dpid=0000000000000001 : Leave SW. {} On 2014年11月27日 15:34, Weiyang Mo wrote: > Hi > > Is there any simple way to get all the Datapath instances (e.g. a list?) that > I can send to a specific one. For example I have two switches dpid=1 and > dpid=2, I receiver packet_in from dpid=1 and wants to do something on dpid2. > > @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) > def _packet_in_handler(self, ev): > ev.msg.datapath.id == 1 True > #I want send some msg to dpid 2, How can I access dpid instance? > > Thank you very much. > > William > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Ryu-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ryu-devel > ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
