nodenetwork sequels
[tests.git] / system / TestSsh.py
index 81956b0..d392659 100644 (file)
@@ -69,10 +69,12 @@ class TestSsh:
             return "%s@%s"%(self.username,self.hostname)
     
     # command gets run on the right box
-    def actual_command (self, command):
+    def actual_command (self, command,keep_stdin=False):
         if self.is_local():
             return command
         ssh_command = "ssh "
+        if not keep_stdin:
+            ssh_command += "-n "
         ssh_command += TestSsh.std_options
         ssh_command += self.key_part()
         ssh_command += "%s %s" %(self.hostname_part(),TestSsh.backslash_shell_specials(command))
@@ -80,9 +82,7 @@ class TestSsh:
 
     def run(self, command,background=False):
         local_command = self.actual_command(command)
-        if background:
-            local_command += " &"
-        return utils.system(local_command)
+        return utils.system(local_command,background)
 
     def clean_dir (self,dirname):
         if self.is_local():
@@ -140,3 +140,13 @@ class TestSsh:
             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))
+