devserver: make host event logging optional
This is to prevent clogging the devserver's memory when this feature is
not needed (normally in specific test situations, where it will be
invoked with the new --host_log flag).
BUG=None
TEST=Passes unit tests; host events logged when requested
Change-Id: I3fe078dfdcd87abcdf2fa0886d814dc4a37a8c84
Reviewed-on: https://gerrit.chromium.org/gerrit/34660
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/autoupdate.py b/autoupdate.py
index 66febf7..5f34f29 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -134,9 +134,10 @@
board: board for the image. Needed for pre-generating of updates.
copy_to_static_root: copies images generated from the cache to ~/static.
private_key: path to private key in PEM format.
- critical_update: whether provisioned payload is critical.
- remote_payload: whether provisioned payload is remotely staged.
- max_updates: maximum number of updates we'll try to provision.
+ critical_update: whether provisioned payload is critical.
+ remote_payload: whether provisioned payload is remotely staged.
+ max_updates: maximum number of updates we'll try to provision.
+ host_log: record full history of host update events.
"""
_PAYLOAD_URL_PREFIX = '/static/'
@@ -148,6 +149,7 @@
proxy_port=None, src_image='', vm=False, board=None,
copy_to_static_root=True, private_key=None,
critical_update=False, remote_payload=False, max_updates=-1,
+ host_log=False,
*args, **kwargs):
super(Autoupdate, self).__init__(*args, **kwargs)
self.serve_only = serve_only
@@ -169,6 +171,7 @@
self.critical_update = critical_update
self.remote_payload = remote_payload
self.max_updates=max_updates
+ self.host_log = host_log
# Path to pre-generated file.
self.pregenerated_path = None
@@ -807,8 +810,9 @@
log_message['track'] = channel
log_message['board'] = board_id
- # Log client's message
- curr_host_info.AddLogEntry(log_message)
+ # Log host event, if so instructed.
+ if self.host_log:
+ curr_host_info.AddLogEntry(log_message)
# We only generate update payloads for updatecheck requests.
update_check = root.getElementsByTagName('o:updatecheck')