Skip to content

Commit

Permalink
Handle device updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adibrastegarnia committed Sep 2, 2020
1 parent 448c047 commit 4ff9cbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion pkg/southbound/synchronizer/deviceUpdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func (s *Session) updateDevice(id topodevice.ID, connectivity topodevice.Connect
log.Info("Update device state")

topoDevice, err := s.deviceStore.Get(id)

st, ok := status.FromError(err)

// If the device doesn't exist then we should not update its state
Expand Down
17 changes: 17 additions & 0 deletions pkg/southbound/synchronizer/sessionManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ func (sm *SessionManager) processDeviceEvent(event *topodevice.ListResponse) err
return err
}
case topodevice.ListResponse_UPDATED:
session, ok := sm.sessions[event.Device.ID]
if !ok {
log.Error("Session for the device %v does not exist", event.Device.ID)
return nil
}
// If the address is changed, delete the current session and creates new one
if session.device.Address != event.Device.Address {
err := sm.deleteSession(event.Device)
if err != nil {
return err
}
err = sm.createSession(event.Device)
if err != nil {
return err
}
}

log.Info("Process device event updated")

case topodevice.ListResponse_REMOVED:
Expand Down

0 comments on commit 4ff9cbf

Please sign in to comment.