Cleaning up the ONU state when disabling the device
Change-Id: Ie88f58b52a5ea27409c1be0f64fc99a0551b0f7b
diff --git a/internal/bbsim/devices/onu.go b/internal/bbsim/devices/onu.go
index f385a45..a62d240 100644
--- a/internal/bbsim/devices/onu.go
+++ b/internal/bbsim/devices/onu.go
@@ -64,7 +64,7 @@
// ONU State
// PortNo comes with flows and it's used when sending packetIndications,
// There is one PortNo per UNI Port, for now we're only storing the first one
- // FIXME add support for multiple UNIs
+ // FIXME add support for multiple UNIs (each UNI has a different PortNo)
PortNo uint32
DhcpFlowReceived bool
Flows []FlowKey
@@ -199,6 +199,13 @@
o.Channel <- msg
},
"enter_disabled": func(event *fsm.Event) {
+
+ // clean the ONU state
+ o.DhcpFlowReceived = false
+ o.PortNo = 0
+ o.Flows = []FlowKey{}
+
+ // set the OpenState to disabled
if err := o.OperState.Event("disable"); err != nil {
onuLogger.WithFields(log.Fields{
"OnuId": o.ID,
@@ -206,6 +213,8 @@
"OnuSn": o.Sn(),
}).Errorf("Cannot change ONU OperState to down: %s", err.Error())
}
+
+ // send the OnuIndication DOWN event
msg := Message{
Type: OnuIndication,
Data: OnuIndicationMessage{