View status of individual ONUs using PON interface and ONU IDs
Change-Id: I5fb4cd9246b2ed29a5384579203ebc2d96e506a9
diff --git a/core/core_server.go b/core/core_server.go
index 69c0bc8..af699e1 100644
--- a/core/core_server.go
+++ b/core/core_server.go
@@ -107,6 +107,7 @@
FlowDirection string
}
+//Has options (OLT id, number onu ports) from mediator
// NewCore initialize OLT and ONU objects
func NewCore(opt *option) *Server {
// TODO: make it decent
diff --git a/core/grpc_service.go b/core/grpc_service.go
index 38f9539..a225fd9 100644
--- a/core/grpc_service.go
+++ b/core/grpc_service.go
@@ -159,6 +159,24 @@
return new(openolt.Empty), nil
}
+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
+ }
+}
+
// OmciMsgOut receives OMCI messages from voltha
func (s *Server) OmciMsgOut(c context.Context, msg *openolt.OmciMsg) (*openolt.Empty, error) {
logger.Debug("OLT %d receives OmciMsgOut to IF %v (ONU-ID: %v) pkt:%x.", s.Olt.ID, msg.IntfId, msg.OnuId, msg.Pkt)
@@ -320,7 +338,7 @@
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){
logger.Error("PON ID %d out of bounds. %d ports total", intf.IntfId, s.Olt.NumPonIntf)