From efda9075336780b08465c97892e57064ca922d15 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 15 Jan 2010 10:23:16 +0000 Subject: [PATCH] make check_slice silent for the silent period --- system/TestPlc.py | 13 +------------ system/TestSlice.py | 10 ++++++---- system/utils.py | 11 ++++++++--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/system/TestPlc.py b/system/TestPlc.py index d979e4f..c593e4d 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -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 diff --git a/system/TestSlice.py b/system/TestSlice.py index 24794b0..2676bc7 100644 --- a/system/TestSlice.py +++ b/system/TestSlice.py @@ -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) diff --git a/system/utils.py b/system/utils.py index 22eb885..19113b0 100644 --- a/system/utils.py +++ b/system/utils.py @@ -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): -- 2.43.0