reviewed list options parsing
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 21 Sep 2010 10:08:30 +0000 (12:08 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 21 Sep 2010 10:08:30 +0000 (12:08 +0200)
dismantled svn keywords
added copyright notice

30 files changed:
system/LocalTestResources.sample.inria
system/TestApiserver.py
system/TestBox.py
system/TestKey.py
system/TestMain.py
system/TestMapper.py
system/TestNode.py
system/TestPlc.py
system/TestPool.py
system/TestResources.py
system/TestSite.py
system/TestSlice.py
system/TestSliceSfa.py
system/TestSliver.py
system/TestSsh.py
system/TestUser.py
system/TestUserSfa.py
system/Trackers.py
system/config_default.py
system/config_resa.py
system/config_sfa.py [new file with mode: 0644]
system/config_wifilab.py
system/plcsh_stress_test.py
system/step_fresh_install.py
system/tcptest.py
system/template-qemu/qemu-bridge-init
system/template-qemu/qemu-ifup
system/template-qemu/qemu-kill-node
system/template-qemu/qemu-start-node
system/utils.py

index 985bfb6..5357851 100644 (file)
@@ -1,5 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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
index baf8dec..d0cdc8c 100644 (file)
@@ -1,4 +1,6 @@
-# $Id$
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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
index 5bcdf40..9ad138f 100644 (file)
@@ -1,4 +1,6 @@
-# $Id$
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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
index d1af805..7fb508a 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import utils
 import os, os.path
 from TestSsh import TestSsh
index 9a512ff..5e19f7a 100755 (executable)
@@ -1,6 +1,8 @@
 #!/usr/bin/python -u
-# $Id$
 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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) ,
index faaeb00..c0358a5 100644 (file)
@@ -1,5 +1,7 @@
 #
-# Thierry Parmentelat - INRIA Sophia Antipolis 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 #
 # mapper class
 # 
index 81a6014..687b526 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import sys, os, os.path, time, base64
 import xmlrpclib
 
index 546ba5d..3e7970d 100644 (file)
@@ -1,4 +1,6 @@
-# $Id$
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import os, os.path
 import datetime
 import time
index b18777c..87e1b97 100644 (file)
@@ -1,5 +1,7 @@
 #
-# Thierry Parmentelat - INRIA Sophia Antipolis 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 #
 # pool class
 # 
index c7a298b..bc928ac 100644 (file)
@@ -1,7 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
 #
-# $Id$
-#
-
 import sys
 import traceback
 
index ca2977f..32af2a9 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import os.path
 import datetime
 import time
index 0de8d3e..3dc57db 100644 (file)
@@ -1,6 +1,5 @@
-#
-# $Id$
-# $URL$
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
 #
 import utils
 import os, os.path
index 9542db4..281df58 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import utils
 import os, os.path
 import datetime
index cde09e8..0d5ab64 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import utils
 import os, os.path
 import datetime
index 6d721fa..1028a18 100644 (file)
@@ -1,5 +1,5 @@
-#
-# Thierry Parmentelat - INRIA
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
 #
 # class for issuing commands on a box, either local or remote
 #
index 8170601..23f01a4 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import os, sys, time
 import xmlrpclib
 
index a460f78..e578c08 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import os, sys, time
 import xmlrpclib
 
index 29cff12..de26b31 100644 (file)
@@ -1,6 +1,8 @@
 #!/usr/bin/python
-# $Id$
 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import os
 
 import utils
index cc642dc..f283b6b 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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  ["""<record hrn="%s" type="slice" description="SFA-testing" url="http://anil.onelab.eu/"><researcher>%s</researcher></record>"""%(hrn, researcher)]
+    return  ['<record hrn="%s" type="slice" description="SFA-testing" url="http://test.onelab.eu/"><researcher>%s</researcher></record>'%(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 ["""<record email="sfafakeuser1@onelab.eu" enabled="True" first_name="Anil" hrn="%s" last_name="Kumar" name="%s" type="user"><keys>%s</keys><role_ids>20</role_ids><role_ids>10</role_ids><site_ids>1</site_ids><roles>pi</roles><roles>admin</roles><sites>plc.main</sites></record>"""%(hrn,hrn,public_key)]
+    return ['<record email="sfafakeuser1@onelab.eu" enabled="True" first_name="Fake" hrn="%s" last_name="Sfa" name="%s" type="user"><keys>%s</keys><role_ids>20</role_ids><role_ids>10</role_ids><site_ids>1</site_ids><roles>pi</roles><roles>admin</roles><sites>plc.main</sites></record>'%(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' : """<?xml version="1.0" ?><Rspec><networks><NetSpec name=""",
-             'part2' : "%s"%netspec_name,
-            'part3' : """><nodes><NodeSpec cpu_min="" cpu_pct="" cpu_share="" disk_max="" init_params="" name=\"""",
-            'part4' : "%s"%node_name,
-             'part5' : """\" start_time="" type=""><net_if><IfSpec init_params="" ip_spoof="" max_kbyte="" max_rate="" min_rate="" name="True" type="ipv4"/></net_if></NodeSpec></nodes></NetSpec></networks></Rspec>"""
+    return { 
+        'part1' : '<?xml version="1.0" ?><Rspec><networks><NetSpec name=',
+        'part2' : '%s'%netspec_name,
+        'part3' : '><nodes><NodeSpec cpu_min="" cpu_pct="" cpu_share="" disk_max="" init_params="" name=\"',
+        'part4' : '%s'%node_name,
+        'part5' : '\" start_time="" type=""><net_if><IfSpec init_params="" ip_spoof="" max_kbyte="" max_rate="" min_rate="" name="True" type="ipv4"/></net_if></NodeSpec></nodes></NetSpec></networks></Rspec>',
            }
              
 def config (plc_specs,options):
index 9cb53a0..27b2c76 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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 (file)
index 0000000..8b6d918
--- /dev/null
@@ -0,0 +1,10 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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)
+    
index 85f26bc..fa519df 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 # a configuration module is expected:
 # (*) to define a config method
 # (*) that takes two arguments
index ef862bc..3d17b97 100755 (executable)
@@ -5,8 +5,6 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 from pprint import pprint
 from string import letters, digits, punctuation, whitespace
index 399e893..a402dfd 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 from TestPlc import TestPlc
 
 def run01_uninstall (test_plc):
index 975bc16..e7d9964 100755 (executable)
@@ -1,5 +1,8 @@
 #!/usr/bin/env python
 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import sys
 import time
 from optparse import OptionParser    
index 3d81838..cf21f81 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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
index 936b4b8..c929270 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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
 
index 3b9626b..6fdb161 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/sh
-# $Id$
+#
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 COMMAND=$(basename $0)
 cd $(dirname $0)
 THISNODE=$(basename $(pwd -P) | sed -e s,qemu-,,)
index 4252725..acaa0e6 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/bash
-# $Id$
 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# 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
index 9098b14..d6938bf 100644 (file)
@@ -1,4 +1,6 @@
-# $Id$
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import time, os, re, glob, sys
 from pprint import PrettyPrinter