make check_slice silent for the silent period
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 15 Jan 2010 10:23:16 +0000 (10:23 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 15 Jan 2010 10:23:16 +0000 (10:23 +0000)
system/TestPlc.py
system/TestSlice.py
system/utils.py

index d979e4f..c593e4d 100644 (file)
@@ -750,18 +750,7 @@ class TestPlc:
                 # try to run 'hostname' in the node
                 command = TestSsh (hostname,key=local_key).actual_command("hostname;uname -a")
                 # don't spam logs - show the command only after the grace period 
-                if datetime.datetime.now() > graceout:
-                    success=utils.system(command)
-                else:
-                    # truly silent, just print out a dot to show we're alive
-                    print '.',
-                    sys.stdout.flush()
-                    command += " 2>/dev/null"
-                    if self.options.dry_run:
-                        print 'dry_run',command
-                        success=0
-                    else:
-                        success=os.system(command)
+                success = utils.system ( command, silent=datetime.datetime.now() < graceout)
                 if success==0:
                     utils.header('Successfully entered root@%s (%s)'%(hostname,message))
                     # refresh tocheck
index 24794b0..2676bc7 100644 (file)
@@ -1,3 +1,7 @@
+#
+# $Id$
+# $URL$
+#
 import utils
 import os, os.path
 import datetime
@@ -99,10 +103,8 @@ class TestSlice:
             for hostname in tocheck:
                 (site_spec,node_spec) = self.test_plc.locate_hostname(hostname)
                 date_test_ssh = TestSsh (hostname,key=remote_privatekey,username=self.name())
-                if datetime.datetime.now() >= graceout:
-                    utils.header('Trying to enter into slice %s@%s'%(self.name(),hostname))
-                # this can be ran locally as we have the key
-                date = date_test_ssh.run("echo hostname ; hostname; echo id; id; echo uname -a ; uname -a")==0
+                command = date_test_ssh.actual_command("echo hostname ; hostname; echo id; id; echo uname -a ; uname -a")
+                date = utils.system (command, silent=datetime.datetime.now() < graceout)
                 if date:
                     utils.header("Successfuly entered slice %s on %s"%(self.name(),hostname))
                     tocheck.remove(hostname)
index 22eb885..19113b0 100644 (file)
@@ -20,17 +20,22 @@ def pprint(message,spec,depth=2):
 
 
 
-def system(command,background=False):
-    if background: command += " &"
+def system(command,background=False,silent=False):
     if options.dry_run:
         print 'dry_run:',command
         return 0
+    
+    if silent :    command += "2> /dev/null"
+    if background: command += " &"
+    if silent:
+        print '.',
+        sys.stdout.flush()
     else:
         now=time.strftime("%H:%M:%S", time.localtime())
         # don't show in summary
         print "->",now,'--',
         sys.stdout.flush()
-        return os.system("set -x; " + command)
+    return os.system("set -x; " + command)
 
 ### WARNING : this ALWAYS does its job, even in dry_run mode
 def output_of (command):