VOL-4896 return error fro omci proxy messages

Change-Id: I9b695225af726747fbb50a3fb3ec5a1cdb9df06c
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index effbc08..e8ced1e 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -1232,6 +1232,9 @@
 
 // ProxyOmciRequests sends the proxied OMCI message to the target device
 func (dh *DeviceHandler) ProxyOmciRequests(ctx context.Context, omciMsgs *ia.OmciMessages) error {
+	if DeviceState(dh.device.ConnectStatus) != DeviceState(voltha.ConnectStatus_REACHABLE) {
+		return status.Error(codes.Unavailable, "OLT unreachable")
+	}
 	if omciMsgs.GetProxyAddress() == nil {
 		onuDevice, err := dh.getDeviceFromCore(ctx, omciMsgs.ChildDeviceId)
 		if err != nil {
@@ -1311,6 +1314,9 @@
 func (dh *DeviceHandler) ProxyOmciMessage(ctx context.Context, omciMsg *ia.OmciMessage) error {
 	logger.Debugw(ctx, "proxy-omci-message", log.Fields{"parent-device-id": omciMsg.ParentDeviceId, "child-device-id": omciMsg.ChildDeviceId, "proxy-address": omciMsg.ProxyAddress, "connect-status": omciMsg.ConnectStatus})
 
+	if DeviceState(dh.device.ConnectStatus) != DeviceState(voltha.ConnectStatus_REACHABLE) {
+		return status.Error(codes.Unavailable, "OLT unreachable")
+	}
 	if omciMsg.GetProxyAddress() == nil {
 		onuDevice, err := dh.getDeviceFromCore(ctx, omciMsg.ChildDeviceId)
 		if err != nil {
diff --git a/internal/pkg/core/device_handler_test.go b/internal/pkg/core/device_handler_test.go
index 4d5d231..0948830 100644
--- a/internal/pkg/core/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -159,7 +159,7 @@
 			ChannelId:      1,
 			ChannelGroupId: 1,
 		},
-		ConnectStatus: 1,
+		ConnectStatus: 2,
 	}
 	mcs := newMockCoreService()
 	cc := mocks.NewMockCoreClient(mcs)
diff --git a/internal/pkg/core/openolt.go b/internal/pkg/core/openolt.go
index 801e563..6115ec5 100644
--- a/internal/pkg/core/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -19,7 +19,6 @@
 
 import (
 	"context"
-	"errors"
 	"fmt"
 	"sync"
 	"time"
@@ -393,7 +392,7 @@
 func (oo *OpenOLT) ProxyOmciRequests(ctx context.Context, request *ia.OmciMessages) (*empty.Empty, error) {
 	if handler := oo.getDeviceHandler(request.ParentDeviceId); handler != nil {
 		if err := handler.ProxyOmciRequests(ctx, request); err != nil {
-			return nil, errors.New(err.Error())
+			return nil, err
 		}
 		return &empty.Empty{}, nil
 	}
@@ -406,7 +405,7 @@
 
 	if handler := oo.getDeviceHandler(request.ParentDeviceId); handler != nil {
 		if err := handler.ProxyOmciMessage(ctx, request); err != nil {
-			return nil, errors.New(err.Error())
+			return nil, err
 		}
 		return &empty.Empty{}, nil
 	}