[VOL-936] Add changes for onu distance from olt

Change-Id: I2d935194371d348e40a9926bb3a916b4893f48df
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 7b5f2a2..ba40532 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -2178,3 +2178,36 @@
 	onuKey := dh.formOnuKey(onuDevice.intfID, onuDevice.onuID)
 	dh.onus.Store(onuKey, onuDevice)
 }
+
+func (dh *DeviceHandler) getExtValue(device *voltha.Device, value voltha.ValueType_Type) (*voltha.ReturnValues, error) {
+	var err error
+	var ID uint32
+	resp := new(voltha.ReturnValues)
+	valueparam := new(oop.ValueParam)
+	ctx := context.Background()
+	log.Infow("getExtValue", log.Fields{"onu-id": device.Id, "pon-intf": device.ParentPortNo})
+	sn := new(oop.SerialNumber)
+	if sn, err = dh.deStringifySerialNumber(device.SerialNumber); err != nil {
+		return nil, err
+	}
+	ID = device.ProxyAddress.GetOnuId()
+	Onu := oop.Onu{IntfId: device.ParentPortNo, OnuId: ID, SerialNumber: sn}
+	valueparam.Onu = &Onu
+	valueparam.Value = value
+
+	// This API is unsupported until agent patch is added
+	resp.Unsupported = uint32(value)
+	_ = ctx
+
+	// Uncomment this code once agent changes are complete and tests
+	/*
+		resp, err = dh.Client.GetValue(ctx, valueparam)
+		if err != nil {
+			log.Errorw("error-while-getValue", log.Fields{"DeviceID": dh.device, "onu-id": onuid, "error": err})
+			return nil, err
+		}
+	*/
+
+	log.Infow("get-ext-value", log.Fields{"resp": resp, "device-id": dh.device, "onu-id": device.Id, "pon-intf": device.ParentPortNo})
+	return resp, nil
+}
diff --git a/internal/pkg/core/openolt.go b/internal/pkg/core/openolt.go
index 6e35a3e..7343c94 100644
--- a/internal/pkg/core/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -389,3 +389,17 @@
 func (oo *OpenOLT) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) {
 	return nil, olterrors.ErrNotImplemented
 }
+
+func (oo *OpenOLT) Get_ext_value(deviceID string, device *voltha.Device, valueparam voltha.ValueType_Type) (*voltha.ReturnValues, error) {
+	var err error
+	resp := new(voltha.ReturnValues)
+	log.Infow("Get_ext_value", log.Fields{"device-id": deviceID, "onu-id": device.Id})
+	if handler := oo.getDeviceHandler(deviceID); handler != nil {
+		if resp, err = handler.getExtValue(device, valueparam); err != nil {
+			log.Errorw("error-occurred-during-get-ext-value", log.Fields{"device-id": deviceID, "onu-id": device.Id,
+				"error": err})
+			return nil, err
+		}
+	}
+	return resp, nil
+}