Merge "[VOL-3286] Sending PortStats only when OLT Enabled"
diff --git a/internal/bbsim/devices/olt.go b/internal/bbsim/devices/olt.go
index dbc226e..e0d1556 100644
--- a/internal/bbsim/devices/olt.go
+++ b/internal/bbsim/devices/olt.go
@@ -619,18 +619,20 @@
 }
 
 func (o *OltDevice) sendPortStatsIndication(stats *openolt.PortStatistics, portID uint32, portType string) {
-	oltLogger.WithFields(log.Fields{
-		"Type":   portType,
-		"IntfId": portID,
-	}).Trace("Sending port stats")
-	stats.IntfId = InterfaceIDToPortNo(portID, portType)
-	data := &openolt.Indication_PortStats{
-		PortStats: stats,
-	}
-	stream := *o.OpenoltStream
-	if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
-		oltLogger.Errorf("Failed to send PortStats: %v", err)
-		return
+	if o.InternalState.Current() == "enabled" {
+		oltLogger.WithFields(log.Fields{
+			"Type":   portType,
+			"IntfId": portID,
+		}).Trace("Sending port stats")
+		stats.IntfId = InterfaceIDToPortNo(portID, portType)
+		data := &openolt.Indication_PortStats{
+			PortStats: stats,
+		}
+		stream := *o.OpenoltStream
+		if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
+			oltLogger.Errorf("Failed to send PortStats: %v", err)
+			return
+		}
 	}
 }
 
@@ -1079,8 +1081,8 @@
 func (o OltDevice) FlowRemove(_ context.Context, flow *openolt.Flow) (*openolt.Empty, error) {
 
 	oltLogger.WithFields(log.Fields{
-		"FlowId":           flow.FlowId,
-		"FlowType":         flow.FlowType,
+		"FlowId":   flow.FlowId,
+		"FlowType": flow.FlowType,
 	}).Debug("OLT receives FlowRemove")
 
 	if !o.enablePerf { // remove only if flow were stored
@@ -1139,7 +1141,7 @@
 		msg := Message{
 			Type: FlowRemoved,
 			Data: OnuFlowUpdateMessage{
-				Flow:      flow,
+				Flow: flow,
 			},
 		}
 		onu.Channel <- msg