Skip to content

Commit

Permalink
Merge pull request kytos#657 from renanrodrigo/generate_reconn_event
Browse files Browse the repository at this point in the history
Add event to notify switch reconnection
  • Loading branch information
diraol authored Nov 14, 2017
2 parents 111b377 + 0501289 commit bb605cd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions kytos/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,23 +461,24 @@ def get_switch_or_create(self, dpid, connection):
"""
self.create_or_update_connection(connection)
switch = self.get_switch_by_dpid(dpid)
event = None
event_name = 'kytos/core.switch.'

if switch is None:
switch = Switch(dpid=dpid)
self.add_new_switch(switch)
event_name += 'new'
else:
event_name += 'reconnected'

event = KytosEvent(name='kytos/core.switch.new',
content={'switch': switch})
event = KytosEvent(name=event_name, content={'switch': switch})

old_connection = switch.connection
switch.update_connection(connection)

if old_connection is not connection:
self.remove_connection(old_connection)

if event:
self.buffers.app.put(event)
self.buffers.app.put(event)

return switch

Expand Down

0 comments on commit bb605cd

Please sign in to comment.