VOL-3501 Code changes to support rpc event
Change-Id: I2536c0c03faa5fb026349c906ebef46323398e9a
diff --git a/rw_core/core/device/agent_port.go b/rw_core/core/device/agent_port.go
index a3489fc..6e53d16 100644
--- a/rw_core/core/device/agent_port.go
+++ b/rw_core/core/device/agent_port.go
@@ -22,6 +22,7 @@
"github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-go/rw_core/core/device/port"
+ coreutils "github.com/opencord/voltha-go/rw_core/utils"
"github.com/opencord/voltha-lib-go/v4/pkg/log"
"github.com/opencord/voltha-protos/v4/go/voltha"
"google.golang.org/grpc/codes"
@@ -43,7 +44,7 @@
// getPorts retrieves the ports information of the device based on the port type.
func (agent *Agent) getPorts(ctx context.Context, portType voltha.Port_PortType) *voltha.Ports {
- logger.Debugw(ctx, "getPorts", log.Fields{"device-id": agent.deviceID, "port-type": portType})
+ logger.Debugw(ctx, "get-ports", log.Fields{"device-id": agent.deviceID, "port-type": portType})
ports := &voltha.Ports{}
for _, port := range agent.listDevicePorts() {
if port.Type == portType {
@@ -63,7 +64,7 @@
}
func (agent *Agent) updatePortsOperState(ctx context.Context, portTypeFilter uint32, operStatus voltha.OperStatus_Types) error {
- logger.Debugw(ctx, "updatePortsOperState", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw(ctx, "update-ports-oper-state", log.Fields{"device-id": agent.deviceID})
for portID := range agent.portLoader.ListIDs() {
if portHandle, have := agent.portLoader.Lock(portID); have {
@@ -79,12 +80,14 @@
// Notify the logical device manager to change the port state
// Do this for NNI and UNIs only. PON ports are not known by logical device
if newPort.Type == voltha.Port_ETHERNET_NNI || newPort.Type == voltha.Port_ETHERNET_UNI {
+ subCtx := coreutils.WithSpanAndRPCMetadataFromContext(ctx)
+
go func(portID uint32, ctx context.Context) {
if err := agent.deviceMgr.logicalDeviceMgr.updatePortState(ctx, agent.deviceID, portID, operStatus); err != nil {
// TODO: VOL-2707
logger.Warnw(ctx, "unable-to-update-logical-port-state", log.Fields{"error": err})
}
- }(portID, log.WithSpanFromContext(context.Background(), ctx))
+ }(portID, subCtx)
}
}
portHandle.Unlock()
@@ -116,7 +119,7 @@
}
func (agent *Agent) deleteAllPorts(ctx context.Context) error {
- logger.Debugw(ctx, "deleteAllPorts", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw(ctx, "delete-all-ports", log.Fields{"device-id": agent.deviceID})
device, err := agent.getDeviceReadOnly(ctx)
if err != nil {
@@ -159,7 +162,7 @@
oldPort := portHandle.GetReadOnly()
if oldPort.Label != "" || oldPort.Type != voltha.Port_PON_OLT {
- logger.Debugw(ctx, "port already exists", log.Fields{"port": port})
+ logger.Debugw(ctx, "port-already-exists", log.Fields{"port": port})
return nil
}
@@ -218,7 +221,7 @@
}
func (agent *Agent) disablePort(ctx context.Context, portID uint32) error {
- logger.Debugw(ctx, "disablePort", log.Fields{"device-id": agent.deviceID, "port-no": portID})
+ logger.Debugw(ctx, "disable-port", log.Fields{"device-id": agent.deviceID, "port-no": portID})
portHandle, have := agent.portLoader.Lock(portID)
if !have {
@@ -244,6 +247,8 @@
return err
}
subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout)
+ subCtx = coreutils.WithRPCMetadataFromContext(subCtx, ctx)
+
ch, err := agent.adapterProxy.DisablePort(ctx, device, &newPort)
if err != nil {
cancel()
@@ -254,7 +259,7 @@
}
func (agent *Agent) enablePort(ctx context.Context, portID uint32) error {
- logger.Debugw(ctx, "enablePort", log.Fields{"device-id": agent.deviceID, "port-no": portID})
+ logger.Debugw(ctx, "enable-port", log.Fields{"device-id": agent.deviceID, "port-no": portID})
portHandle, have := agent.portLoader.Lock(portID)
if !have {
@@ -280,6 +285,8 @@
return err
}
subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout)
+ subCtx = coreutils.WithRPCMetadataFromContext(subCtx, ctx)
+
ch, err := agent.adapterProxy.EnablePort(ctx, device, &newPort)
if err != nil {
cancel()