VOL-3503 Add a device operational state of RECONCILING
Change-Id: I5a1abd6013ae37d700ad905cd584fd3bfeb184c2
diff --git a/VERSION b/VERSION
index 38fe29a..8c2e99f 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.3.1-dev202
+1.3.1-dev203
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index fc29ac2..73a3d48 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -3385,13 +3385,41 @@
select {
case success := <-dh.chReconcilingFinished:
if success {
+ if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+ logger.Errorw(ctx, "No valid OnuDevice - aborting Core DeviceStateUpdate",
+ log.Fields{"device-id": dh.deviceID})
+ } else {
+ connectStatus := voltha.ConnectStatus_UNREACHABLE
+ operState := voltha.OperStatus_UNKNOWN
+ if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+ connectStatus = voltha.ConnectStatus_REACHABLE
+ if !onuDevEntry.sOnuPersistentData.PersUniDisableDone {
+ if onuDevEntry.sOnuPersistentData.PersUniUnlockDone {
+ operState = voltha.OperStatus_ACTIVE
+ } else {
+ operState = voltha.OperStatus_ACTIVATING
+ }
+ }
+ } else if onuDevEntry.sOnuPersistentData.PersOperState == "down" ||
+ onuDevEntry.sOnuPersistentData.PersOperState == "unknown" ||
+ onuDevEntry.sOnuPersistentData.PersOperState == "" {
+ operState = voltha.OperStatus_DISCOVERED
+ }
+
+ logger.Debugw(ctx, "Core DeviceStateUpdate", log.Fields{"connectStatus": connectStatus, "operState": operState})
+ if err := dh.coreProxy.DeviceStateUpdate(ctx, dh.deviceID, connectStatus, operState); err != nil {
+ logger.Errorw(ctx, "unable to update device state to core",
+ log.Fields{"OperState": onuDevEntry.sOnuPersistentData.PersOperState, "Err": err})
+ }
+ }
logger.Debugw(ctx, "reconciling has been finished in time",
log.Fields{"device-id": dh.deviceID})
} else {
- logger.Debugw(ctx, "wait for reconciling aborted",
+ logger.Errorw(ctx, "wait for reconciling aborted",
log.Fields{"device-id": dh.deviceID})
}
case <-time.After(dh.pOpenOnuAc.maxTimeoutReconciling):
+ //TODO: handle notification to core if reconciling timed out
logger.Errorw(ctx, "timeout waiting for reconciling to be finished!",
log.Fields{"device-id": dh.deviceID})
}
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/onuadaptercore/openonu.go
index c61ce5f..c7f3e85 100644
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/onuadaptercore/openonu.go
@@ -332,6 +332,9 @@
handler := newDeviceHandler(ctx, oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
oo.addDeviceHandlerToMap(ctx, handler)
handler.device = device
+ if err := handler.coreProxy.DeviceStateUpdate(ctx, device.Id, device.ConnectStatus, voltha.OperStatus_RECONCILING); err != nil {
+ return fmt.Errorf("not able to update device state to reconciling. Err : %s", err.Error())
+ }
handler.startReconciling(ctx, false)
go handler.adoptOrReconcileDevice(ctx, handler.device)
// reconcilement will be continued after onu-device entry is added