Delete callback function to port status events

For ovsdb monitor module has already been merged, DF controller doesn't
need to responsed to the port status events. Keep remaining this callback
function will cause apps be notified duplicately local port delete event.
Besides, if a port isn't online on south, the local controller shouldn't
save this lport's information in its cache.

Change-Id: I9a2ebd0d3a751291ea4eb788b877723d44399a5a
Closes-Bug: #1580082
This commit is contained in:
yuanwei 2016-05-24 16:06:39 +08:00
parent 1ad08952cc
commit a40352ad78
3 changed files with 2 additions and 52 deletions

View File

@ -220,10 +220,10 @@ class DfLocalController(object):
'original_port': str(original_lport)})
self.open_flow_app.notify_update_local_port(lport,
original_lport)
self.db_store.set_port(lport.get_id(), lport, True)
else:
LOG.info(_LI("Local logical port %s was not created yet") %
str(lport))
self.db_store.set_port(lport.get_id(), lport, True)
else:
lport.set_external_value('is_local', False)
ofport = chassis_to_ofport.get(lport.get_chassis(), 0)
@ -240,13 +240,13 @@ class DfLocalController(object):
'original_port': str(original_lport)})
self.open_flow_app.notify_update_remote_port(
lport, original_lport)
self.db_store.set_port(lport.get_id(), lport, False)
else:
# TODO(gampel) add handling for this use case
# remote port but no tunnel to remote Host
# if this should never happen raise an exception
LOG.warning(_LW("No tunnel for remote logical port %s") %
str(lport))
self.db_store.set_port(lport.get_id(), lport, False)
def logical_port_created(self, lport):
self._logical_port_process(lport)

View File

@ -156,34 +156,6 @@ class RyuDFAdapter(OFPHandler):
req = ofp_parser.OFPPortDescStatsRequest(datapath, 0)
datapath.send_msg(req)
@set_ev_handler(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
def _port_status_handler(self, ev):
msg = ev.msg
reason = msg.reason
port_no = msg.desc.port_no
port_name = msg.desc.name
ofproto = msg.datapath.ofproto
if reason == ofproto.OFPPR_ADD:
LOG.info(_LI("port added %s"), port_no)
lport = self.db_store.get_local_port_by_name(port_name)
if lport:
lport.set_external_value('ofport', port_no)
lport.set_external_value('is_local', True)
self.notify_add_local_port(lport)
elif reason == ofproto.OFPPR_DELETE:
LOG.info(_LI("port deleted %s"), port_no)
lport = self.db_store.get_local_port_by_name(port_name)
if lport:
self.notify_remove_local_port(lport)
# Leave the last correct OF port number of this port
elif reason == ofproto.OFPPR_MODIFY:
LOG.info(_LI("port modified %s"), port_no)
# TODO(oanson) Add notification
else:
LOG.info(_LI("Illeagal port state %(port_no)s %(reason)s")
% {'port_no': port_no, 'reason': reason})
@set_ev_handler(ofp_event.EventOFPPortDescStatsReply, MAIN_DISPATCHER)
def port_desc_stats_reply_handler(self, ev):
self.dispatcher.dispatch('port_desc_stats_reply_handler', ev)

View File

@ -102,28 +102,6 @@ class TestRyuDFAdapter(tests_base.BaseTestCase):
self.mock_app.assert_has_calls([
mock.call.port_desc_stats_reply_handler(ev)])
def test_port_status_handler(self):
self.mock_app.reset_mock()
ev = mock.Mock()
ev.msg.reason = ev.msg.datapath.ofproto.OFPPR_ADD
self.ryu_df_adapter._port_status_handler(ev)
port_name = ev.msg.desc.name
lport = self.db_store.get_local_port_by_name(port_name)
self.mock_app.assert_has_calls([mock.call.add_local_port(lport=lport)])
lport.assert_has_calls([
mock.call.set_external_value('ofport', ev.msg.desc.port_no),
mock.call.set_external_value('is_local', True)])
self.mock_app.reset_mock()
ev = mock.Mock()
ev.msg.reason = ev.msg.datapath.ofproto.OFPPR_DELETE
self.ryu_df_adapter._port_status_handler(ev)
port_name = ev.msg.desc.name
lport = self.db_store.get_local_port_by_name(port_name)
self.mock_app.assert_has_calls([
mock.call.remove_local_port(lport=lport)])
#TODO(oanson) Once notification is added, add update_local_port test
def test_packet_in_handler(self):
self.mock_app.reset_mock()
ev = mock.Mock()