[VOL-3311] Fix for ONU Delete and Re-Discovery
Change-Id: Ia5ae24a68889c9b160b55ad4af28667390cfa11c
diff --git a/internal/bbsim/devices/onu.go b/internal/bbsim/devices/onu.go
index a21d96a..beb3779 100644
--- a/internal/bbsim/devices/onu.go
+++ b/internal/bbsim/devices/onu.go
@@ -245,8 +245,12 @@
},
}
o.Channel <- msg
+
+ // verify all the flows removes are handled and
// terminate the ONU's ProcessOnuMessages Go routine
- close(o.Channel)
+ if len(o.FlowIds) == 0 {
+ close(o.Channel)
+ }
},
"before_start_auth": func(e *fsm.Event) {
if o.EapolFlowReceived == false {
@@ -896,6 +900,12 @@
// so that we can properly set these two flag when the flow is removed
o.EapolFlowReceived = false
o.DhcpFlowReceived = false
+
+ // check if ONU delete is performed and
+ // terminate the ONU's ProcessOnuMessages Go routine
+ if o.InternalState.Current() == "disabled" {
+ close(o.Channel)
+ }
}
}
@@ -1120,3 +1130,31 @@
}
}
}
+
+func (onu *Onu) ReDiscoverOnu() {
+ // Wait for few seconds to be sure of the cleanup
+ time.Sleep(5 * time.Second)
+
+ onuLogger.WithFields(log.Fields{
+ "IntfId": onu.PonPortID,
+ "OnuId": onu.ID,
+ "OnuSn": onu.Sn(),
+ }).Debug("Send ONU Re-Discovery")
+
+ // ONU Re-Discovery
+ if err := onu.InternalState.Event("initialize"); err != nil {
+ log.WithFields(log.Fields{
+ "IntfId": onu.PonPortID,
+ "OnuSn": onu.Sn(),
+ "OnuId": onu.ID,
+ }).Infof("Failed to transition ONU to initialized state: %s", err.Error())
+ }
+
+ if err := onu.InternalState.Event("discover"); err != nil {
+ log.WithFields(log.Fields{
+ "IntfId": onu.PonPortID,
+ "OnuSn": onu.Sn(),
+ "OnuId": onu.ID,
+ }).Infof("Failed to transition ONU to discovered state: %s", err.Error())
+ }
+}