VOL-2463 : Adding enable/disable PON port.
2. Raising and clearing alarm on disable and enable PON port.
3. Avoiding statistics collection for disabled pon.
Change-Id: I794d002a9fbf906cfb6aacbee0c6fea758617a61
diff --git a/adaptercore/openolt_eventmgr.go b/adaptercore/openolt_eventmgr.go
index 75086dc..835abe6 100644
--- a/adaptercore/openolt_eventmgr.go
+++ b/adaptercore/openolt_eventmgr.go
@@ -18,11 +18,13 @@
package adaptercore
import (
+ ctx "context"
"fmt"
"strconv"
"github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
+ "github.com/opencord/voltha-protos/v3/go/common"
oop "github.com/opencord/voltha-protos/v3/go/openolt"
"github.com/opencord/voltha-protos/v3/go/voltha"
)
@@ -47,6 +49,7 @@
onuLossOfKeySyncEvent = "ONU_LOSS_OF_KEY_SYNC"
onuLossOfFrameEvent = "ONU_LOSS_OF_FRAME"
onuLossOfPloamEvent = "ONU_LOSS_OF_PLOAM"
+ ponIntfDownIndiction = "OLT_PON_INTERFACE_DOWN"
)
const (
@@ -446,3 +449,40 @@
log.Infow("ONU loss of key sync event sent to KAFKA", log.Fields{"onu-id": onuLOKI.OnuId, "intf-id": onuLOKI.IntfId})
return nil
}
+
+// oltIntfOperIndication handles Up and Down state of an OLT PON ports
+func (em *OpenOltEventMgr) oltIntfOperIndication(ifindication *oop.IntfOperIndication, deviceID string, raisedTs int64) {
+ var de voltha.DeviceEvent
+ context := make(map[string]string)
+ portID := IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT)
+ device, err := em.handler.coreProxy.GetDevice(ctx.Background(), deviceID, deviceID)
+ if err != nil {
+ log.Errorw("Error while fetching Device object", log.Fields{"DeviceId": deviceID})
+ }
+ 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 {
+ log.Infow("Port disable/enable event not generated because, The port is not enabled by operator", log.Fields{"deviceId": deviceID, "port": port})
+ return
+ }
+ break
+ }
+ }
+ /* Populating event context */
+ context["oper-state"] = ifindication.GetOperState()
+ /* Populating device event body */
+ de.Context = context
+ de.ResourceId = deviceID
+
+ if ifindication.GetOperState() == operationStateDown {
+ de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "RAISE_EVENT")
+ } else if ifindication.OperState == operationStateUp {
+ de.DeviceEventName = fmt.Sprintf("%s_%s", ponIntfDownIndiction, "CLEAR_EVENT")
+ }
+ /* Send event to KAFKA */
+ if err := em.eventProxy.SendDeviceEvent(&de, communication, olt, raisedTs); err != nil {
+ log.Errorw("failed-to-send-olt-intf-oper-status-event", log.Fields{"err": err})
+ }
+ log.Info("sent-olt-intf-oper-status-event-to-kafka")
+}