Autotest AFE: Replace Reinstall button with Repair.

It is sometimes useful to kick off a repair job from the AFE, added
a new repair button to the host info page.

BUG=chromium:39213
TEST=compiled locally and verified that when I click repair a repair
     job is kicked off. Also added a new unittest and ensured the old
     ones still worked.

Change-Id: I71533987eb353e52b2b7fd32725adf00df017bc9
Reviewed-on: https://gerrit.chromium.org/gerrit/43975
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Simran Basi <sbasi@chromium.org>
Tested-by: Simran Basi <sbasi@chromium.org>
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index c578589..57eea88 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -592,18 +592,36 @@
         queue_entry.abort()
 
 
+def _call_special_tasks_on_hosts(task, hosts):
+    """\
+    Schedules a set of hosts for a special task.
+
+    @returns A list of hostnames that a special task was created for.
+    """
+    models.AclGroup.check_for_acl_violation_hosts(hosts)
+    for host in hosts:
+        models.SpecialTask.schedule_special_task(host, task)
+    return list(sorted(host.hostname for host in hosts))
+
+
 def reverify_hosts(**filter_data):
     """\
     Schedules a set of hosts for verify.
 
     @returns A list of hostnames that a verify task was created for.
     """
-    hosts = models.Host.query_objects(filter_data)
-    models.AclGroup.check_for_acl_violation_hosts(hosts)
-    for host in hosts:
-        models.SpecialTask.schedule_special_task(host,
-                                                 models.SpecialTask.Task.VERIFY)
-    return list(sorted(host.hostname for host in hosts))
+    return _call_special_tasks_on_hosts(models.SpecialTask.Task.VERIFY,
+            models.Host.query_objects(filter_data))
+
+
+def repair_hosts(**filter_data):
+    """\
+    Schedules a set of hosts for repair.
+
+    @returns A list of hostnames that a repair task was created for.
+    """
+    return _call_special_tasks_on_hosts(models.SpecialTask.Task.REPAIR,
+            models.Host.query_objects(filter_data))
 
 
 def get_jobs(not_yet_run=False, running=False, finished=False, **filter_data):