streamline getting ONU/PON status from change-id I5fb4cd9246b2ed29a5384579203ebc2d96e506a9
Change-Id: I6374156134a816c88c8877624450a13ccd3092fe
diff --git a/core/grpc_service.go b/core/grpc_service.go
index a225fd9..d9b3613 100644
--- a/core/grpc_service.go
+++ b/core/grpc_service.go
@@ -159,22 +159,19 @@
return new(openolt.Empty), nil
}
-func (s *Server) GetOnuInfo(c context.Context, onu *openolt.Onu) (*openolt.OnuIndication, error){
+func (s *Server) GetOnuInfo(c context.Context, onu *openolt.Onu) (*openolt.OnuIndication, error) {
logger.Debug("Olt receives GetOnuInfo() intfID: %d, onuID: %d", onu.IntfId, onu.OnuId)
-
- if onu.IntfId > (s.Olt.NumPonIntf-1){
- logger.Error("PON ID %d out of bounds. %d ports total", onu.IntfId, s.Olt.NumPonIntf)
- return nil, status.Errorf(codes.OutOfRange, "PON ID %d out of bounds. %d ports total (indexing starts at 0)", onu.IntfId, s.Olt.NumPonIntf)
- } else if nonus:=len(s.Onumap[onu.IntfId]); int(onu.OnuId) > nonus-1{
- logger.Error("ONU ID %d out of bounds. %d onus total", onu.OnuId, s.Olt.NumPonIntf)
- return nil, status.Errorf(codes.OutOfRange, "ONU ID %d out of bounds. %d ONUs total (indexing starts at 0)", onu.OnuId, nonus)
- } else{
- stat := new(openolt.OnuIndication)
- stat.IntfId = onu.IntfId
- stat.OnuId = onu.OnuId
- stat.OperState = "up"
- return stat, nil
+ Onu, err := s.GetOnuByID(onu.OnuId, onu.IntfId)
+ if err != nil {
+ logger.Error("ONU not found intfID %d, onuID %d", onu.IntfId, onu.OnuId)
+ return new(openolt.OnuIndication), err
}
+ onuIndication := new(openolt.OnuIndication)
+ onuIndication.IntfId = Onu.IntfID
+ onuIndication.OnuId = Onu.OnuID
+ onuIndication.OperState = Onu.OperState
+
+ return onuIndication, nil
}
// OmciMsgOut receives OMCI messages from voltha
@@ -336,18 +333,18 @@
return new(openolt.Empty), nil
}
-func (s *Server) GetPonIf(c context.Context, intf *openolt.Interface) (*openolt.IntfIndication, error){
+func (s *Server) GetPonIf(c context.Context, intf *openolt.Interface) (*openolt.IntfIndication, error) {
logger.Debug("OLT %d receives GetPonIf().", s.Olt.ID)
- stat:=new(openolt.IntfIndication)
+ stat := new(openolt.IntfIndication)
- if intf.IntfId > (s.Olt.NumPonIntf-1){
+ if intf.IntfId > (s.Olt.NumPonIntf - 1) {
logger.Error("PON ID %d out of bounds. %d ports total", intf.IntfId, s.Olt.NumPonIntf)
return stat, status.Errorf(codes.OutOfRange, "PON ID %d out of bounds. %d ports total (indexing starts at 0)", intf.IntfId, s.Olt.NumPonIntf)
- } else{
- stat.IntfId = intf.IntfId
- stat.OperState = "up"
- return stat, nil
}
+ stat.IntfId = intf.IntfId
+ stat.OperState = s.Olt.PonIntfs[intf.IntfId].OperState
+ return stat, nil
+
}
func (s *Server) DisablePonIf(c context.Context, intf *openolt.Interface) (*openolt.Empty, error) {