[SEBA-818] Adding onu get command to BBSimCtl
Change-Id: I182effdd2d82e3b57d72c53c89fa978b75f16354
diff --git a/internal/bbsim/api/onus_handler.go b/internal/bbsim/api/onus_handler.go
index bd333b0..ce0dba0 100644
--- a/internal/bbsim/api/onus_handler.go
+++ b/internal/bbsim/api/onus_handler.go
@@ -49,6 +49,29 @@
return &onus, nil
}
+func (s BBSimServer) GetONU(ctx context.Context, req *bbsim.ONURequest) (*bbsim.ONU, error) {
+ olt := devices.GetOLT()
+
+ onu, err := olt.FindOnu(req.SerialNumber)
+
+ if err != nil {
+ res := bbsim.ONU{}
+ return &res, err
+ }
+
+ res := bbsim.ONU{
+ ID: int32(onu.ID),
+ SerialNumber: onu.Sn(),
+ OperState: onu.OperState.Current(),
+ InternalState: onu.InternalState.Current(),
+ PonPortID: int32(onu.PonPortID),
+ STag: int32(onu.STag),
+ CTag: int32(onu.CTag),
+ HwAddress: onu.HwAddress.String(),
+ }
+ return &res, nil
+}
+
func (s BBSimServer) ShutdownONU(ctx context.Context, req *bbsim.ONURequest) (*bbsim.Response, error) {
// NOTE this method is now sendying a Dying Gasp and then disabling the device (operState: down, adminState: up),
// is this the only way to do? Should we address other cases?