[VOL-3188] - concurrency protection enhancement to ensure setup for muliple ONU parallel start
[VOL-3167] - Implementd device handler processing based on ONU-Indication-Request OperStatus Unreachable/Down

Change-Id: Ia4fd92111c9e49fc174c791aafb4ee00305043a9
Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
diff --git a/internal/pkg/onuadaptercore/mib_sync.go b/internal/pkg/onuadaptercore/mib_sync.go
index d5f2696..807412d 100644
--- a/internal/pkg/onuadaptercore/mib_sync.go
+++ b/internal/pkg/onuadaptercore/mib_sync.go
@@ -23,6 +23,7 @@
 	"errors"
 	"fmt"
 	"strconv"
+	"strings"
 
 	"github.com/looplab/fsm"
 
@@ -95,7 +96,13 @@
 	if err == nil {
 		if Value != nil {
 			logger.Debugf("MibSync FSM - MibTemplate read: Key: %s, Value: %s  %s", Value.Key, Value.Value)
-			mibTmpBytes, _ := kvstore.ToByte(Value.Value)
+
+			// swap out tokens with specific data
+			mibTmpString, _ := kvstore.ToString(Value.Value)
+			mibTmpString2 := strings.Replace(mibTmpString, "%SERIAL_NUMBER%", onuDeviceEntry.serialNumber, -1)
+			mibTmpString = strings.Replace(mibTmpString2, "%MAC_ADDRESS%", onuDeviceEntry.macAddress, -1)
+			mibTmpBytes := []byte(mibTmpString)
+			logger.Debugf("MibSync FSM - MibTemplate tokens swapped out: %s", mibTmpBytes)
 
 			var fistLevelMap map[string]interface{}
 			if err = json.Unmarshal(mibTmpBytes, &fistLevelMap); err != nil {