VOL-3121 - Removing usage of device.Ports
Changed device.Ports usages to GetDevicePort() and ListDevicePorts()
Added port type filter to PortsStateUpdate()
Change-Id: I4fab819a909379ee71e70eb48ac44044e9810185
diff --git a/internal/pkg/core/openolt_eventmgr.go b/internal/pkg/core/openolt_eventmgr.go
index fc9a342..6f1fd68 100644
--- a/internal/pkg/core/openolt_eventmgr.go
+++ b/internal/pkg/core/openolt_eventmgr.go
@@ -617,26 +617,17 @@
// oltIntfOperIndication handles Up and Down state of an OLT PON ports
func (em *OpenOltEventMgr) oltIntfOperIndication(ctx context.Context, ifindication *oop.IntfOperIndication, deviceID string, raisedTs int64) error {
- var de voltha.DeviceEvent
- portID := IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT)
- device, err := em.handler.coreProxy.GetDevice(context.Background(), deviceID, deviceID)
- if err != nil {
- return olterrors.NewErrAdapter("error-while-fetching-device-object", log.Fields{"DeviceId": deviceID}, err)
- }
- context := make(map[string]string)
- for _, port := range device.Ports {
- if port.PortNo == portID {
- // Events are suppressed if the Port Adminstate is not enabled.
- if port.AdminState != common.AdminState_ENABLED {
- logger.Debugw(ctx, "port-disable/enable-event-not-generated--the-port-is-not-enabled-by-operator", log.Fields{"deviceId": deviceID, "port": port})
- return nil
- }
- break
- }
+ portNo := IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT)
+ if port, err := em.handler.coreProxy.GetDevicePort(ctx, deviceID, portNo); err != nil {
+ logger.Warnw(ctx, "Error while fetching port object", log.Fields{"device-id": deviceID, "error": err})
+ } else if port.AdminState != common.AdminState_ENABLED {
+ logger.Debugw(ctx, "port-disable/enable-event-not-generated--the-port-is-not-enabled-by-operator", log.Fields{"device-id": deviceID, "port": port})
+ return nil
}
/* Populating event context */
- context[ContextOltPonIntfOperState] = ifindication.GetOperState()
+ context := map[string]string{ContextOltPonIntfOperState: ifindication.GetOperState()}
/* Populating device event body */
+ var de voltha.DeviceEvent
de.Context = context
de.ResourceId = deviceID