[VOL-3144] Disabling all ports when a disable ONU is received, enabling upon re-enable

Change-Id: I8a1d3be9a53c6c173c92d316feb279d6618e65fc
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index 61ce8dc..f8bf361 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -562,6 +562,7 @@
 			dh.pLockStateFsm.setSuccessEvent(UniAdminStateDone)
 			dh.runUniLockFsm(true)
 		}
+		dh.disableUniPortStateUpdate()
 		//VOL-3493/VOL-3495: postpone setting of deviceReason, conn- and operStatus until all omci-related communication regarding
 		//device disabling has finished successfully
 	}
@@ -596,6 +597,9 @@
 		dh.pUnlockStateFsm.setSuccessEvent(UniAdminStateDone)
 		dh.runUniLockFsm(false)
 	}
+	//TODO this should be moved according to the discussion here
+	// https://gerrit.opencord.org/c/voltha-openonu-adapter-go/+/21066
+	dh.enableUniPortStateUpdate()
 }
 
 func (dh *deviceHandler) reconcileDeviceOnuInd() {
@@ -1569,7 +1573,7 @@
 		}
 	default:
 		{
-			logger.Warnw("unhandled-device-event", log.Fields{"device-id": dh.deviceID, "event": devEvent})
+			logger.Debugw("unhandled-device-event", log.Fields{"device-id": dh.deviceID, "event": devEvent})
 		}
 	} //switch
 }
@@ -1619,6 +1623,7 @@
 				//maybe also use getter functions on uniPort - perhaps later ...
 				go dh.coreProxy.PortStateUpdate(context.TODO(), dh.deviceID, voltha.Port_ETHERNET_UNI, uniPort.portNo, uniPort.operState)
 			} else {
+				//TODO there is no retry mechanism, return error
 				logger.Debugw("reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.deviceID})
 			}
 		}
diff --git a/internal/pkg/onuadaptercore/uniportadmin.go b/internal/pkg/onuadaptercore/uniportadmin.go
index dea2a06..ea2ed16 100644
--- a/internal/pkg/onuadaptercore/uniportadmin.go
+++ b/internal/pkg/onuadaptercore/uniportadmin.go
@@ -228,11 +228,16 @@
 			logger.Errorw("error-updating-reason-state", log.Fields{"device-id": oFsm.pDeviceHandler.deviceID, "error": err})
 		}
 		oFsm.pDeviceHandler.deviceReason = "omci-admin-lock"
-		//200604: ConnState improved to 'unreachable' (was not set in python-code), OperState 'unknown' seems to be best choice
-		logger.Debugw("call DeviceStateUpdate", log.Fields{"ConnectStatus": voltha.ConnectStatus_UNREACHABLE,
-			"OperStatus": voltha.OperStatus_UNKNOWN, "device-id": oFsm.pDeviceHandler.deviceID})
+		//ConnState is reachable given the fact that no cable was pulled and it can be re-enabled through OMCI.
+		logger.Debugw("call DeviceStateUpdate", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
+			"OperStatus": voltha.OperStatus_UNKNOWN, "device-id": oFsm.pDeviceHandler.deviceID, "reason": oFsm.pDeviceHandler.deviceReason})
+		if err := oFsm.pDeviceHandler.coreProxy.DeviceReasonUpdate(context.TODO(), oFsm.pDeviceHandler.deviceID,
+			oFsm.pDeviceHandler.deviceReason); err != nil {
+			//TODO with VOL-3045/VOL-3046: return the error and stop further processing
+			logger.Errorw("error-updating-device-reason", log.Fields{"device-id": oFsm.pDeviceHandler.deviceID, "error": err})
+		}
 		if err := oFsm.pDeviceHandler.coreProxy.DeviceStateUpdate(context.TODO(), oFsm.pDeviceHandler.deviceID,
-			voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN); err != nil {
+			voltha.ConnectStatus_REACHABLE, voltha.OperStatus_UNKNOWN); err != nil {
 			//TODO with VOL-3045/VOL-3046: return the error and stop further processing
 			logger.Errorw("error-updating-device-state", log.Fields{"device-id": oFsm.pDeviceHandler.deviceID, "error": err})
 		}