Skip to content

Commit bb605cd

Browse files
authored
Merge pull request kytos#657 from renanrodrigo/generate_reconn_event
Add event to notify switch reconnection
2 parents 111b377 + 0501289 commit bb605cd

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

kytos/core/controller.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,23 +461,24 @@ def get_switch_or_create(self, dpid, connection):
461461
"""
462462
self.create_or_update_connection(connection)
463463
switch = self.get_switch_by_dpid(dpid)
464-
event = None
464+
event_name = 'kytos/core.switch.'
465465

466466
if switch is None:
467467
switch = Switch(dpid=dpid)
468468
self.add_new_switch(switch)
469+
event_name += 'new'
470+
else:
471+
event_name += 'reconnected'
469472

470-
event = KytosEvent(name='kytos/core.switch.new',
471-
content={'switch': switch})
473+
event = KytosEvent(name=event_name, content={'switch': switch})
472474

473475
old_connection = switch.connection
474476
switch.update_connection(connection)
475477

476478
if old_connection is not connection:
477479
self.remove_connection(old_connection)
478480

479-
if event:
480-
self.buffers.app.put(event)
481+
self.buffers.app.put(event)
481482

482483
return switch
483484

0 commit comments

Comments
 (0)