Add the ability to clear out known hosts file for a specific host, and
for all hosts in a job.

This is useful when we reinstall the machine to reduce the "REMOTE HOST
IDENTIFICATION HAS CHANGED" spam warnings.

Signed-off-by: Girts Folkmanis <[email protected]>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4435 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/server_job.py b/server/server_job.py
index 86a6f32..40489e4 100644
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -13,6 +13,7 @@
 from autotest_lib.client.common_lib import error, log, utils, packages
 from autotest_lib.client.common_lib import logging_manager
 from autotest_lib.server import test, subcommand, profilers
+from autotest_lib.server.hosts import abstract_ssh
 from autotest_lib.tko import db as tko_db, status_lib, utils as tko_utils
 
 
@@ -1142,6 +1143,13 @@
         self._state.discard_namespace('client')
 
 
+    def clear_all_known_hosts(self):
+        """Clears known hosts files for all AbstractSSHHosts."""
+        for host in self.hosts:
+            if isinstance(host, abstract_ssh.AbstractSSHHost):
+                host.clear_known_hosts()
+
+
 site_server_job = utils.import_site_class(
     __file__, "autotest_lib.server.site_server_job", "site_server_job",
     base_server_job)