Paul Pendlebury | 9dc949c | 2011-04-06 13:31:07 -0700 | [diff] [blame^] | 1 | # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import os |
| 6 | import common |
| 7 | import utils |
| 8 | |
| 9 | |
| 10 | def get_site_job_data(job): |
| 11 | """Add custom data to the job keyval info. |
| 12 | |
| 13 | When multiple machines are used in a job, change the hostname to |
| 14 | the platform of the first machine instead of machine1,machine2,... This |
| 15 | makes the job reports easier to read and keeps the tko_machines table from |
| 16 | growing too large. |
| 17 | |
| 18 | Args: |
| 19 | job: instance of server_job. |
| 20 | |
| 21 | Returns: |
| 22 | keyval dictionary with new hostname value, or empty dictionary. |
| 23 | """ |
| 24 | site_job_data = {} |
| 25 | # Only modify hostname on multimachine jobs. Assume all host have the same |
| 26 | # platform. |
| 27 | if len(job.machines) > 1: |
| 28 | # Search through machines for first machine with a platform. |
| 29 | for host in job.machines: |
| 30 | keyval_path = os.path.join(job.resultdir, 'host_keyvals', host) |
| 31 | keyvals = utils.read_keyval(keyval_path) |
| 32 | host_plat = keyvals.get('platform', None) |
| 33 | if not host_plat: |
| 34 | continue |
| 35 | site_job_data['hostname'] = host_plat |
| 36 | break |
| 37 | return site_job_data |
| 38 | |
| 39 | |
| 40 | class site_server_job(object): |
| 41 | pass |