VOL-3503 Add a device operational state of RECONCILING

Change-Id: I55dad67a24acdfac0af9448e6f19ec9d35edc39e
diff --git a/rw_core/core/device/agent_transient_state.go b/rw_core/core/device/agent_transient_state.go
index 776d60d..6b5b100 100644
--- a/rw_core/core/device/agent_transient_state.go
+++ b/rw_core/core/device/agent_transient_state.go
@@ -18,6 +18,7 @@
 
 import (
 	"context"
+	"github.com/opencord/voltha-protos/v4/go/common"
 	"github.com/opencord/voltha-protos/v4/go/voltha"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
@@ -30,7 +31,17 @@
 	return deviceTransientState
 }
 
+func (agent *Agent) matchTransientState(transientState voltha.DeviceTransientState_Types) bool {
+	transientStateHandle := agent.transientStateLoader.Lock()
+	defer transientStateHandle.UnLock()
+	return transientState == transientStateHandle.GetReadOnly()
+}
+
 func (agent *Agent) updateTransientState(ctx context.Context, transientState voltha.DeviceTransientState_Types) error {
+	// Already in same transientState
+	if transientState == agent.getTransientState() {
+		return nil
+	}
 	// Update device transient state
 	transientStateHandle := agent.transientStateLoader.Lock()
 	if err := transientStateHandle.Update(ctx, transientState); err != nil {
@@ -62,3 +73,9 @@
 	transientStateHandle.UnLock()
 	return nil
 }
+
+func (agent *Agent) isReconcileInProgress() bool {
+	device := agent.getDeviceReadOnlyWithoutLock()
+	return device.OperStatus == common.OperStatus_RECONCILING ||
+		agent.matchTransientState(voltha.DeviceTransientState_RECONCILE_IN_PROGRESS)
+}