1#!/usr/bin/python3 2 3""" 4Send all Repair Failed hosts that the user running this script has access to 5back into Verifying. (Only hosts ACL accessable to the user) 6 7Suggested use: Run this as an occasional cron job to re-check if Repair Failed 8hosts have overcome whatever issue caused the failure and are useful again. 9""" 10 11from __future__ import absolute_import 12from __future__ import division 13from __future__ import print_function 14 15import optparse, os, sys 16 17import common 18from autotest_lib.server import frontend 19 20 21def main(): 22 parser = optparse.OptionParser(usage='%prog [options]\n\n' + 23 __doc__.strip()) 24 parser.add_option('-w', dest='server', default='autotest', 25 help='Hostname of the autotest frontend RPC server.') 26 parser.add_option('-b', dest='label', default=None, type=str, 27 help='A label to restrict the set of hosts reverified.') 28 options, unused_args = parser.parse_args(sys.argv) 29 30 afe_client = frontend.AFE(debug=False, server=options.server) 31 hostnames = afe_client.reverify_hosts(status='Repair Failed', 32 label=options.label) 33 # The old RPC interface didn't return anything. 34 # A more recent one returns a list of hostnames to make this message useful. 35 if hostnames: 36 print('The following Repair Failed hosts on', options.server, end=' ') 37 print('will be reverified:') 38 print(' '.join(hostnames)) 39 else: 40 print('Repair Failed hosts on', options.server, 'will be reverified.') 41 42 43if __name__ == '__main__': 44 main() 45