[VOL-3604] flow/techProfile handling after ONU reboot/down/disable must be revised -> version 0.1.13-dev137

Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
Change-Id: I8bd846170d62f15c3a83ce6b10911707e0cd6176
diff --git a/internal/pkg/onuadaptercore/omci_ani_config.go b/internal/pkg/onuadaptercore/omci_ani_config.go
index 70f172a..4c5f22f 100644
--- a/internal/pkg/onuadaptercore/omci_ani_config.go
+++ b/internal/pkg/onuadaptercore/omci_ani_config.go
@@ -552,30 +552,32 @@
 		return
 	}
 	logger.Debugw("CreateResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
-	if msgObj.Result != me.Success {
+	if msgObj.Result == me.Success || msgObj.Result == me.InstanceExists {
+		//if the result is ok or Instance already exists (latest needed at least as long as we do not clear the OMCI techProfile data)
+		if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() &&
+			msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() {
+			// maybe we can use just the same eventName for different state transitions like "forward"
+			//   - might be checked, but so far I go for sure and have to inspect the concrete state events ...
+			switch oFsm.pLastTxMeInstance.GetName() {
+			case "Ieee8021PMapperServiceProfile":
+				{ // let the FSM proceed ...
+					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapCResp)
+				}
+			case "MacBridgePortConfigurationData":
+				{ // let the FSM proceed ...
+					_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxMbpcdResp)
+				}
+			case "GemPortNetworkCtp", "GemInterworkingTerminationPoint":
+				{ // let aniConfig Multi-Id processing proceed by stopping the wait function
+					oFsm.omciMIdsResponseReceived <- true
+				}
+			}
+		}
+	} else {
 		logger.Errorw("Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
 		// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
 		return
 	}
-	if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() &&
-		msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() {
-		// maybe we can use just the same eventName for different state transitions like "forward"
-		//   - might be checked, but so far I go for sure and have to inspect the concrete state events ...
-		switch oFsm.pLastTxMeInstance.GetName() {
-		case "Ieee8021PMapperServiceProfile":
-			{ // let the FSM proceed ...
-				_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapCResp)
-			}
-		case "MacBridgePortConfigurationData":
-			{ // let the FSM proceed ...
-				_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxMbpcdResp)
-			}
-		case "GemPortNetworkCtp", "GemInterworkingTerminationPoint":
-			{ // let aniConfig Multi-Id processing proceed by stopping the wait function
-				oFsm.omciMIdsResponseReceived <- true
-			}
-		}
-	}
 }
 
 func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(msg OmciMessage) {