moving to multi-plcs daily tests
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 24 Nov 2008 10:57:45 +0000 (10:57 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 24 Nov 2008 10:57:45 +0000 (10:57 +0000)
12 files changed:
system/TestMain.py
system/TestMapper.py
system/TestNode.py
system/TestPlc.py
system/TestPool.py
system/TestSlice.py
system/config_1testbox.py
system/config_1vnodes.py
system/config_1vservers.py
system/config_default.py
system/config_main.py
system/utils.py

index 501126e..75c79ff 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python -u
 # $Id$
 
 import sys, os, os.path
@@ -79,10 +79,8 @@ steps refer to a method in TestPlc or to a step_* module
         parser.add_option("-P","--plcs",action="callback", callback=TestMain.optparse_list, dest="ips_plc",
                           nargs=1,type="string",
                           help="Specify the set of IP addresses to use for plcs (scanning disabled)")
-        parser.add_option("-1","--small",action="store_true",dest="small_test",
-                          help="run a small test (default) -- typically only one plc and one node")
-        parser.add_option("-2","--large",action="store_false",dest="small_test",default=True,
-                          help="runs full-size test")
+        parser.add_option("-s","--size",action="store",type="int",dest="size",default=1,
+                          help="sets test size in # of plcs - default is 1")
         parser.add_option("-D","--dbname",action="store",dest="dbname",default=None,
                            help="Used by db_dump and db_restore")
         parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False, 
@@ -99,6 +97,8 @@ steps refer to a method in TestPlc or to a step_* module
                           #default="logs/trace-@TIME@.txt",
                           help="Trace file location")
         (self.options, self.args) = parser.parse_args()
+        if self.options.quiet:
+            self.options.verbose=False
 
         if len(self.args) == 0:
             if self.options.all_steps:
@@ -124,7 +124,7 @@ steps refer to a method in TestPlc or to a step_* module
             ('arch_rpms_url','arg-arch-rpms-url',"") , 
             ('personality','arg-personality',"linux32"),
             ('pldistro','arg-pldistro',"planetlab"),
-            ('fcdistro','arg-fcdistro','f8'),
+            ('fcdistro','arg-fcdistro','centos5'),
             ) :
 #            print 'handling',recname
             path=filename
@@ -147,8 +147,6 @@ steps refer to a method in TestPlc or to a step_* module
                         print "Cannot determine",recname
                         print "Run %s --help for help"%sys.argv[0]                        
                         sys.exit(1)
-            if not self.options.quiet:
-                utils.header('* Using %s = %s'%(recname,getattr(self.options,recname)))
 
             # save for next run
             fsave=open(path,"w")
@@ -160,6 +158,14 @@ steps refer to a method in TestPlc or to a step_* module
             fsave.close()
 #            utils.header('Saved %s into %s'%(recname,filename))
 
+            # lists need be reversed
+            if isinstance(getattr(self.options,recname),list):
+                getattr(self.options,recname).reverse()
+
+            if not self.options.quiet:
+                utils.header('* Using %s = %s'%(recname,getattr(self.options,recname)))
+
+
         if self.options.personality == "linux32":
             self.options.arch = "i386"
         elif self.options.personality == "linux64":
@@ -201,21 +207,17 @@ steps refer to a method in TestPlc or to a step_* module
                 print 'Cannot load config %s -- ignored'%modulename
                 raise
         # remember plc IP address(es) if not specified
-        current=file('arg-ips-plc').read()
-        if not current:
-            ips_plc_file=open('arg-ips-plc','w')
-            for plc_spec in all_plc_specs:
-                ips_plc_file.write("%s\n"%plc_spec['PLC_API_HOST'])
-            ips_plc_file.close()
+        ips_plc_file=open('arg-ips-plc','w')
+        for plc_spec in all_plc_specs:
+            ips_plc_file.write("%s\n"%plc_spec['PLC_API_HOST'])
+        ips_plc_file.close()
         # ditto for nodes
-        current=file('arg-ips-node').read()
-        if not current:
-            ips_node_file=open('arg-ips-node','w')
-            for plc_spec in all_plc_specs:
-                for site_spec in plc_spec['sites']:
-                    for node_spec in site_spec['nodes']:
-                        ips_node_file.write("%s\n"%node_spec['node_fields']['hostname'])
-            ips_node_file.close()
+        ips_node_file=open('arg-ips-node','w')
+        for plc_spec in all_plc_specs:
+            for site_spec in plc_spec['sites']:
+                for node_spec in site_spec['nodes']:
+                    ips_node_file.write("%s\n"%node_spec['node_fields']['hostname'])
+        ips_node_file.close()
         # build a TestPlc object from the result, passing options
         for spec in all_plc_specs:
             spec['disabled'] = False
index 13a0780..8b9e915 100644 (file)
@@ -22,14 +22,21 @@ class TestMapper:
 
     @staticmethod
     def node_name (node):
-        return node['node_fields']['hostname']
+        return node['name']
+
+    def node_names (self):
+        result=[]
+        for plc in self.plcs:
+            for site in plc['sites']:
+                for node in site['nodes']:
+                    result.append(node['name'])
+        return result
 
     def apply_first_map (self, type, name, obj, maplist):
         for (map_pattern,rename_dict) in maplist:
-            if self.options.verbose:
-                print 'dbg: TestMapper/',type,'name=',name,'& pattern=',map_pattern
             if utils.match (name,map_pattern):
-                utils.header("TestMapper/%s : applying rules '%s' on %s"%(type,map_pattern,name))
+                if not self.options.quiet:
+                    utils.header("TestMapper/%s : applying rules '%s' on %s"%(type,map_pattern,name))
                 for (k,v) in rename_dict.iteritems():
                     # apply : separator
                     path=k.split(':')
@@ -38,30 +45,25 @@ class TestMapper:
                     for step in path[:-1]:
                         if not o.has_key(step):
                             o[step]={}
-                            utils.header ("WARNING : created step %s in path %s on %s %s"%(
-                                    step,path,type,name))
+                            if not self.options.quiet:
+                                utils.header ("WARNING : created step %s in path %s on %s %s"%(
+                                        step,path,type,name))
                         o=o[step]
                     # last step is the one for side-effect
                     step=path[-1]
-                    if not o.has_key(step):
-                        utils.header ("WARNING : inserting key %s for path %s on %s %s"%(
-                                step,path,type,name))
+                    if not self.options.quiet:
+                        if not o.has_key(step):
+                            utils.header ("WARNING : inserting key %s for path %s on %s %s"%(
+                                    step,path,type,name))
                     # apply formatting if '%s' found in the value
                     if v.find('%s')>=0:
                         v=v%obj[k]
-                    print("TestMapper, rewriting %s: %s into %s"%(name,k,v))
+                    if not self.options.quiet:
+                        print("TestMapper, rewriting %s: %s into %s"%(name,k,v))
                     o[step]=v
                 # only apply first rule
                 return
 
-    def node_names (self):
-        result=[]
-        for plc in self.plcs:
-            for site in plc['sites']:
-                for node in site['nodes']:
-                    result.append(node['node_fields']['hostname'])
-        return result
-
     def map (self,mapper):
 
         plc_maps  = mapper.get('plc',[])
index 08dd17c..7c06e65 100644 (file)
@@ -236,3 +236,4 @@ class TestNode:
             # xxx - temporary : always return true for now
             #return False
         return True
+
index 6009b7e..88a4a41 100644 (file)
@@ -62,24 +62,29 @@ SEP='<sep>'
 
 class TestPlc:
 
-    default_steps = ['display','uninstall','install','install_rpm', 
-                     'configure', 'start', 'fetch_keys', SEP,
-                     'store_keys', 'clear_known_hosts', 'initscripts', SEP,
-                     'sites', 'nodes', 'slices', 'nodegroups', SEP,
-                     'init_node','bootcd', 'configure_qemu', 'export_qemu',
-                     'kill_all_qemus', 'reinstall_node','start_node', SEP,
-                     'nodes_debug_ssh', 'nodes_boot_ssh', 'check_slice', 'check_initscripts', SEP,
-                     'check_tcp', 'plcsh_stress_test', SEP,
-                     'force_gather_logs', 'force_kill_qemus', 'force_record_tracker','force_free_tracker' ]
-    other_steps = [ 'stop_all_vservers','fresh_install', 'cache_rpm', 'stop', 'vs_start', SEP,
-                    'check_sanity', SEP,
-                    'clean_initscripts', 'clean_nodegroups','clean_all_sites', SEP,
-                    'clean_sites', 'clean_nodes', 
-                    'clean_slices', 'clean_keys', SEP,
-                    'show_boxes', 'list_all_qemus', 'list_qemus', SEP,
-                    'db_dump' , 'db_restore', 'cleanup_trackers', 'cleanup_all_trackers',
-                    'standby_1 through 20'
-                    ]
+    default_steps = [
+        'display','uninstall','install','install_rpm', 
+        'configure', 'start', 'fetch_keys', SEP,
+        'store_keys', 'clear_known_hosts', 'initscripts', SEP,
+        'sites', 'nodes', 'slices', 'nodegroups', SEP,
+        'init_node','bootcd', 'configure_qemu', 'export_qemu',
+        'kill_all_qemus', 'reinstall_node','start_node', SEP,
+        # better use of time: do this now that the nodes are taking off
+        'plcsh_stress_test', SEP,
+        'nodes_ssh_debug', 'nodes_ssh_boot', 'check_slice', 'check_initscripts', SEP,
+        'check_tcp',  SEP,
+        'force_gather_logs', 'force_kill_qemus', 'force_record_tracker','force_free_tracker',
+        ]
+    other_steps = [ 
+        'stop_all_vservers','fresh_install', 'cache_rpm', 'stop', 'vs_start', SEP,
+        'check_sanity',  SEP,
+        'clean_initscripts', 'clean_nodegroups','clean_all_sites', SEP,
+        'clean_sites', 'clean_nodes', 
+        'clean_slices', 'clean_keys', SEP,
+        'show_boxes', 'list_all_qemus', 'list_qemus', SEP,
+        'db_dump' , 'db_restore', 'cleanup_trackers', 'cleanup_all_trackers',
+        'standby_1 through 20',
+        ]
 
     @staticmethod
     def printable_steps (list):
@@ -268,10 +273,111 @@ class TestPlc:
                 node.kill_qemu()
         return True
 
+    #################### display config
     def display (self):
-        utils.show_plc_spec (self.plc_spec)
+        self.display_pass (1)
+        self.display_pass (2)
         return True
 
+    # entry point
+    def display_pass (self,passno):
+        for (key,val) in self.plc_spec.iteritems():
+            if passno == 2:
+                if key == 'sites':
+                    for site in val:
+                        self.display_site_spec(site)
+                        for node in site['nodes']:
+                            self.display_node_spec(node)
+                elif key=='initscripts':
+                    for initscript in val:
+                        self.display_initscript_spec (initscript)
+                elif key=='slices':
+                    for slice in val:
+                        self.display_slice_spec (slice)
+                elif key=='keys':
+                    for key in val:
+                        self.display_key_spec (key)
+            elif passno == 1:
+                if key not in ['sites','initscripts','slices','keys']:
+                    print '*   ',key,':',val
+
+    def display_site_spec (self,site):
+        print '* ======== site',site['site_fields']['name']
+        for (k,v) in site.iteritems():
+            if k=='nodes':
+                if v: 
+                    print '*       ','nodes : ',
+                    for node in v:  
+                        print node['node_fields']['hostname'],'',
+                    print ''
+            elif k=='users':
+                if v: 
+                    print '*       users : ',
+                    for user in v:  
+                        print user['name'],'',
+                    print ''
+            elif k == 'site_fields':
+                print '*       login_base',':',v['login_base']
+            elif k == 'address_fields':
+                pass
+            else:
+                print '*       ',k,
+                PrettyPrinter(indent=8,depth=2).pprint(v)
+        
+    def display_initscript_spec (self,initscript):
+        print '* ======== initscript',initscript['initscript_fields']['name']
+
+    def display_key_spec (self,key):
+        print '* ======== key',key['name']
+
+    def display_slice_spec (self,slice):
+        print '* ======== slice',slice['slice_fields']['name']
+        for (k,v) in slice.iteritems():
+            if k=='nodenames':
+                if v: 
+                    print '*       nodes : ',
+                    for nodename in v:  
+                        print nodename,'',
+                    print ''
+            elif k=='usernames':
+                if v: 
+                    print '*       users : ',
+                    for username in v:  
+                        print username,'',
+                    print ''
+            elif k=='slice_fields':
+                print '*       fields',':',
+                print 'max_nodes=',v['max_nodes'],
+                print ''
+            else:
+                print '*       ',k,v
+
+    def display_node_spec (self,node):
+        print "*           node",node['name'],"host_box=",node['host_box'],
+        print "hostname=",node['node_fields']['hostname'],
+        print "ip=",node['interface_fields']['ip']
+    
+
+    # another entry point for just showing the boxes involved
+    def display_mapping (self):
+        TestPlc.display_mapping_plc(self.plc_spec)
+        return True
+
+    @staticmethod
+    def display_mapping_plc (plc_spec):
+        print '* MyPLC',plc_spec['name']
+        print '*\tvserver address = root@%s:/vservers/%s'%(plc_spec['hostname'],plc_spec['vservername'])
+        print '*\tIP = %s/%s'%(plc_spec['PLC_API_HOST'],plc_spec['vserverip'])
+        for site_spec in plc_spec['sites']:
+            for node_spec in site_spec['nodes']:
+                TestPlc.display_mapping_node(node_spec)
+
+    @staticmethod
+    def display_mapping_node (node_spec):
+        print '*   NODE %s'%(node_spec['name'])
+        print '*\tqemu box %s'%node_spec['host_box']
+        print '*\thostname=%s'%node_spec['node_fields']['hostname']
+
     ### utility methods for handling the pool of IP addresses allocated to plcs
     # Logic
     # (*) running plcs are recorded in the file named ~/running-test-plcs
@@ -699,10 +805,10 @@ class TestPlc:
         # only useful in empty plcs
         return True
         
-    def nodes_debug_ssh(self):
+    def nodes_ssh_debug(self):
         return self.check_nodes_ssh(debug=True,timeout_minutes=30,silent_minutes=10)
     
-    def nodes_boot_ssh(self):
+    def nodes_ssh_boot(self):
         return self.check_nodes_ssh(debug=False,timeout_minutes=30,silent_minutes=10)
     
     @node_mapper
@@ -817,7 +923,7 @@ class TestPlc:
         self.test_ssh.copy_abs("plcsh-stress-test.py",remote)
         command = location
         command += " -- --check"
-        if self.options.small_test:
+        if self.options.size == 1:
             command +=  " --tiny"
         return ( self.run_in_guest(command) == 0)
 
index ef52a0d..34c178e 100644 (file)
@@ -38,12 +38,20 @@ class TestPool:
 
     def next_free (self):
         # if preferred is provided, let's re-order
+        if self.options.quiet:
+            print 'TestPool is looking for a free IP address',
         for (host,ip,user_data) in self.pool:
             if host in self.busy:
                 continue
-            utils.header('TestPool : checking %s'%host)
+            if not self.options.quiet:
+                utils.header('TestPool : checking %s'%host)
+            if self.options.quiet:
+                print '.',
             if not TestPool.check_ping (host):
-                utils.header('%s is available'%host)
+                if not self.options.quiet:
+                    utils.header('%s is available'%host)
+                else:
+                    print ''
                 self.busy.append(host)
                 return (host,ip,user_data)
             else:
index c49b48c..1420a53 100644 (file)
@@ -102,7 +102,7 @@ class TestSlice:
                 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("id;hostname")==0
+                date = date_test_ssh.run("echo hostname ; hostname; echo id; id; echo uname -a ; uname -a")==0
                 if date:
                     utils.header("Successfuly entered slice %s on %s"%(self.name(),hostname))
                     tocheck.remove(hostname)
index 2472712..e4b6c3d 100644 (file)
@@ -25,8 +25,8 @@ def config (plcs, options):
                                'PLC_WWW_HOST':plc_box,
                                'name':'%s-'+options.arch } ) 
                        ],
-              'node': [ ('deferred01' , {'host_box': node_box1 } ),
-                        ('deferred02' , {'host_box': node_box2 } ),
+              'node': [ ('node1' , {'host_box': node_box1 } ),
+                        ('node2' , {'host_box': node_box2 } ),
                         ],
               }
     
index 48862a4..22d75ea 100644 (file)
@@ -1,5 +1,6 @@
 # map all nodes onto the avail. pool
 
+import utils
 from TestMapper import TestMapper
 from TestPool import TestPool
 
@@ -22,12 +23,12 @@ def config (plcs, options):
     all_nodenames = test_mapper.node_names()
     maps = []
     for nodename in all_nodenames:
-        if len(options.ips_node) != 0:
-            ip=options.ips_node[0]
-            options.ips_node=options.ips_node[1:]
-            (hostname,ip,mac)=test_pool.locate(ip)
+        if options.ips_node:
+            ip=options.ips_node.pop()
+            (hostname,ip,mac)=test_pool.locate(ip,True)
         else:
             (hostname,ip,mac) = test_pool.next_free()
+        utils.header('Attaching node %s to %s (%s)'%(nodename,hostname,ip))
         node_dict= {'node_fields:hostname':hostname,
                     'interface_fields:ip':ip, 
                     'interface_fields:mac':mac,
index 6e63fe3..de02c67 100644 (file)
@@ -15,23 +15,20 @@ def config (plcs,options):
 
     test_pool = TestPool (onelab_plcs_pool,options)
 
-    if len(options.ips_plc) != 0:
-        utils.header('Using user-provided IPS:\nips_plc=%r'%options.ips_plc)
-        options.ips_plc.reverse()
-
     plc_counter=0
     for plc in plcs:
         try:
-            if len(options.ips_plc) != 0:
-                ip=options.ips_plc[0]
-                options.ips_plc=options.ips_plc[1:]
-                (hostname,ip,mac)=test_pool.locate(ip)
-                utils.header("Using user-provided %s %s for plc %s"%(
-                        hostname,ip,plc['name']))
+            if options.ips_plc :
+                ip=options.ips_plc.pop()
+                (hostname,ip,mac)=test_pool.locate(ip,True)
+                if not options.quiet:
+                    utils.header("Using user-provided %s %s for plc %s"%(
+                            hostname,ip,plc['name']))
             else:
                 (hostname,ip,mac)=test_pool.next_free()
-                utils.header("Using auto-allocated %s %s for plc %s"%(
-                        hostname,ip,plc['name']))
+                if not options.quiet:
+                    utils.header("Using auto-allocated %s %s for plc %s"%(
+                            hostname,ip,plc['name']))
 
             ### rewrite fields in plc
             # compute a helpful vserver name - remove domain in hostname
index 08051e9..1329670 100644 (file)
@@ -1,17 +1,41 @@
 # the defaults
 import utils
+import TestPlc
+
+# this default is for the OneLab test infrastructure
 
 def config (plc_specs, options):
 
+#    for step in ['main','1testbox','1nodes','1vservers']:
+#        module=__import__(
+
     import config_main
     plcs = config_main.config([],options)
+    if options.verbose:
+        print '======================================== AFTER main'
+        for plc in plcs: TestPlc.TestPlc.display_mapping_plc(plc)
+        print '========================================'
+
     import config_1testbox
     plcs = config_1testbox.config (plcs,options)
+    if options.verbose:
+        print '======================================== AFTER testbox'
+        for plc in plcs: TestPlc.TestPlc.display_mapping_plc(plc)
+        print '========================================'
+
     import config_1vnodes
     plcs = config_1vnodes.config(plcs,options)
+    if options.verbose:
+        print '======================================== AFTER vnodes'
+        for plc in plcs: TestPlc.TestPlc.display_mapping_plc(plc)
+        print '========================================'
 
     import config_1vservers
     plcs = config_1vservers.config (plcs,options)
+    if options.verbose:
+        print '======================================== AFTER vservers'
+        for plc in plcs: TestPlc.TestPlc.display_mapping_plc(plc)
+        print '========================================'
 
     return plcs
 
index 41aeac4..42c8410 100644 (file)
@@ -7,48 +7,27 @@
 
 # values like 'hostname', 'ip' and the like my be rewritten later with a TestPool object
 
-def nodes(options):
-    nodes= [{'name':'node1',
-             'node_fields': {'hostname': 'deferred01',
+def nodes(options,index):
+    return [{'name':'node%d'%index,
+             'node_fields': {'hostname': 'deferred-nodename%d'%index,
                              'model':'qemu/minhw', } ,
-             'host_box': 'deferred-testbox01',
+             'host_box': 'deferred-node-hostbox-%d'%index,
              'owner' : 'pi',
              'nodegroups' : 'mynodegroup',
              'interface_fields': { 'method':'static',
-                                 'type':'ipv4',
-                                 'ip':'xxx-deferred-xxx',
-                                 'gateway':'xxx-deferred-xxx',
-                                 'network':'xxx-deferred-xxx',
-                                 'broadcast':'xxx-deferred-xxx',
-                                 'netmask':'xxx-deferred-xxx',
-                                 'dns1': 'xxx-deferred-xxx',
-                                 'dns2': 'xxx-deferred-xxx',
-                                 },
-             },
-            {'name':'node2',
-             'node_fields': {'hostname': 'deferred02',
-                             'model':'qemu/minhw', } ,
-             'host_box': 'deferred-testbox02',
-             'owner' : 'pi',
-             'interface_fields': { 'method':'static',
-                                 'type':'ipv4',
-                                 'ip':'xxx-deferred-xxx',
-                                 'gateway':'xxx-deferred-xxx',
-                                 'network':'xxx-deferred-xxx',
-                                 'broadcast':'xxx-deferred-xxx',
-                                 'netmask':'xxx-deferred-xxx',
-                                 'dns1': 'xxx-deferred-xxx',
-                                 'dns2': 'xxx-deferred-xxx',
-                                 },
-             },
-            ]
-    if options.small_test:
-        return [nodes[0]]
-    else:
-        return nodes
+                                   'type':'ipv4',
+                                   'ip':'xxx-deferred-xxx',
+                                   'gateway':'xxx-deferred-xxx',
+                                   'network':'xxx-deferred-xxx',
+                                   'broadcast':'xxx-deferred-xxx',
+                                   'netmask':'xxx-deferred-xxx',
+                                   'dns1': 'xxx-deferred-xxx',
+                                   'dns2': 'xxx-deferred-xxx',
+                                   },
+             }]
 
-def all_nodenames (options):
-    return [ node['name'] for node in nodes(options)]
+def all_nodenames (options,index):
+    return [ node['name'] for node in nodes(options,index)]
 
 def users (options) :
     domain="onelab.eu"
@@ -88,7 +67,7 @@ def users (options) :
 def all_usernames (options):
     return [ user['name'] for user in users(options)]
 
-def sites (options):
+def sites (options,index):
     return [ {'site_fields' : {'name':'mainsite',
                                'login_base':'main',
                                'abbreviated_name':'PLanettest',
@@ -102,7 +81,7 @@ def sites (options):
                                   'country':'france',
                                   },
               'users' : users(options),
-              'nodes': nodes(options),
+              'nodes': nodes(options,index),
             }]
 
 ##########
@@ -137,14 +116,14 @@ BO+VyPNWF+kDNI8mSUwi7jLW6liMdhNOmDaSX0+0X8CHtK898xM=
 -----END RSA PRIVATE KEY-----
 """
 
-def keys (options):
+def keys (options,index):
     return [ {'name': 'key1',
               'private' : private_key,
               'key_fields' : {'key_type':'ssh',
                               'key': public_key}}
              ]
 
-def initscripts(options): 
+def initscripts(options,index): 
     initscripts= [ { 'initscript_fields' : 
                      { 'enabled' : True,
                        'name':'script1',
@@ -156,93 +135,77 @@ def initscripts(options):
                        'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 2; date) > /tmp/script2.stamp \n ',
                        }},
                    ]
-    if options.small_test:
-        return [initscripts[0]]
-    else:
-        return initscripts
+    return initscripts
 
-def slices (options):
-    both = [ { 'slice_fields': {'name':'main_slicetest1',
+def slices (options,index):
+    return [ { 'slice_fields': {'name':'main_slicetest%d'%index,
                                 'instantiation':'plc-instantiated',
-                                'url':'http://foo@ffo.com',
-                                'description':'testslice the first slice for the site testsite',
-                                'max_nodes':2
+                                'url':'http://foo%d@foo.com'%index,
+                                'description':'testslice number %d'%index,
+                                'max_nodes':2,
                                 },
                'usernames' : [ 'pi','tech','techuser' ],
-               'nodenames' : all_nodenames(options),
-               'initscriptname' : 'script1',
-               'sitename' : 'main',
-               'owner' : 'pi',
-               },
-             { 'slice_fields': {'name':'main_slicetest2',
-                                'instantiation':'plc-instantiated',
-                                'url':'http://foo2@ffo2.com',
-                                'description':'testslice the second slice for the site testsite',
-                                'max_nodes':100
-                                },
-               'usernames' : [ 'user', 'pitech' ],
-               'nodenames' : all_nodenames(options),
-               'initscriptname' : 'script2',
+               'nodenames' : all_nodenames(options,index),
+               'initscriptname' : 'script%d'%index,
                'sitename' : 'main',
                'owner' : 'pi',
                }]
-    if options.small_test:
-        return [both[0]]
-    else:
-        return both
-
 
-def all_slicenames (options):
-    return [ slice['slice_fields']['name'] for slice in slices(options)]
+def all_slicenames (options,index):
+    return [ slice['slice_fields']['name'] for slice in slices(options,index)]
 
-def tcp_tests (options):
-    all_tests = [ 
-        # local test
-        { 'server_node': 'node1',
-          'server_slice' : 'main_slicetest1',
-          'client_node' : 'node1',
-          'client_slice' : 'main_slicetest1',
-          'port' : 2000,
-          },
-        # remote test
-        { 'server_node': 'node1',
-          'server_slice' : 'main_slicetest1',
-          'client_node' : 'node2',
-          'client_slice' : 'main_slicetest1',
-          'port' : 4000,
-          },
-        ]
-    if options.small_test:
-        return [all_tests[0]]
+def tcp_tests (options,index):
+    if index == 1:
+        return [
+            # local test
+            { 'server_node': 'node1',
+              'server_slice' : 'main_slicetest1',
+              'client_node' : 'node1',
+              'client_slice' : 'main_slicetest1',
+              'port' : 2000,
+              }]
+    elif index == 2:
+        return [
+            # remote test
+            { 'server_node': 'node1',
+              'server_slice' : 'main_slicetest1',
+              'client_node' : 'node2',
+              'client_slice' : 'main_slicetest2',
+              'port' : 4000,
+              },
+            ]
     else:
-        return all_tests
+        return []
              
-def plc (options) :
+def plc (options,index) :
     return { 
-        'name' : 'onetest',
+        'name' : 'onetest%d'%index,
         # as of yet, not sure we can handle foreign hosts, but this is required though
-        'hostname' : 'xxx-deferred-xxx',
+        'hostname' : 'deferred-myplc-hostbox-%d'%index,
         # set these two items to run within a vserver
-        # 'vservername': '138.96.250.131'
-        # 'vserverip': '138.96.250.131'
+        'vservername': 'deferred-vservername',
+        'vserverip': 'deferred-vserverip',
         'role' : 'root',
         'PLC_ROOT_USER' : 'root@test.onelab.eu',
         'PLC_ROOT_PASSWORD' : 'test++',
         'PLC_NAME' : 'TestLab',
         'PLC_MAIL_ENABLED':'true',
         'PLC_MAIL_SUPPORT_ADDRESS' : 'thierry.parmentelat@sophia.inria.fr',
-        'PLC_DB_HOST' : 'test.onelab.eu',
-        'PLC_API_HOST' : 'test.onelab.eu',
-        'PLC_WWW_HOST' : 'test.onelab.eu',
-        'PLC_BOOT_HOST' : 'test.onelab.eu',
-        'PLC_NET_DNS1' : 'xxx-deferred-xxx',
-        'PLC_NET_DNS2' : 'xxx-deferred-xxx',
-        'sites' : sites(options),
-        'keys' : keys(options),
-        'initscripts': initscripts(options),
-        'slices' : slices(options),
-        'tcp_test' : tcp_tests(options),
+        'PLC_DB_HOST' : 'deferred-myplc-hostname',
+        'PLC_API_HOST' : 'deferred-myplc-hostname',
+        'PLC_WWW_HOST' : 'deferred-myplc-hostname',
+        'PLC_BOOT_HOST' : 'deferred-myplc-hostname',
+        'PLC_NET_DNS1' : 'deferred-dns-1',
+        'PLC_NET_DNS2' : 'deferred-dns-2',
+        'sites' : sites(options,index),
+        'keys' : keys(options,index),
+        'initscripts': initscripts(options,index),
+        'slices' : slices(options,index),
+        'tcp_test' : tcp_tests(options,index),
     }
 
 def config (plc_specs,options):
-    return plc_specs + [ plc(options) ]
+    result=plc_specs
+    for i in range (options.size):
+        result += [ plc(options,i+1) ]
+    return result
index 2859642..df34cd9 100644 (file)
@@ -71,87 +71,3 @@ def show_options (message,options):
 
 
 
-#################### display config
-# entry point
-def show_plc_spec (plc_spec):
-    show_plc_spec_pass (plc_spec,1)
-    show_plc_spec_pass (plc_spec,2)
-
-def show_plc_spec_pass (plc_spec,passno):
-    for (key,val) in plc_spec.iteritems():
-        if passno == 2:
-            if key == 'sites':
-                for site in val:
-                    show_site_spec(site)
-                    for node in site['nodes']:
-                        show_node_spec(node)
-            elif key=='initscripts':
-                for initscript in val:
-                    show_initscript_spec (initscript)
-            elif key=='slices':
-                for slice in val:
-                    show_slice_spec (slice)
-            elif key=='keys':
-                for key in val:
-                    show_key_spec (key)
-        elif passno == 1:
-            if key not in ['sites','initscripts','slices','keys']:
-                print '*   ',key,':',val
-
-def show_site_spec (site):
-    print '* ======== site',site['site_fields']['name']
-    for (k,v) in site.iteritems():
-        if k=='nodes':
-            if v: 
-                print '*       ','nodes : ',
-                for node in v:  
-                    print node['node_fields']['hostname'],'',
-                print ''
-        elif k=='users':
-            if v: 
-                print '*       users : ',
-                for user in v:  
-                    print user['name'],'',
-                print ''
-        elif k == 'site_fields':
-            print '*       login_base',':',v['login_base']
-        elif k == 'address_fields':
-            pass
-        else:
-            print '*       ',k,
-            PrettyPrinter(indent=8,depth=2).pprint(v)
-        
-def show_initscript_spec (initscript):
-    print '* ======== initscript',initscript['initscript_fields']['name']
-
-def show_key_spec (key):
-    print '* ======== key',key['name']
-
-def show_slice_spec (slice):
-    print '* ======== slice',slice['slice_fields']['name']
-    for (k,v) in slice.iteritems():
-        if k=='nodenames':
-            if v: 
-                print '*       nodes : ',
-                for nodename in v:  
-                    print nodename,'',
-                print ''
-        elif k=='usernames':
-            if v: 
-                print '*       users : ',
-                for username in v:  
-                    print username,'',
-                print ''
-        elif k=='slice_fields':
-            print '*       fields',':',
-            print 'max_nodes=',v['max_nodes'],
-            print ''
-        else:
-            print '*       ',k,v
-
-def show_node_spec (node):
-    print "*           node",node['name'],"host_box=",node['host_box'],
-    print "hostname=",node['node_fields']['hostname'],
-    print "ip=",node['interface_fields']['ip']
-    
-