devserver: Add new post_au_status RPC
BUG=chromium:779870
TEST=curl -F "status=testing" "http://${ds}/post_au_status?host_name=${dut}&pid=${pid}"; curl "http://${ds}/get_au_status?host_name=${dut}&pid=${pid}"
Change-Id: I89cbdc2722162e07c8a9ae7b5767764163692757
Reviewed-on: https://chromium-review.googlesource.com/746996
Commit-Ready: David Riley <[email protected]>
Tested-by: David Riley <[email protected]>
Reviewed-by: David Riley <[email protected]>
diff --git a/devserver.py b/devserver.py
index c5f8c3c..58eba3b 100755
--- a/devserver.py
+++ b/devserver.py
@@ -1027,6 +1027,35 @@
return json.dumps(result_dict)
@cherrypy.expose
+ def post_au_status(self, status, **kwargs):
+ """Updates the status of an auto-update task.
+
+ Callers will need to POST to this URL with a body of MIME-type
+ "multipart/form-data".
+ The body should include a single argument, 'status', containing the
+ AU status to record.
+
+ Args:
+ status: The updated status.
+ kwargs:
+ host_name: the hostname of the DUT to auto-update.
+ pid: the background process id of cros-update.
+ """
+ if 'host_name' not in kwargs:
+ raise common_util.DevServerHTTPError((KEY_ERROR_MSG % 'host_name'))
+
+ if 'pid' not in kwargs:
+ raise common_util.DevServerHTTPError((KEY_ERROR_MSG % 'pid'))
+
+ host_name = kwargs['host_name']
+ pid = kwargs['pid']
+ progress_tracker = cros_update_progress.AUProgress(host_name, pid)
+
+ progress_tracker.WriteStatus(status.rstrip())
+
+ return 'True'
+
+ @cherrypy.expose
def handler_cleanup(self, **kwargs):
"""Clean track status log and temp directory for CrOS auto-update process.