Re-adding get_site_job_data(): Now uses host platform for hostname.
Update to CL http://codereview.chromium.org/6677136/
- Changing default keyval info with get_site_job_data() allows cleaner reporting and smaller tko_machines tables when multiple machines are used on the same job.
Now hostname will only be updated in multimachine jobs when the platform of a host can be retrieved from AFE. The platform will be used as the hostname to prevent breaking the dashboard.
Change-Id: I24c6a6937b583ca3d10f5c9bfb759346ae6a2b26
BUG=None.
TEST=Tested multimachine BVT run in the lab.
Review URL: http://codereview.chromium.org/6805015
diff --git a/server/site_server_job.py b/server/site_server_job.py
new file mode 100644
index 0000000..d96c288
--- /dev/null
+++ b/server/site_server_job.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import common
+import utils
+
+
+def get_site_job_data(job):
+ """Add custom data to the job keyval info.
+
+ When multiple machines are used in a job, change the hostname to
+ the platform of the first machine instead of machine1,machine2,... This
+ makes the job reports easier to read and keeps the tko_machines table from
+ growing too large.
+
+ Args:
+ job: instance of server_job.
+
+ Returns:
+ keyval dictionary with new hostname value, or empty dictionary.
+ """
+ site_job_data = {}
+ # Only modify hostname on multimachine jobs. Assume all host have the same
+ # platform.
+ if len(job.machines) > 1:
+ # Search through machines for first machine with a platform.
+ for host in job.machines:
+ keyval_path = os.path.join(job.resultdir, 'host_keyvals', host)
+ keyvals = utils.read_keyval(keyval_path)
+ host_plat = keyvals.get('platform', None)
+ if not host_plat:
+ continue
+ site_job_data['hostname'] = host_plat
+ break
+ return site_job_data
+
+
+class site_server_job(object):
+ pass