VOL-2103 - Device reason update modifications

A new api is defined to update the reason attribute of Device in rw_core.

Change-Id: Icc4134498fc622d67d8e8b6f6d08f0968a8e9bd2
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index 95e4f67..4a5274b 100755
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -1328,3 +1328,19 @@
 
 	return nil
 }
+
+func (agent *DeviceAgent) updateDeviceReason(reason string) error {
+	agent.lockDevice.Lock()
+	defer agent.lockDevice.Unlock()
+	// Work only on latest data
+	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	} else {
+		// clone the device
+		cloned := proto.Clone(storeDevice).(*voltha.Device)
+		cloned.Reason = reason
+		log.Debugw("updateDeviceReason", log.Fields{"deviceId": cloned.Id, "reason": cloned.Reason})
+		// Store the device
+		return agent.updateDeviceInStoreWithoutLock(cloned, false, "")
+	}
+}