clears known_hosts for test nodes
[tests.git] / system / TestSsh.py
index 396d4b6..3c61a4b 100644 (file)
@@ -121,9 +121,32 @@ class TestSsh:
             return 0
         self.create_buildname_once()
         scp_command="scp "
+        scp_command += TestSsh.std_options
         if recursive: scp_command += "-r "
         scp_command += self.key_part()
         scp_command += "%s %s:%s/%s"%(local_file,self.hostname_part(),
                                       self.buildname,os.path.basename(local_file) or ".")
         return utils.system(scp_command)
+
+    def fetch (self, remote_file, local_file, recursive=False):
+        if self.is_local():
+            command="cp "
+            if recursive: command += "-r "
+            command += "%s %s"%(remote_file,local_file)
+        else:
+            command="scp "
+            command += TestSsh.std_options
+            if recursive: command += "-r "
+            command += self.key_part()
+            command += "%s:%s/%s %s"%(self.hostname_part(),self.buildname,remote_file,local_file)
+        utils.system(command)
+
+    # this is only to avoid harmless message when host cannot be identified
+    # convenience only
+    # the only place where this is needed is when tring to reach a slice in a node,
+    # which is done from the test master box
+    def clear_known_hosts (self):
+        known_hosts = "%s/.ssh/known_hosts"%os.getenv("HOME")
+        utils.header("Clearing entry for %s in %s"%(self.hostname,known_hosts))
+        utils.system("sed -i -e /^%s/d %s"%(self.hostname,known_hosts))