From: Thierry Parmentelat Date: Tue, 21 Sep 2010 10:08:30 +0000 (+0200) Subject: reviewed list options parsing X-Git-Tag: tests-5.0-16~9 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=acc29368268d995c2965a917409dba89d2373397;p=tests.git reviewed list options parsing dismantled svn keywords added copyright notice --- diff --git a/system/LocalTestResources.sample.inria b/system/LocalTestResources.sample.inria index 985bfb6..5357851 100644 --- a/system/LocalTestResources.sample.inria +++ b/system/LocalTestResources.sample.inria @@ -1,5 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA # -# $Id: LocalTestResources.sample.inria 17428 2010-03-22 11:56:23Z thierry $ # # this is only an example file # the actual file is installed in your testmaster box as /root/LocalTestResources.py diff --git a/system/TestApiserver.py b/system/TestApiserver.py index baf8dec..d0cdc8c 100644 --- a/system/TestApiserver.py +++ b/system/TestApiserver.py @@ -1,4 +1,6 @@ -# $Id$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # wrapper to xmlrpc server, that support dry-run commands # we dont want to have to depend on PLCAPI, so: import xmlrpclib diff --git a/system/TestBox.py b/system/TestBox.py index 5bcdf40..9ad138f 100644 --- a/system/TestBox.py +++ b/system/TestBox.py @@ -1,4 +1,6 @@ -# $Id$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # this models a box that hosts qemu nodes # could probably also be used for boxes that host plc instances import os.path diff --git a/system/TestKey.py b/system/TestKey.py index d1af805..7fb508a 100644 --- a/system/TestKey.py +++ b/system/TestKey.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import utils import os, os.path from TestSsh import TestSsh diff --git a/system/TestMain.py b/system/TestMain.py index 9a512ff..5e19f7a 100755 --- a/system/TestMain.py +++ b/system/TestMain.py @@ -1,6 +1,8 @@ #!/usr/bin/python -u -# $Id$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import sys, os, os.path from optparse import OptionParser import traceback @@ -18,7 +20,7 @@ import LocalTestResources class TestMain: - subversion_id = "$Id$" + subversion_id = "Now using git -- version tracker broken" default_config = [ 'default' ] @@ -58,13 +60,6 @@ class TestMain: except: print "*** no doc found" - @staticmethod - def optparse_list (option, opt, value, parser): - try: - setattr(parser.values,option.dest,getattr(parser.values,option.dest)+value.split()) - except: - setattr(parser.values,option.dest,value.split()) - def run (self): self.init_steps() usage = """usage: %%prog [options] steps @@ -83,8 +78,7 @@ steps refer to a method in TestPlc or to a step_* module help="URL of the arch-dependent RPMS area - for locating what to test") parser.add_option("-b","--build",action="store", dest="build_url", help="ignored, for legacy only") - parser.add_option("-c","--config",action="callback", callback=TestMain.optparse_list, dest="config", - nargs=1,type="string", + parser.add_option("-c","--config",action="append", dest="config", default=[], help="Config module - can be set multiple times, or use quotes") parser.add_option("-p","--personality",action="store", dest="personality", help="personality - as in vbuild-nightly") @@ -92,21 +86,17 @@ steps refer to a method in TestPlc or to a step_* module help="pldistro - as in vbuild-nightly") parser.add_option("-f","--fcdistro",action="store", dest="fcdistro", help="fcdistro - as in vbuild-nightly") - parser.add_option("-x","--exclude",action="callback", callback=TestMain.optparse_list, dest="exclude", - nargs=1,type="string",default=[], + parser.add_option("-x","--exclude",action="append", dest="exclude", default=[], help="steps to exclude - can be set multiple times, or use quotes") parser.add_option("-a","--all",action="store_true",dest="all_steps", default=False, help="Run all default steps") parser.add_option("-l","--list",action="store_true",dest="list_steps", default=False, help="List known steps") - parser.add_option("-N","--nodes",action="callback", callback=TestMain.optparse_list, dest="ips_node", - nargs=1,type="string", + parser.add_option("-N","--nodes",action="append", dest="ips_node", default=[], help="Specify the set of hostname/IP's to use for nodes") - parser.add_option("-P","--plcs",action="callback", callback=TestMain.optparse_list, dest="ips_plc", - nargs=1,type="string", + parser.add_option("-P","--plcs",action="append", dest="ips_plc", default=[], help="Specify the set of hostname/IP's to use for plcs") - parser.add_option("-Q","--qemus",action="callback", callback=TestMain.optparse_list, dest="ips_qemu", - nargs=1,type="string", + parser.add_option("-Q","--qemus",action="append", dest="ips_qemu", default=[], help="Specify the set of hostname/IP's to use for qemu boxes") parser.add_option("-s","--size",action="store",type="int",dest="size",default=1, help="sets test size in # of plcs - default is 1") @@ -125,6 +115,19 @@ steps refer to a method in TestPlc or to a step_* module help="Trace file location") (self.options, self.args) = parser.parse_args() + # allow things like "run -c 'c1 c2' -c c3" + def flatten (x): + result = [] + for el in x: + if hasattr(el, "__iter__") and not isinstance(el, basestring): + result.extend(flatten(el)) + else: + result.append(el) + return result + # flatten relevant options + for optname in ['config','exclude','ips_node','ips_plc','ips_qemu']: + setattr(self.options,optname, flatten ( [ arg.split() for arg in getattr(self.options,optname) ] )) + # handle defaults and option persistence for (recname,filename,default) in ( ('build_url','arg-build-url',TestMain.default_build_url) , diff --git a/system/TestMapper.py b/system/TestMapper.py index faaeb00..c0358a5 100644 --- a/system/TestMapper.py +++ b/system/TestMapper.py @@ -1,5 +1,7 @@ # -# Thierry Parmentelat - INRIA Sophia Antipolis +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # # mapper class # diff --git a/system/TestNode.py b/system/TestNode.py index 81a6014..687b526 100644 --- a/system/TestNode.py +++ b/system/TestNode.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import sys, os, os.path, time, base64 import xmlrpclib diff --git a/system/TestPlc.py b/system/TestPlc.py index 546ba5d..3e7970d 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -1,4 +1,6 @@ -# $Id$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import os, os.path import datetime import time diff --git a/system/TestPool.py b/system/TestPool.py index b18777c..87e1b97 100644 --- a/system/TestPool.py +++ b/system/TestPool.py @@ -1,5 +1,7 @@ # -# Thierry Parmentelat - INRIA Sophia Antipolis +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # # pool class # diff --git a/system/TestResources.py b/system/TestResources.py index c7a298b..bc928ac 100644 --- a/system/TestResources.py +++ b/system/TestResources.py @@ -1,7 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA # -# $Id$ -# - import sys import traceback diff --git a/system/TestSite.py b/system/TestSite.py index ca2977f..32af2a9 100644 --- a/system/TestSite.py +++ b/system/TestSite.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import os.path import datetime import time diff --git a/system/TestSlice.py b/system/TestSlice.py index 0de8d3e..3dc57db 100644 --- a/system/TestSlice.py +++ b/system/TestSlice.py @@ -1,6 +1,5 @@ -# -# $Id$ -# $URL$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA # import utils import os, os.path diff --git a/system/TestSliceSfa.py b/system/TestSliceSfa.py index 9542db4..281df58 100644 --- a/system/TestSliceSfa.py +++ b/system/TestSliceSfa.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import utils import os, os.path import datetime diff --git a/system/TestSliver.py b/system/TestSliver.py index cde09e8..0d5ab64 100644 --- a/system/TestSliver.py +++ b/system/TestSliver.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import utils import os, os.path import datetime diff --git a/system/TestSsh.py b/system/TestSsh.py index 6d721fa..1028a18 100644 --- a/system/TestSsh.py +++ b/system/TestSsh.py @@ -1,5 +1,5 @@ -# -# Thierry Parmentelat - INRIA +# Thierry Parmentelat +# Copyright (C) 2010 INRIA # # class for issuing commands on a box, either local or remote # diff --git a/system/TestUser.py b/system/TestUser.py index 8170601..23f01a4 100644 --- a/system/TestUser.py +++ b/system/TestUser.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import os, sys, time import xmlrpclib diff --git a/system/TestUserSfa.py b/system/TestUserSfa.py index a460f78..e578c08 100644 --- a/system/TestUserSfa.py +++ b/system/TestUserSfa.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import os, sys, time import xmlrpclib diff --git a/system/Trackers.py b/system/Trackers.py index 29cff12..de26b31 100644 --- a/system/Trackers.py +++ b/system/Trackers.py @@ -1,6 +1,8 @@ #!/usr/bin/python -# $Id$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import os import utils diff --git a/system/config_default.py b/system/config_default.py index cc642dc..f283b6b 100644 --- a/system/config_default.py +++ b/system/config_default.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # a configuration module is expected: # (*) to define a config method # (*) that takes two arguments @@ -292,7 +295,7 @@ def sfa_slice_xml(options,index): hrn='ple.main.fslc1' researcher='ple.main.fake-pi1' - return ["""%s"""%(hrn, researcher)] + return ['%s'%(hrn, researcher)] def sfa_person_xml(options,index): if index==1: @@ -300,7 +303,7 @@ def sfa_person_xml(options,index): else: hrn='ple.main.sfafakeuser1' - return ["""%s20101piadminplc.main"""%(hrn,hrn,public_key)] + return ['%s20101piadminplc.main'%(hrn,hrn,public_key)] def sfa_slice_rspec(options,index): node_name='deferred' @@ -309,11 +312,12 @@ def sfa_slice_rspec(options,index): else: netspec_name='\"ple\"' - return { 'part1' : """""" + return { + 'part1' : '', } def config (plc_specs,options): diff --git a/system/config_resa.py b/system/config_resa.py index 9cb53a0..27b2c76 100644 --- a/system/config_resa.py +++ b/system/config_resa.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # a configuration module is expected: # (*) to define a config method # (*) that takes two arguments diff --git a/system/config_sfa.py b/system/config_sfa.py new file mode 100644 index 0000000..8b6d918 --- /dev/null +++ b/system/config_sfa.py @@ -0,0 +1,10 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# +# just overwrite options.size to be 2 and re-use the default config +import config_default + +def config (plc_specs, options): + options.size=2 + return config_default.config(plc_specs,options) + diff --git a/system/config_wifilab.py b/system/config_wifilab.py index 85f26bc..fa519df 100644 --- a/system/config_wifilab.py +++ b/system/config_wifilab.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # a configuration module is expected: # (*) to define a config method # (*) that takes two arguments diff --git a/system/plcsh_stress_test.py b/system/plcsh_stress_test.py index ef862bc..3d17b97 100755 --- a/system/plcsh_stress_test.py +++ b/system/plcsh_stress_test.py @@ -5,8 +5,6 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id$ -# from pprint import pprint from string import letters, digits, punctuation, whitespace diff --git a/system/step_fresh_install.py b/system/step_fresh_install.py index 399e893..a402dfd 100644 --- a/system/step_fresh_install.py +++ b/system/step_fresh_install.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# from TestPlc import TestPlc def run01_uninstall (test_plc): diff --git a/system/tcptest.py b/system/tcptest.py index 975bc16..e7d9964 100755 --- a/system/tcptest.py +++ b/system/tcptest.py @@ -1,5 +1,8 @@ #!/usr/bin/env python +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import sys import time from optparse import OptionParser diff --git a/system/template-qemu/qemu-bridge-init b/system/template-qemu/qemu-bridge-init index 3d81838..cf21f81 100755 --- a/system/template-qemu/qemu-bridge-init +++ b/system/template-qemu/qemu-bridge-init @@ -1,5 +1,8 @@ #!/bin/bash +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # Establishment of a runtime environment for a # virtual machine under QEMU, This script allows the host box # to share its network connection with qemu-based guests diff --git a/system/template-qemu/qemu-ifup b/system/template-qemu/qemu-ifup index 936b4b8..c929270 100755 --- a/system/template-qemu/qemu-ifup +++ b/system/template-qemu/qemu-ifup @@ -1,5 +1,8 @@ #!/bin/bash +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # this is the script provided to the qemu command-line, that qemu invokes to init the net device # basically this adds the interface to the bridge diff --git a/system/template-qemu/qemu-kill-node b/system/template-qemu/qemu-kill-node index 3b9626b..6fdb161 100755 --- a/system/template-qemu/qemu-kill-node +++ b/system/template-qemu/qemu-kill-node @@ -1,5 +1,8 @@ #!/bin/sh -# $Id$ +# +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# COMMAND=$(basename $0) cd $(dirname $0) THISNODE=$(basename $(pwd -P) | sed -e s,qemu-,,) diff --git a/system/template-qemu/qemu-start-node b/system/template-qemu/qemu-start-node index 4252725..acaa0e6 100755 --- a/system/template-qemu/qemu-start-node +++ b/system/template-qemu/qemu-start-node @@ -1,6 +1,8 @@ #!/bin/bash -# $Id$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # it does the following: # (*) close all file descriptors and redirect output to log.txt # this is because it is designed for use through ssh from a remote test master controller diff --git a/system/utils.py b/system/utils.py index 9098b14..d6938bf 100644 --- a/system/utils.py +++ b/system/utils.py @@ -1,4 +1,6 @@ -# $Id$ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import time, os, re, glob, sys from pprint import PrettyPrinter