| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 | |
| 7 """Update the buildbot checkouts for each buildslave on every host. | |
| 8 | |
| 9 This differs from UpdateScripts in that it updates ALL of the buildbot script | |
| 10 checkouts for ALL buildslaves, as opposed to a single buildslave's checkout of | |
| 11 the buildbot scripts on a single host machine. | |
| 12 """ | |
| 13 | |
| 14 | |
| 15 import re | |
| 16 import skia_vars | |
| 17 import sys | |
| 18 | |
| 19 from build_step import BuildStep, BuildStepWarning | |
| 20 from scripts import run_cmd | |
| 21 from utils import force_update_checkout | |
| 22 | |
| 23 | |
| 24 BUILDBOT_GIT_URL = skia_vars.GetGlobalVariable('buildbot_git_url') | |
| 25 | |
| 26 | |
| 27 class UpdateAllBuildslaves(BuildStep): | |
| 28 def _Run(self): | |
| 29 script_path = run_cmd.ResolvablePath('slave', 'skia_slave_scripts', 'utils', | |
| 30 'force_update_checkout.py') | |
| 31 sync_cmd = ['python', script_path] | |
| 32 results = run_cmd.run_on_all_slaves_on_all_hosts(sync_cmd) | |
| 33 failed = [] | |
| 34 for host in results.iterkeys(): | |
| 35 print host | |
| 36 # If results[host] is a MultiCommandResults instance, then we have results | |
| 37 # for buildslaves running on that machine, which implies that we were able | |
| 38 # to log in to the machine successfully. | |
| 39 if isinstance(results[host], run_cmd.MultiCommandResults): | |
| 40 # We successfully logged into the buildslave host machine. | |
| 41 for buildslave in results[host].iterkeys(): | |
| 42 print ' ', buildslave, | |
| 43 # Check and report the results of the command for each buildslave on | |
| 44 # this host machine. | |
| 45 if results[host][buildslave].returncode != 0: | |
| 46 # If the command failed, print its output. | |
| 47 failed.append(buildslave) | |
| 48 print | |
| 49 results[host][buildslave].print_results(pretty=True) | |
| 50 else: | |
| 51 # If the command succeeded, find and print the commit hash we synced | |
| 52 # to. If we can't find it, then something must have failed, so | |
| 53 # print the output and report a failure. | |
| 54 match = re.search( | |
| 55 force_update_checkout.GOT_REVISION_PATTERN % ('(\w+)'), | |
| 56 results[host][buildslave].stdout) | |
| 57 if match: | |
| 58 print '\t%s' % match.group(1) | |
| 59 else: | |
| 60 failed.append(host) | |
| 61 print | |
| 62 results[host][buildslave].print_results(pretty=True) | |
| 63 else: | |
| 64 # We were unable to log into the buildslave host machine. | |
| 65 if results[host].returncode != 0: | |
| 66 failed.append(host) | |
| 67 results[host].print_results(pretty=True) | |
| 68 print | |
| 69 | |
| 70 if failed: | |
| 71 print | |
| 72 print 'Failed to update the following buildslaves:' | |
| 73 for failed_host in failed: | |
| 74 print ' ', failed_host | |
| 75 | |
| 76 if failed: | |
| 77 # TODO(borenet): Make sure that we can log in to all hosts, then make this | |
| 78 # an error. | |
| 79 raise BuildStepWarning('Could not update some buildslaves.') | |
| 80 | |
| 81 | |
| 82 if '__main__' == __name__: | |
| 83 sys.exit(BuildStep.RunBuildStep(UpdateAllBuildslaves)) | |
| OLD | NEW |