Hi, Ryu provides many way for such a purpose.
One is using user defined event. Please refer to the attached examples. Usage) $ sudo mn --topo single --mac --controller remote ... mininet> h1 ping h2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. >From 10.0.0.1 icmp_seq=1 Destination Host Unreachable ... $ ryu-manager ryu.app.event_sender ryu.app.event_receiver ... *** send event: event.msg = TEST EVENT *** Received event: ev.msg = TEST EVENT ... Another way is using "app_manager.lookup_service_brick('APP_NAME')" method. This method returns a RyuApp instance whose name is 'APP_NAME'. The others are to define REST API, to use the Unix domain socket and so on. Thanks, Iwase On 2015年10月13日 03:32, janael pinheiro wrote: > Hi, everyone. > > I need to get the value of a variable of a running application. The value of > this variable will be used by another application. How can I get variable > values belonging to other applications? > > -- > Antonio Janael Pinheiro > MSc. Candidate in Computer Science at CIn/UFPE > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > Ryu-devel mailing list > Ryu-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ryu-devel >
# Copyright (C) 2015 Nippon Telegraph and Telephone Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. from ryu.app import event_sender from ryu.base import app_manager from ryu.controller.handler import set_ev_cls class EventReceiver(app_manager.RyuApp): def __init__(self, *args, **kwargs): super(EventReceiver, self).__init__(*args, **kwargs) @set_ev_cls(event_sender.TestEvent) def _test_event_handler(self, ev): self.logger.info('*** Received event: ev.msg = %s', ev.msg)
# Copyright (C) 2015 Nippon Telegraph and Telephone Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. from ryu.base import app_manager from ryu.controller import event from ryu.controller import ofp_event from ryu.controller.handler import MAIN_DISPATCHER, CONFIG_DISPATCHER from ryu.controller.handler import set_ev_cls class TestEvent(event.EventBase): def __init__(self, msg): super(TestEvent, self).__init__() self.msg = msg class EventSender(app_manager.RyuApp): _EVENTS = [TestEvent] def __init__(self, *args, **kwargs): super(EventSender, self).__init__(*args, **kwargs) self.mac_to_port = {} @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) def switch_features_handler(self, ev): datapath = ev.msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser match = parser.OFPMatch() actions = [parser.OFPActionOutput( ofproto.OFPP_CONTROLLER, ofproto.OFPCML_NO_BUFFER)] inst = [parser.OFPInstructionActions( ofproto.OFPIT_APPLY_ACTIONS, actions)] mod = parser.OFPFlowMod(datapath, match=match, instructions=inst) datapath.send_msg(mod) @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) def _packet_in_handler(self, ev): event = TestEvent('TEST EVENT') self.logger.info('*** send event: event.msg = %s', event.msg) self.send_event_to_observers(TestEvent('TEST EVENT'))
------------------------------------------------------------------------------
_______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel