[autotest] Add a 'repair_hosts' command.

We have a `reverify_hosts` command for triggering Verify tasks, but
nothing for triggering Repair tasks.  So, add the command.

BUG=chromium:754362
TEST=Run against a couple of working, idle DUTs in the lab

Change-Id: I9901d9aa5fb3852bd93013e768681e5e259b15c3
Reviewed-on: https://chromium-review.googlesource.com/611252
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
diff --git a/contrib/repair_hosts b/contrib/repair_hosts
new file mode 100755
index 0000000..ee3717e
--- /dev/null
+++ b/contrib/repair_hosts
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+# Simple utility to trigger a Repair job on a bunch of hosts.
+#
+# CAVEAT:  no error checking; if any argument isn't a valid
+# host, it will be silently ignored.  If there are no command
+# line arguments, silently succeed.
+
+import sys
+
+import common
+
+from autotest_lib.server import frontend
+
+# For simplicity, we want to do nothing if there are no hosts named
+# on the command line.  That makes it easy to do stuff like this:
+#     dut-status -b $BOARD -p bvt -n | xargs repair_hosts
+#
+# By doing nothing, we get more useful behavior if all the DUTs selected
+# by `dut-status` are actually working.
+#
+# Note that we have to specifically test for an empty host list: I
+# _think_ (but I don't know) that the AFE calls operate on all the
+# hosts if there are no arguments given.  I do know for certain that
+# with hostnames=[], the call takes longer than I was willing to
+# wait.
+
+if len(sys.argv) >= 2:
+    frontend.AFE().repair_hosts(hostnames=sys.argv[1:])