blob: c7a21caf3ab48d983a2826ac4d2ea2136cd5d996 [file] [log] [blame]
# Takes a list of hostnames (via file) and schedules host repair
# jobs based on the delay specified in order to throttle the jobs
# and not overwhelm the system.
import argparse
import sys
import common
import time
from autotest_lib.server import frontend
def GetParser():
"""Creates the argparse parser."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--input', type=str, action='store',
help='File with hostnames to repair')
parser.add_argument('--delay_seconds', type=int, action='store', default=5,
help='Delay between scheduling repair jobs')
return parser
def main(argv):
parser = GetParser()
options = parser.parse_args(argv)
afe = frontend.AFE()
with open(options.input) as input:
hostnames = input.readlines()
remaining = len(hostnames)
delay = options.delay_seconds
print "Scheduling %d repairs with %s delay in seconds" \
% (remaining, delay)
for hostname in hostnames:
hostname = hostname.strip()
remaining = remaining - 1
print "%s host repair scheduled with %d remaining" \
% (hostname, remaining)
if __name__ == '__main__':