Move common/utils.go to device/utils.go.
The utility functions ConvB2S(), OnuToSn(), LoggerWithOnu() in common/utils.go strongly depend on ONU instance specification.
Then, I consider it should be in device package that contains ONU instance , not utils package.
Change-Id: I7fd2b21c5f7c51be8ec4a5c161da9c93e3a3f582
diff --git a/core/grpc_service.go b/core/grpc_service.go
index 2d216d8..edf7d1b 100644
--- a/core/grpc_service.go
+++ b/core/grpc_service.go
@@ -20,7 +20,6 @@
"net"
"gerrit.opencord.org/voltha-bbsim/common/logger"
- "gerrit.opencord.org/voltha-bbsim/common/utils"
"gerrit.opencord.org/voltha-bbsim/device"
flowHandler "gerrit.opencord.org/voltha-bbsim/flow"
openolt "gerrit.opencord.org/voltha-bbsim/protos"
@@ -187,12 +186,12 @@
logger.Error("Failed in OnuPacketOut, %v", err)
return new(openolt.Empty), err
}
- utils.LoggerWithOnu(onu).Debugf("OLT %d receives OnuPacketOut () to IF-ID:%d ONU-ID %d.", s.Olt.ID, packet.IntfId, packet.OnuId)
+ device.LoggerWithOnu(onu).Debugf("OLT %d receives OnuPacketOut () to IF-ID:%d ONU-ID %d.", s.Olt.ID, packet.IntfId, packet.OnuId)
onuid := packet.OnuId
intfid := packet.IntfId
rawpkt := gopacket.NewPacket(packet.Pkt, layers.LayerTypeEthernet, gopacket.Default)
if err := s.onuPacketOut(intfid, onuid, rawpkt); err != nil {
- utils.LoggerWithOnu(onu).WithField("error", err).Errorf("OnuPacketOut Error ")
+ device.LoggerWithOnu(onu).WithField("error", err).Errorf("OnuPacketOut Error ")
return new(openolt.Empty), err
}
return new(openolt.Empty), nil
@@ -234,7 +233,7 @@
if err == nil {
onu.GemportID = uint16(flow.GemportId)
- utils.LoggerWithOnu(onu).WithFields(log.Fields{
+ device.LoggerWithOnu(onu).WithFields(log.Fields{
"olt": s.Olt.ID,
"c_tag": flow.Action.IVid,
}).Debug("OLT receives FlowAdd().")
@@ -293,7 +292,7 @@
} else {
// Delete flowID from onu
onu.DeleteFlowID(flow.FlowId)
- utils.LoggerWithOnu(onu).WithFields(log.Fields{
+ device.LoggerWithOnu(onu).WithFields(log.Fields{
"olt": s.Olt.ID,
"c_tag": flow.Action.IVid,
}).Debug("OLT receives FlowRemove().")