[Ocfs2-test-devel] [PATCH 03/11] python_common
Marcos Matsunaga
Marcos.Matsunaga at oracle.com
Wed Jun 23 21:19:52 PDT 2010
ocfs2-test: changed to accept an alternate NIC to be used by the test.
- on untar fucntion, created an option to separate the extraction logfile
from the general logfile. This is to try to keep the general logfile
clean.
- added the option to use an alternate network interface to remote_umount.py
and remote_mount.py
- added the option to use specify remote access method to remote_umount.py
and remote_mount.py
- Made remote_mount.py and remote_umount.py accept the remote communication
method. ssh or rsh are valid.
- Added Tristan description of the -i argument.
Signed-off-by: Marcos Matsunaga <Marcos.Matsunaga at oracle.com>
---
programs/python_common/o2tf.py | 37 +++++++++++++++++++++----------
programs/python_common/remote_mount.py | 28 +++++++++++++++++++++--
programs/python_common/remote_umount.py | 27 +++++++++++++++++++++-
3 files changed, 75 insertions(+), 17 deletions(-)
diff --git a/programs/python_common/o2tf.py b/programs/python_common/o2tf.py
index df060cb..69081bf 100644
--- a/programs/python_common/o2tf.py
+++ b/programs/python_common/o2tf.py
@@ -18,7 +18,7 @@
#
# o2tf - OCFS2 Tests Functions.
#
-import os, sys, signal, string, popen2, socket, time, pdb, shutil, platform
+import os, sys, signal, string, socket, time, pdb, shutil, platform
import config, stat, os.path
#from log import log
# Set time executable to use.
@@ -130,7 +130,7 @@ def extract_tar(DEBUGON, logfile, dirl, tarfile):
% wdir, logfile, 0, '')
os.mkdir(wdir)
os.chdir(wdir)
- untar(DEBUGON, wdir, tarfile, logfile)
+ untar(DEBUGON, wdir, tarfile, logfile, '1')
#
# CreateDir is used by :
# - o2tf.py
@@ -162,7 +162,7 @@ def CreateDir(DEBUGON, dirl, logfile):
#
# untar is used by :
# - o2tf.py
-def untar(DEBUGON, destdir, tarfile, logfile):
+def untar(DEBUGON, destdir, tarfile, logfile, quiet):
'Untar into a destdir, the tarfile, logging the output into a logfile'
'For the moment, it only works with compressed tar files.'
if DEBUGON:
@@ -174,19 +174,27 @@ def untar(DEBUGON, destdir, tarfile, logfile):
options = 'xvf'
compress = 'z'
st = os.stat(destdir)
+ logdate = str(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()))
+ arch = str(platform.machine())
if stat.S_ISREG(st.st_mode):
o2tf.printlog('o2tf.untar: (%s) is a regular file. Can\'t \
extract tarfile into a regular file.' % \
destdir, logfile, 0, '')
else:
- if DEBUGON:
- printlog('o2tf.untar: Extracting tar file %s into %s \
- directory.' % (tarfile, destdir),
- logfile, 0, '')
+ printlog('o2tf.untar: Extracting tar file %s into %s \
+ directory.' % (tarfile, destdir),
+ logfile, 0, '')
+ if quiet == '1':
+ tlogfile = os.path.join(dirlog,logdate+'_untar_'+arch+'_'+nodename)
+ else:
+ tlogfile = logfile
+ printlog('o2tf.untar: Extraction logfile at %s ' % logfile,
+ logfile, 0, '')
+
t1 = time.time()
os.system('cd %s; tar %s %s 2>&1 1>> %s; du -sh * 1>> %s' % \
- (destdir, options + compress, tarfile, logfile,
- logfile))
+ (destdir, options + compress, tarfile, tlogfile,
+ tlogfile))
t2 = time.time()
printlog('o2tf.untar: Extraction elapsed time = %s' % \
(t2 - t1), logfile, 0, '')
@@ -236,7 +244,7 @@ so just do a sanity check here to test if all nodes are available.
#
# Calls mpirun from openmpi
#
-def openmpi_run(DEBUGON, nproc, cmd, nodes, remote_sh, logfile, w_flag):
+def openmpi_run(DEBUGON, nproc, cmd, nodes, remote_sh, interface, logfile, w_flag):
"""
Execute commands in parallel using OpenMPI.'
"""
@@ -251,6 +259,11 @@ def openmpi_run(DEBUGON, nproc, cmd, nodes, remote_sh, logfile, w_flag):
else:
nprocopt='-np ' + str(nproc)
+ if not interface:
+ iface = ''
+ else:
+ iface = '-mca btl_tcp_if_include '+interface
+
if remote_sh == '' or remote_sh == 'ssh':
shopt = '-mca plm_rsh_agent ssh:rsh'
else:
@@ -269,8 +282,8 @@ def openmpi_run(DEBUGON, nproc, cmd, nodes, remote_sh, logfile, w_flag):
logfile, 0, '')
pid = os.spawnv(os.P_NOWAIT,
'/bin/bash', ['bash', '-xc',
- config.MPIRUN + ' -mca btl tcp,self %s %s --host %s %s' % \
- (shopt, nprocopt, nodes, cmd)])
+ config.MPIRUN + ' -mca btl tcp,self %s %s %s --host %s %s' % \
+ (shopt, iface, nprocopt, nodes, cmd)])
if w_flag == 'NOWAIT':
return pid
else:
diff --git a/programs/python_common/remote_mount.py b/programs/python_common/remote_mount.py
index c688cf0..7520405 100755
--- a/programs/python_common/remote_mount.py
+++ b/programs/python_common/remote_mount.py
@@ -35,7 +35,8 @@ DEBUGON = os.getenv('DEBUG',0)
userid = pwd.getpwuid(os.getuid())[0]
logfile = config.LOGFILE
#
-Usage = 'Usage: %prog [-l|-label label] \
+Usage = 'Usage: %prog [-i|--if <Network Interface>] \
+[-l|-label label] \
[-m|--mountpoint mountpoint] \
[-n|--nodes nodelist] \
[-o|--options mountoptions]'
@@ -47,6 +48,12 @@ if userid == 'root':
if __name__=='__main__':
parser = optparse.OptionParser(Usage)
#
+ parser.add_option('-i',
+ '--if',
+ dest='interface',
+ type='string',
+ help='Network Interface name to be used for MPI messaging.')
+#
parser.add_option('-l',
'--label',
dest='label',
@@ -64,13 +71,19 @@ if __name__=='__main__':
dest='nodelist',
type='string',
help='List of nodes where the test will be executed.')
-
+#
parser.add_option('-o',
'--options',
dest='mountoptions',
type='string',
help='Mounting options to be added.')
#
+ parser.add_option('-s',
+ '--shell',
+ dest='remote_method',
+ type='string',
+ help='Remote access method <ssh|rsh>.')
+#
(options, args) = parser.parse_args()
if len(args) != 0:
parser.error('incorrect number of arguments')
@@ -85,6 +98,14 @@ if __name__=='__main__':
else:
mt_options = ''
#
+ if not options.remote_method:
+ remote_method = 'ssh'
+ else:
+ if options.remote_method == 'ssh' or options.remote_method == 'rsh':
+ remote_method = options.remote_method
+ else:
+ parser.error('Invalid option. Choose ssh or rsh')
+#
nodelist = options.nodelist.split(',')
nodelen = len(nodelist)
if nodelen == 1:
@@ -111,7 +132,8 @@ ret = o2tf.openmpi_run(DEBUGON,
nproc,
str('%s' % command),
options.nodelist,
- 'ssh',
+ remote_method,
+ options.interface,
logfile,
'WAIT')
diff --git a/programs/python_common/remote_umount.py b/programs/python_common/remote_umount.py
index 7b8f24d..915b11e 100755
--- a/programs/python_common/remote_umount.py
+++ b/programs/python_common/remote_umount.py
@@ -35,7 +35,8 @@ DEBUGON = os.getenv('DEBUG',0)
userid = pwd.getpwuid(os.getuid())[0]
logfile = config.LOGFILE
#
-Usage = 'Usage: %prog [-m|--mountpoint mountpoint] \
+Usage = 'Usage: %prog [-i|--if <Network Interface>] \
+[-m|--mountpoint mountpoint] \
[-n|--nodes nodelist]'
#
if userid == 'root':
@@ -45,6 +46,12 @@ if userid == 'root':
if __name__=='__main__':
parser = optparse.OptionParser(Usage)
#
+ parser.add_option('-i',
+ '--if',
+ dest='interface',
+ type='string',
+ help='Network Interface name to be used for MPI messaging.')
+#
parser.add_option('-m',
'--mountpoint',
dest='mountpoint',
@@ -57,6 +64,12 @@ if __name__=='__main__':
type='string',
help='List of nodes where the test will be executed.')
#
+ parser.add_option('-s',
+ '--shell',
+ dest='remote_method',
+ type='string',
+ help='Remote access method <ssh|rsh>.')
+#
(options, args) = parser.parse_args()
if len(args) != 0:
parser.error('incorrect number of arguments')
@@ -65,6 +78,14 @@ if __name__=='__main__':
if not options.mountpoint:
parser.error('Please specify mountpoint.')
#
+ if not options.remote_method:
+ remote_method = 'ssh'
+ else:
+ if options.remote_method == 'ssh' or options.remote_method == 'rsh':
+ remote_method = options.remote_method
+ else:
+ parser.error('Invalid option. Choose ssh or rsh')
+#
nodelist = options.nodelist.split(',')
nodelen = len(nodelist)
if nodelen == 1:
@@ -89,7 +110,9 @@ ret = o2tf.openmpi_run(DEBUGON,
nproc,
str('%s' % command),
options.nodelist,
- 'ssh', logfile,
+ remote_method,
+ options.interface,
+ logfile,
'WAIT')
if ret:
--
1.5.6.5
More information about the Ocfs2-test-devel
mailing list