[VOL-2890] Using olt-device-id in the path of a tech-profile

Change-Id: I4b572790e8b82ef903e557dee0ddf1a21859f188
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index f019f10..7b5f2a2 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -511,7 +511,7 @@
 		}()
 	case *oop.Indication_PktInd:
 		pktInd := indication.GetPktInd()
-		logger.Infow("Received pakcet indication ", log.Fields{"PktInd": pktInd})
+		logger.Debugw("Received packet indication ", log.Fields{"PktInd": pktInd, "deviceId": dh.device.Id})
 		go func() {
 			if err := dh.handlePacketIndication(ctx, pktInd); err != nil {
 				olterrors.NewErrAdapter("handle-indication-error", log.Fields{"type": "packet"}, err).Log()
@@ -1271,7 +1271,7 @@
 			"interface-id": parentPort,
 			"onu-id":       onuID}, err)
 	}
-	logger.Debugw("Successfully received child device from core", log.Fields{"child_device": *onuDevice})
+	logger.Debugw("Successfully received child device from core", log.Fields{"child_device_id": onuDevice.Id, "child_device_sn": onuDevice.SerialNumber})
 	return onuDevice, nil
 }
 
@@ -1656,6 +1656,7 @@
 func (dh *DeviceHandler) handlePacketIndication(ctx context.Context, packetIn *oop.PacketIndication) error {
 	logger.Debugw("Received packet-in", log.Fields{
 		"packet-indication": *packetIn,
+		"device-id":         dh.device.Id,
 		"packet":            hex.EncodeToString(packetIn.Pkt),
 	})
 	logicalPortNum, err := dh.flowMgr.GetLogicalPortFromPacketIn(ctx, packetIn)
@@ -1664,16 +1665,20 @@
 	}
 	logger.Debugw("sending packet-in to core", log.Fields{
 		"logicalPortNum": logicalPortNum,
+		"device-id":      dh.device.Id,
 		"packet":         hex.EncodeToString(packetIn.Pkt),
 	})
 	if err := dh.coreProxy.SendPacketIn(context.TODO(), dh.device.Id, logicalPortNum, packetIn.Pkt); err != nil {
 		return olterrors.NewErrCommunication("send-packet-in", log.Fields{
 			"destination": "core",
 			"source":      dh.deviceType,
-			"packet":      hex.EncodeToString(packetIn.Pkt)}, err)
+			"device-id":   dh.device.Id,
+			"packet":      hex.EncodeToString(packetIn.Pkt),
+		}, err)
 	}
 	logger.Debugw("Success sending packet-in to core!", log.Fields{
-		"packet": hex.EncodeToString(packetIn.Pkt),
+		"packet":    hex.EncodeToString(packetIn.Pkt),
+		"device-id": dh.device.Id,
 	})
 	return nil
 }
@@ -1684,6 +1689,7 @@
 		"deviceID":       dh.deviceID,
 		"egress_port_no": egressPortNo,
 		"pkt-length":     len(packet.Data),
+		"device-id":      dh.device.Id,
 		"packet":         hex.EncodeToString(packet.Data),
 	})
 
@@ -1696,7 +1702,9 @@
 			// ONOS has no clue about uni/nni ports, it just packets out on all
 			// available ports on the Logical Switch. It should not be interested
 			// in the UNI links.
-			logger.Debug("dropping-lldp-packet-out-on-uni")
+			logger.Debugw("dropping-lldp-packet-out-on-uni", log.Fields{
+				"device-id": dh.device.Id,
+			})
 			return nil
 		}
 		if outerEthType == 0x88a8 || outerEthType == 0x8100 {
@@ -1704,7 +1712,10 @@
 				// q-in-q 802.1ad or 802.1q double tagged packet.
 				// slice out the outer tag.
 				packet.Data = append(packet.Data[:12], packet.Data[16:]...)
-				logger.Debugw("packet-now-single-tagged", log.Fields{"packetData": hex.EncodeToString(packet.Data)})
+				logger.Debugw("packet-now-single-tagged", log.Fields{
+					"packetData": hex.EncodeToString(packet.Data),
+					"device-id":  dh.device.Id,
+				})
 			}
 		}
 		intfID := IntfIDFromUniPortNum(uint32(egressPortNo))
@@ -1717,7 +1728,8 @@
 			// The agent tries to retrieve the gemPortID in this case.
 			// This may not always succeed at the agent and packetOut may fail.
 			logger.Errorw("failed-to-retrieve-gemport-id-for-packet-out", log.Fields{
-				"packet": hex.EncodeToString(packet.Data),
+				"packet":    hex.EncodeToString(packet.Data),
+				"device-id": dh.device.Id,
 			})
 		}
 
@@ -1730,6 +1742,7 @@
 			"uniID":          uniID,
 			"gemPortID":      gemPortID,
 			"packet":         hex.EncodeToString(packet.Data),
+			"device-id":      dh.device.Id,
 		})
 
 		if _, err := dh.Client.OnuPacketOut(ctx, &onuPkt); err != nil {
@@ -1741,28 +1754,38 @@
 				"oni-id":             onuID,
 				"uni-id":             uniID,
 				"gem-port-id":        gemPortID,
-				"packet":             hex.EncodeToString(packet.Data)}, err)
+				"packet":             hex.EncodeToString(packet.Data),
+				"device-id":          dh.device.Id,
+			}, err)
 		}
 	} else if egressPortType == voltha.Port_ETHERNET_NNI {
 		nniIntfID, err := IntfIDFromNniPortNum(uint32(egressPortNo))
 		if err != nil {
-			return olterrors.NewErrInvalidValue(log.Fields{"egress-nni-port": egressPortNo}, err)
+			return olterrors.NewErrInvalidValue(log.Fields{
+				"egress-nni-port": egressPortNo,
+				"device-id":       dh.device.Id,
+			}, err)
 		}
 		uplinkPkt := oop.UplinkPacket{IntfId: nniIntfID, Pkt: packet.Data}
 
 		logger.Debugw("sending-packet-to-nni", log.Fields{
 			"uplink_pkt": uplinkPkt,
 			"packet":     hex.EncodeToString(packet.Data),
+			"device-id":  dh.device.Id,
 		})
 
 		if _, err := dh.Client.UplinkPacketOut(ctx, &uplinkPkt); err != nil {
-			return olterrors.NewErrCommunication("packet-out-to-nni", log.Fields{"packet": hex.EncodeToString(packet.Data)}, err)
+			return olterrors.NewErrCommunication("packet-out-to-nni", log.Fields{
+				"packet":    hex.EncodeToString(packet.Data),
+				"device-id": dh.device.Id,
+			}, err)
 		}
 	} else {
 		logger.Warnw("Packet-out-to-this-interface-type-not-implemented", log.Fields{
 			"egress_port_no": egressPortNo,
 			"egressPortType": egressPortType,
 			"packet":         hex.EncodeToString(packet.Data),
+			"device-id":      dh.device.Id,
 		})
 	}
 	return nil
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index e4f3349..07469d7 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -227,7 +227,7 @@
 
 //NewFlowManager creates OpenOltFlowMgr object and initializes the parameters
 func NewFlowManager(ctx context.Context, dh *DeviceHandler, rMgr *rsrcMgr.OpenOltResourceMgr) *OpenOltFlowMgr {
-	logger.Info("Initializing flow manager")
+	logger.Infow("Initializing flow manager", log.Fields{"deviceId": dh.device.Id})
 	var flowMgr OpenOltFlowMgr
 	var err error
 	var idx uint32
@@ -298,8 +298,11 @@
 	var gemPorts []uint32
 	var TpInst *tp.TechProfile
 
-	logger.Infow("Dividing flow", log.Fields{"intfId": intfID, "onuId": onuID, "uniId": uniID, "portNo": portNo,
-		"classifier": classifierInfo, "action": actionInfo, "UsMeterID": UsMeterID, "DsMeterID": DsMeterID, "TpID": TpID})
+	logger.Infow("dividing-flow", log.Fields{
+		"deviceId": f.deviceHandler.device.Id,
+		"intfId":   intfID, "onuId": onuID, "uniId": uniID, "portNo": portNo,
+		"classifier": classifierInfo,
+		"action":     actionInfo, "UsMeterID": UsMeterID, "DsMeterID": DsMeterID, "TpID": TpID})
 	// only create tcont/gemports if there is actually an onu id.  otherwise BAL throws an error.  Usually this
 	// is because the flow is an NNI flow and there would be no onu resources associated with it
 	// TODO: properly deal with NNI flows
@@ -308,11 +311,16 @@
 		return
 	}
 
-	uni := getUniPortPath(intfID, int32(onuID), int32(uniID))
-	logger.Debugw("Uni port name", log.Fields{"uni": uni})
+	uni := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
+	logger.Debugw("uni-port-path", log.Fields{"uni": uni, "deviceId": f.deviceHandler.device.Id})
 
 	tpLockMapKey := tpLockKey{intfID, onuID, uniID}
 	if f.perUserFlowHandleLock.TryLock(tpLockMapKey) {
+		logger.Debugw("dividing-flow-create-tcont-gem-ports", log.Fields{
+			"deviceId": f.deviceHandler.device.Id,
+			"intfId":   intfID, "onuId": onuID, "uniId": uniID, "portNo": portNo,
+			"classifier": classifierInfo,
+			"action":     actionInfo, "UsMeterID": UsMeterID, "DsMeterID": DsMeterID, "TpID": TpID})
 		allocID, gemPorts, TpInst = f.createTcontGemports(ctx, intfID, onuID, uniID, uni, portNo, TpID, UsMeterID, DsMeterID, flowMetadata)
 		if allocID == 0 || gemPorts == nil || TpInst == nil {
 			logger.Error("alloc-id-gem-ports-tp-unavailable")
@@ -332,7 +340,7 @@
 		f.checkAndAddFlow(ctx, args, classifierInfo, actionInfo, flow, TpInst, gemPorts, TpID, uni)
 		f.perUserFlowHandleLock.Unlock(tpLockMapKey)
 	} else {
-		logger.Errorw("failed to acquire per user flow handle lock",
+		logger.Errorw("failed-to-acquire-per-user-flow-handle-lock",
 			log.Fields{"intfId": intfID, "onuId": onuID, "uniId": uniID})
 		return
 	}
@@ -568,28 +576,30 @@
 
 	tpPath := f.getTPpath(intfID, uni, TpID)
 
-	logger.Infow("creating-new-tcont-and-gem", log.Fields{"pon": intfID, "onu": onuID, "uni": uniID})
+	logger.Infow("creating-new-tcont-and-gem", log.Fields{
+		"pon": intfID, "onu": onuID, "uni": uniID,
+		"deviceId": f.deviceHandler.device.Id, "tpId": TpID})
 
 	// Check tech profile instance already exists for derived port name
 	techProfileInstance, _ := f.techprofile[intfID].GetTPInstanceFromKVStore(ctx, TpID, tpPath)
 	if techProfileInstance == nil {
-		logger.Infow("tp-instance-not-found--creating-new", log.Fields{"path": tpPath})
+		logger.Infow("tp-instance-not-found--creating-new", log.Fields{"path": tpPath, "deviceId": f.deviceHandler.device.Id})
 		techProfileInstance, err = f.techprofile[intfID].CreateTechProfInstance(ctx, TpID, uni, intfID)
 		if err != nil {
 			// This should not happen, something wrong in KV backend transaction
-			logger.Errorw("tp-instance-create-failed", log.Fields{"error": err, "tpID": TpID})
+			logger.Errorw("tp-instance-create-failed", log.Fields{"error": err, "tpID": TpID, "deviceId": f.deviceHandler.device.Id})
 			return 0, nil, nil
 		}
 		f.resourceMgr.UpdateTechProfileIDForOnu(ctx, intfID, onuID, uniID, TpID)
 	} else {
-		logger.Debugw("Tech-profile-instance-already-exist-for-given port-name", log.Fields{"uni": uni})
+		logger.Debugw("Tech-profile-instance-already-exist-for-given port-name", log.Fields{"uni": uni, "deviceId": f.deviceHandler.device.Id})
 		tpInstanceExists = true
 	}
 	if UsMeterID != 0 {
 		sq := schedQueue{direction: tp_pb.Direction_UPSTREAM, intfID: intfID, onuID: onuID, uniID: uniID, tpID: TpID,
 			uniPort: uniPort, tpInst: techProfileInstance, meterID: UsMeterID, flowMetadata: flowMetadata}
 		if err := f.CreateSchedulerQueues(ctx, sq); err != nil {
-			logger.Errorw("CreateSchedulerQueues Failed-upstream", log.Fields{"error": err, "meterID": UsMeterID})
+			logger.Errorw("CreateSchedulerQueues Failed-upstream", log.Fields{"error": err, "meterID": UsMeterID, "deviceId": f.deviceHandler.device.Id})
 			return 0, nil, nil
 		}
 	}
@@ -597,7 +607,7 @@
 		sq := schedQueue{direction: tp_pb.Direction_DOWNSTREAM, intfID: intfID, onuID: onuID, uniID: uniID, tpID: TpID,
 			uniPort: uniPort, tpInst: techProfileInstance, meterID: DsMeterID, flowMetadata: flowMetadata}
 		if err := f.CreateSchedulerQueues(ctx, sq); err != nil {
-			logger.Errorw("CreateSchedulerQueues Failed-downstream", log.Fields{"error": err, "meterID": DsMeterID})
+			logger.Errorw("CreateSchedulerQueues Failed-downstream", log.Fields{"error": err, "meterID": DsMeterID, "deviceId": f.deviceHandler.device.Id})
 			return 0, nil, nil
 		}
 	}
@@ -616,7 +626,7 @@
 		allgemPortIDs = appendUnique(allgemPortIDs, gemPortID)
 	}
 
-	logger.Debugw("Allocated Tcont and GEM ports", log.Fields{"allocIDs": allocIDs, "gemports": allgemPortIDs})
+	logger.Debugw("allocated-tcont-and-GEM-ports", log.Fields{"allocIDs": allocIDs, "gemports": allgemPortIDs, "deviceId": f.deviceHandler.device.Id})
 	// Send Tconts and GEM ports to KV store
 	f.storeTcontsGEMPortsIntoKVStore(ctx, intfID, onuID, uniID, allocIDs, allgemPortIDs)
 	return allocID, gemPortIDs, techProfileInstance
@@ -624,8 +634,8 @@
 
 func (f *OpenOltFlowMgr) storeTcontsGEMPortsIntoKVStore(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, allocID []uint32, gemPortIDs []uint32) {
 
-	logger.Debugw("Storing allocated Tconts and GEM ports into KV store",
-		log.Fields{"intfId": intfID, "onuId": onuID, "uniId": uniID, "allocID": allocID, "gemPortIDs": gemPortIDs})
+	logger.Debugw("storing-allocated-Tconts-and-GEM-ports-into-KV-store",
+		log.Fields{"intfId": intfID, "onuId": onuID, "uniId": uniID, "allocID": allocID, "gemPortIDs": gemPortIDs, "deviceId": f.deviceHandler.device.Id})
 	/* Update the allocated alloc_id and gem_port_id for the ONU/UNI to KV store  */
 	if err := f.resourceMgr.UpdateAllocIdsForOnu(ctx, intfID, onuID, uniID, allocID); err != nil {
 		logger.Error("Errow while uploading allocID to KV store")
@@ -636,7 +646,7 @@
 	if err := f.resourceMgr.UpdateGEMportsPonportToOnuMapOnKVStore(ctx, gemPortIDs, intfID, onuID, uniID); err != nil {
 		logger.Error("Errow while uploading gemtopon map to KV store")
 	}
-	logger.Debug("Stored tconts and GEM into KV store successfully")
+	logger.Debugw("stored-tconts-and-GEM-into-KV-store-successfully", log.Fields{"deviceId": f.deviceHandler.device.Id})
 	for _, gemPort := range gemPortIDs {
 		f.addGemPortToOnuInfoMap(ctx, intfID, onuID, gemPort)
 	}
@@ -1086,20 +1096,23 @@
 	return &action, nil
 }
 
-func (f *OpenOltFlowMgr) getTPpath(intfID uint32, uni string, TpID uint32) string {
-	return f.techprofile[intfID].GetTechProfileInstanceKVPath(TpID, uni)
+// getTPpath return the ETCD path for a given UNI port
+func (f *OpenOltFlowMgr) getTPpath(intfID uint32, uniPath string, TpID uint32) string {
+	return f.techprofile[intfID].GetTechProfileInstanceKVPath(TpID, uniPath)
 }
 
 // DeleteTechProfileInstances removes the tech profile instances from persistent storage
 func (f *OpenOltFlowMgr) DeleteTechProfileInstances(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, sn string) error {
 	tpIDList := f.resourceMgr.GetTechProfileIDForOnu(ctx, intfID, onuID, uniID)
-	uniPortName := fmt.Sprintf("pon-{%d}/onu-{%d}/uni-{%d}", intfID, onuID, uniID)
+	uniPortName := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
+
 	for _, tpID := range tpIDList {
 		if err := f.DeleteTechProfileInstance(ctx, intfID, onuID, uniID, uniPortName, tpID); err != nil {
 			olterrors.NewErrAdapter("delete-tech-profile-failed", nil, err).Log()
 			// return err
 			// We should continue to delete tech-profile instances for other TP IDs
 		}
+		log.Debugw("tech-profile-deleted", log.Fields{"deviceId": f.deviceHandler.device.Id, "tp": tpID})
 	}
 	return nil
 }
@@ -1107,7 +1120,7 @@
 // DeleteTechProfileInstance removes the tech profile instance from persistent storage
 func (f *OpenOltFlowMgr) DeleteTechProfileInstance(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, uniPortName string, tpID uint32) error {
 	if uniPortName == "" {
-		uniPortName = fmt.Sprintf("pon-{%d}/onu-{%d}/uni-{%d}", intfID, onuID, uniID)
+		uniPortName = getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
 	}
 	if err := f.techprofile[intfID].DeleteTechProfileInstance(ctx, tpID, uniPortName); err != nil {
 		return olterrors.NewErrAdapter("failed-to-delete-tp-instance-from-kv-store", log.Fields{"tp-id": tpID, "uni-port-name": uniPortName}, err)
@@ -1212,17 +1225,28 @@
 		intfID = uint32(deviceFlow.NetworkIntfId)
 	}
 
-	logger.Debugw("Sending flow to device via grpc", log.Fields{"flow": *deviceFlow})
+	logger.Debugw("sending-flow-to-device-via-grpc", log.Fields{
+		"flow":     *deviceFlow,
+		"deviceId": f.deviceHandler.device.Id,
+	})
 	_, err := f.deviceHandler.Client.FlowAdd(context.Background(), deviceFlow)
 
 	st, _ := status.FromError(err)
 	if st.Code() == codes.AlreadyExists {
-		logger.Debug("Flow already exists", log.Fields{"err": err, "deviceFlow": deviceFlow})
+		logger.Debug("flow-already-exists", log.Fields{
+			"err":        err,
+			"deviceFlow": deviceFlow,
+			"deviceId":   f.deviceHandler.device.Id,
+		})
 		return nil
 	}
 
 	if err != nil {
-		logger.Errorw("Failed to Add flow to device", log.Fields{"err": err, "deviceFlow": deviceFlow})
+		logger.Errorw("failed-to-Add-flow-to-device", log.Fields{
+			"err":        err,
+			"deviceFlow": deviceFlow,
+			"deviceId":   f.deviceHandler.device.Id,
+		})
 		f.resourceMgr.FreeFlowID(ctx, intfID, deviceFlow.OnuId, deviceFlow.UniId, deviceFlow.FlowId)
 		return err
 	}
@@ -1230,7 +1254,10 @@
 		// No need to register the flow if it is a trap on nni flow.
 		f.registerFlow(ctx, logicalFlow, deviceFlow)
 	}
-	logger.Debugw("Flow added to device successfully ", log.Fields{"flow": *deviceFlow})
+	logger.Debugw("flow-added-to-device-successfully", log.Fields{
+		"flow":     *deviceFlow,
+		"deviceId": f.deviceHandler.device.Id,
+	})
 	return nil
 }
 
@@ -1352,8 +1379,8 @@
 	return nil
 }
 
-func getUniPortPath(intfID uint32, onuID int32, uniID int32) string {
-	return fmt.Sprintf("pon-{%d}/onu-{%d}/uni-{%d}", intfID, onuID, uniID)
+func getUniPortPath(oltID string, intfID uint32, onuID int32, uniID int32) string {
+	return fmt.Sprintf("olt-{%s}/pon-{%d}/onu-{%d}/uni-{%d}", oltID, intfID, onuID, uniID)
 }
 
 //getOnuDevice to fetch onu from cache or core.
@@ -1387,7 +1414,7 @@
 			"onu-id":       onuID},
 			err)
 	}
-	logger.Debugw("Successfully received child device from core", log.Fields{"child_device": *onuDevice})
+	logger.Debugw("Successfully received child device from core", log.Fields{"child_device_id": onuDevice.Id, "child_device_sn": onuDevice.SerialNumber})
 	return onuDevice, nil
 }
 
@@ -1485,6 +1512,8 @@
 func (f *OpenOltFlowMgr) deleteGemPortFromLocalCache(intfID uint32, onuID uint32, gemPortID uint32) {
 	f.lockCache.Lock()
 	defer f.lockCache.Unlock()
+	logger.Debugw("deleting-gem-from-local-cache",
+		log.Fields{"gem": gemPortID, "intf": intfID, "onu": onuID, "deviceId": f.deviceHandler.device.Id, "onuGem": f.onuGemInfo[intfID]})
 	onugem := f.onuGemInfo[intfID]
 	for i, onu := range onugem {
 		if onu.OnuID == onuID {
@@ -1493,8 +1522,8 @@
 				if gem == gemPortID {
 					onu.GemPorts = append(onu.GemPorts[:j], onu.GemPorts[j+1:]...)
 					onugem[i] = onu
-					logger.Debugw("removed gemport from local cache",
-						log.Fields{"intfID": intfID, "onuID": onuID, "deletedGemPortID": gemPortID, "gemPorts": onu.GemPorts})
+					logger.Debugw("removed-gemport-from-local-cache",
+						log.Fields{"intfID": intfID, "onuID": onuID, "deletedGemPortID": gemPortID, "gemPorts": onu.GemPorts, "deviceId": f.deviceHandler.device.Id})
 					break
 				}
 			}
@@ -1539,10 +1568,13 @@
 				defer f.deletePendingFlows(Intf, onuID, uniID)
 			}
 
-			logger.Debugw("Releasing flow Id to resource manager", log.Fields{"Intf": Intf, "onuId": onuID, "uniId": uniID, "flowId": flowID})
+			logger.Debugw("releasing-flow-id-to-resource-manager", log.Fields{
+				"Intf": Intf, "onuId": onuID, "uniId": uniID, "flowId": flowID,
+				"deviceId": f.deviceHandler.device.Id,
+			})
 			f.resourceMgr.FreeFlowID(ctx, Intf, int32(onuID), int32(uniID), flowID)
 
-			uni := getUniPortPath(Intf, onuID, uniID)
+			uni := getUniPortPath(f.deviceHandler.device.Id, Intf, onuID, uniID)
 			tpPath := f.getTPpath(Intf, uni, tpID)
 			logger.Debugw("Getting-techprofile-instance-for-subscriber", log.Fields{"TP-PATH": tpPath})
 			techprofileInst, err := f.techprofile[Intf].GetTPInstanceFromKVStore(ctx, tpID, tpPath)
@@ -2250,7 +2282,7 @@
 	if err := f.resourceMgr.AddOnuGemInfo(ctx, intfID, onu); err != nil {
 		return err
 	}
-	logger.Debugw("Updated onuinfo", log.Fields{"intfID": intfID, "onuID": onuID, "serialNum": serialNum})
+	logger.Debugw("Updated onuinfo", log.Fields{"intfID": intfID, "onuID": onuID, "serialNum": serialNum, "onu": onu, "deviceId": f.deviceHandler.device.Id})
 	return nil
 }
 
@@ -2258,6 +2290,8 @@
 func (f *OpenOltFlowMgr) addGemPortToOnuInfoMap(ctx context.Context, intfID uint32, onuID uint32, gemPort uint32) {
 	f.lockCache.Lock()
 	defer f.lockCache.Unlock()
+	logger.Debugw("adding-gem-to-onu-info-map",
+		log.Fields{"gem": gemPort, "intf": intfID, "onu": onuID, "deviceId": f.deviceHandler.device.Id, "onuGem": f.onuGemInfo[intfID]})
 	onugem := f.onuGemInfo[intfID]
 	// update the gem to the local cache as well as to kv strore
 	for idx, onu := range onugem {
@@ -2265,8 +2299,8 @@
 			// check if gem already exists , else update the cache and kvstore
 			for _, gem := range onu.GemPorts {
 				if gem == gemPort {
-					logger.Debugw("Gem already in cache, no need to update cache and kv store",
-						log.Fields{"gem": gemPort})
+					logger.Debugw("gem-already-in-cache-no-need-to-update-cache-and-kv-store",
+						log.Fields{"gem": gemPort, "deviceId": f.deviceHandler.device.Id})
 					return
 				}
 			}
@@ -2276,9 +2310,11 @@
 	}
 	err := f.resourceMgr.AddGemToOnuGemInfo(ctx, intfID, onuID, gemPort)
 	if err != nil {
-		logger.Errorw("Failed to add gem to onu", log.Fields{"intfId": intfID, "onuId": onuID, "gemPort": gemPort})
+		logger.Errorw("failed-to-add-gem-to-onu", log.Fields{"intfId": intfID, "onuId": onuID, "gemPort": gemPort, "deviceId": f.deviceHandler.device.Id})
 		return
 	}
+	logger.Debugw("gem-added-to-onu-info-map",
+		log.Fields{"gem": gemPort, "intf": intfID, "onu": onuID, "deviceId": f.deviceHandler.device.Id, "onuGem": f.onuGemInfo[intfID]})
 }
 
 // This function Lookup maps  by serialNumber or (intfId, gemPort)
@@ -2289,9 +2325,13 @@
 	f.lockCache.Lock()
 	defer f.lockCache.Unlock()
 
-	logger.Debugw("Getting ONU ID from GEM port and PON port", log.Fields{"serialNumber": serialNumber, "intfId": intfID, "gemPortId": gemPortID})
+	logger.Debugw("Getting-ONU-ID-from-GEM-port-and-PON-port", log.Fields{
+		"deviceId": f.deviceHandler.device.Id, "onuGemInfo": f.onuGemInfo[intfID],
+		"serialNumber": serialNumber, "intfId": intfID, "gemPortId": gemPortID})
+
 	// get onuid from the onugem info cache
 	onugem := f.onuGemInfo[intfID]
+
 	for _, onu := range onugem {
 		for _, gem := range onu.GemPorts {
 			if gem == gemPortID {