[VOL-5322]-proper state updated adapter to fix logice device id creation
Change-Id: I26a36e15d0f3ba5cec466500969fea298948cbcb
Signed-off-by: Akash Soni <akash.soni@radisys.com>
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 22c7852..908fb57 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -1083,6 +1083,28 @@
"device-id": dh.device.Id,
"host-and-port": dh.device.GetHostAndPort()}, err)
}
+ //Setting oper and connection state to RECONCILING and conn state to reachable
+ cgClient, err := dh.coreClient.GetCoreServiceClient()
+ if err != nil {
+ return err
+ }
+
+ if dh.device.OperStatus == voltha.OperStatus_RECONCILING {
+ subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), dh.openOLT.rpcTimeout)
+ defer cancel()
+ if _, err := cgClient.DeviceStateUpdate(subCtx, &ca.DeviceStateFilter{
+ DeviceId: dh.device.Id,
+ OperStatus: voltha.OperStatus_RECONCILING,
+ ConnStatus: voltha.ConnectStatus_REACHABLE,
+ }); err != nil {
+ return olterrors.NewErrAdapter("device-update-failed", log.Fields{"device-id": dh.device.Id}, err)
+ }
+ // The OperState and connection state of the device is set to RECONCILING and REACHABLE in the previous section. This also needs to be set on the
+ // locally cached copy of the device struct.
+ dh.device.OperStatus = voltha.OperStatus_RECONCILING
+ dh.device.ConnectStatus = voltha.ConnectStatus_REACHABLE
+ }
+
return nil
}
diff --git a/internal/pkg/core/openolt.go b/internal/pkg/core/openolt.go
index 0d96d4f..b9f68dc 100644
--- a/internal/pkg/core/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -20,6 +20,9 @@
import (
"context"
"fmt"
+ "sync"
+ "time"
+
"github.com/golang/protobuf/ptypes/empty"
conf "github.com/opencord/voltha-lib-go/v7/pkg/config"
"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
@@ -37,8 +40,6 @@
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
- "sync"
- "time"
)
// OpenOLT structure holds the OLT information
@@ -183,14 +184,15 @@
if _, err := cgClient.DeviceStateUpdate(subCtx, &ca.DeviceStateFilter{
DeviceId: device.Id,
OperStatus: voltha.OperStatus_RECONCILING,
- ConnStatus: device.ConnectStatus,
+ ConnStatus: voltha.ConnectStatus_UNREACHABLE,
}); err != nil {
return nil, olterrors.NewErrAdapter("device-update-failed", log.Fields{"device-id": device.Id}, err)
}
- // The OperState of the device is set to RECONCILING in the previous section. This also needs to be set on the
+ // The OperState and connection state of the device is set to RECONCILING and UNREACHABLE in the previous section. This also needs to be set on the
// locally cached copy of the device struct.
device.OperStatus = voltha.OperStatus_RECONCILING
+ device.ConnectStatus = voltha.ConnectStatus_UNREACHABLE
handler := NewDeviceHandler(oo.coreClient, oo.eventProxy, device, oo, oo.configManager, oo.config)
handler.adapterPreviouslyConnected = true
oo.addDeviceHandlerToMap(handler)