VOL-2474 Implement Alarm Simulation in bbsim and bbsimctl;
Release 0.0.12
Change-Id: I65e51729d4fdfd1daf386b1ea1732ff40bf31db7
diff --git a/internal/bbsim/devices/olt.go b/internal/bbsim/devices/olt.go
index b16e405..e5ed6bc 100644
--- a/internal/bbsim/devices/olt.go
+++ b/internal/bbsim/devices/olt.go
@@ -411,6 +411,18 @@
return nil, errors.New(fmt.Sprintf("Cannot find NniPort with id %d in OLT %d", id, o.ID))
}
+func (o *OltDevice) sendAlarmIndication(alarmInd *openolt.AlarmIndication, stream openolt.Openolt_EnableIndicationServer) {
+ data := &openolt.Indication_AlarmInd{AlarmInd: alarmInd}
+ if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
+ oltLogger.Errorf("Failed to send Alarm Indication: %v", err)
+ return
+ }
+
+ oltLogger.WithFields(log.Fields{
+ "AlarmIndication": alarmInd,
+ }).Debug("Sent Indication_AlarmInd")
+}
+
func (o *OltDevice) sendOltIndication(msg OltIndicationMessage, stream openolt.Openolt_EnableIndicationServer) {
data := &openolt.Indication_OltInd{OltInd: &openolt.OltIndication{OperState: msg.OperState.String()}}
if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
@@ -546,6 +558,9 @@
o.OperState.Event("disable")
}
o.sendOltIndication(msg, stream)
+ case AlarmIndication:
+ alarmInd, _ := message.Data.(*openolt.AlarmIndication)
+ o.sendAlarmIndication(alarmInd, stream)
case NniIndication:
msg, _ := message.Data.(NniIndicationMessage)
o.sendNniIndication(msg, stream)
@@ -1016,3 +1031,14 @@
oltLogger.Info("received RemoveTrafficSchedulers")
return new(openolt.Empty), nil
}
+
+// assumes caller has properly formulated an openolt.AlarmIndication
+func (o OltDevice) SendAlarmIndication(context context.Context, ind *openolt.AlarmIndication) error {
+ msg := Message{
+ Type: AlarmIndication,
+ Data: ind,
+ }
+
+ o.channel <- msg
+ return nil
+}