Hi folks,
I noticed that the change of state of the ports by EventOFPPortStatus are
not reflected in Datapath object. Please refer to the attachment of the
script. For example, the following is the result of running the script.
----------8<----------8<----------
...(snip)...
EVENT switches->PortStatusMessageSample EventSwitchEnter
DPID: 1 Ports: [1, 2, 4294967294]
EVENT ofp_event->switches EventOFPPortStatus
EVENT ofp_event->PortStatusMessageSample EventOFPPortStatus
OFPPortStatus received: reason=DELETE
desc=OFPPort(port_no=1,hw_addr='fe:73:14:ee:bf:aa',name='s1-eth1',config=0,state=0,curr=2112,advertised=0,supported=0,peer=0,curr_speed=10000000,max_speed=0)
DPID: 1 Ports: [1, 2, 4294967294]
----------8<----------8<----------
The port 1 has been deleted but do not removed from Datapath object. Is
this correct behavior? We should manage the ports in user applications?
IMHO, I think that it is useful if ryu handles. Please give your opinion.
Thanks,
Satoshi
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from ryu.cmd import manager
from ryu.base import app_manager
from ryu.ofproto import ofproto_v1_3
from ryu.controller.handler import set_ev_cls
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller import ofp_event
from ryu.topology import switches
from ryu.topology import event
class PortStatusMessageSample(app_manager.RyuApp):
OFP_VERSIONS = [
ofproto_v1_3.OFP_VERSION,
]
_CONTEXTS = {
'switches': switches.Switches,
}
def _log_port_info(self, dp):
msg = 'DPID: {0} Ports: {1}'.format(dp.id, dp.ports.keys())
self.logger.info(msg)
@set_ev_cls(event.EventSwitchEnter)
def switch_enter_handler(self, ev):
dp = ev.switch.dp
self._log_port_info(dp)
@set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
def port_status_handler(self, ev):
msg = ev.msg
dp = msg.datapath
ofp = dp.ofproto
if msg.reason == ofp.OFPPR_ADD:
reason = 'ADD'
elif msg.reason == ofp.OFPPR_DELETE:
del dp.ports[msg.desc.port_no]
reason = 'DELETE'
elif msg.reason == ofp.OFPPR_MODIFY:
reason = 'MODIFY'
else:
reason = 'unknown'
self.logger.info('OFPPortStatus received: reason=%s desc=%s',
reason, msg.desc)
self._log_port_info(dp)
def main():
sys.argv.append(__name__)
sys.argv.append('--verbose')
sys.argv.append('--enable-debugger')
manager.main()
if __name__ == '__main__':
main()
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel