Hi,
I am trying to combine a ryu app that detects topology with my python
program that calculate Dijkstra.
But I can’t pass correct value to my python program from ryu app
because I don’t know exactly how
@handler.set_ev_cls(event.EventLinkAdd) handler works.
***My Ryu app that detects topology is following:***
from ryu.controller import handler
from ryu.controller import dpset
from ryu.controller import ofp_event
from ryu.ofproto import ofproto_v1_3
from ryu.ofproto import ofproto_v1_3_parser
from ryu.base import app_manager
from ryu.ofproto.ofproto_parser import MsgBase, msg_pack_into, msg_str_attr
from ryu.topology import api
from ryu.topology import event
class OF13(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
_CONTEXTS = {
'dpset': dpset.DPSet,
}
def __init__(self, *args, **kwargs):
super(OF13, self).__init__(*args, **kwargs)
self.dpset = kwargs['dpset']
def _get_hwaddr(self, dpid, port_no):
return self.dpset.get_port(dpid, port_no).hw_addr
@handler.set_ev_cls(event.EventLinkAdd)
def link_add(self, ev):
srcid, dstid = ev.link.src.dpid, ev.link.dst.dpid
srcpt, dstpt = ev.link.src.port_no, ev.link.dst.port_no
print srcid, srcpt, dstid, dstpt
#####I would like to pass these four values to my python program.
#####but this part below doesn’t work correctly.
f = open(‘topology.txt’, ‘w’)
print >> f, srcid, srcpt, dstid, dstpt
f.close()
***The result output:***
loading app /home/haruka/ryu/ryu/app/topo_detect.py
loading app ryu.topology.switches
loading app ryu.controller.ofp_handler
instantiating app None of DPSet
creating context dpset
instantiating app ryu.topology.switches of Switches
instantiating app /home/haruka/ryu/ryu/app/topo_detect.py of OF13
instantiating app ryu.controller.ofp_handler of OFPHandler
4 3 3 3
2 2 3 2
1 2 3 1
2 3 4 2
1 3 4 1
4 1 1 3
2 1 1 1
4 2 2 3
1 1 2 1
3 3 4 3
3 1 1 2
3 2 2 2
***topology.txt:***
4 1 1 3
#####This value changes every time I run the program above.
I would like to ask the following questions:
●Why does “print srcid, srcpt, dstid, dstpt” part output multiple
lines without the if statement nor the while statement?
●Where should I refer to see the contents of the event handler such as
event.EventLinkAdd?
●In the first place, can Ryu Apps transfer values to other python
program inside Ryu?
Better idea, Any suggestion will be helpful.
thanks,
------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel