fixed the sysconfig/network issue - was due to a misconfig of util-vserver
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 23 Jan 2008 17:43:39 +0000 (17:43 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 23 Jan 2008 17:43:39 +0000 (17:43 +0000)
support for vserver/native myplcs hosted on remote boxes

system/TestMain.py
system/TestPlc.py
system/config_onelab_vserver.py
system/config_wifilab.py

index 668241f..303a7ca 100755 (executable)
@@ -44,18 +44,21 @@ class TestMain:
             setattr(parser.values,option.dest,value.split())
 
     def test_main (self):
+        steps_message="Defaut steps are\n\t%s"%(" ".join(TestMain.default_steps))
+        steps_message += "\nOther useful steps are\n\t %s"%(" ".join(TestMain.other_steps))
         usage = """usage: %%prog [options] steps
-myplc-url defaults to the last value used, as stored in MYPLC-URL,
+myplc-url defaults to the last value used, as stored in arg-myplc-url,
    no default
-build-url defaults to the last value used, as stored in BUILD-URL
+build-url defaults to the last value used, as stored in arg-build-url
    or %s
-config defaults to the last value used, as stored in CONFIG,
+config defaults to the last value used, as stored in arg-config,
    or %r
-ips defaults to the last value used, as stored in IPS,
+ips defaults to the last value used, as stored in arg-ips,
    default is to use IP scanning
-steps refer to a method in TestPlc or to a step_* module"""%(TestMain.default_build_url,TestMain.default_config)
-        usage += "\n  Defaut steps are %r"%TestMain.default_steps
-        usage += "\n  Other useful steps are %r"%TestMain.other_steps
+steps refer to a method in TestPlc or to a step_* module
+===
+"""%(TestMain.default_build_url,TestMain.default_config)
+        usage += steps_message
         parser=OptionParser(usage=usage,version=self.subversion_id)
         parser.add_option("-u","--url",action="store", dest="myplc_url", 
                           help="myplc URL - for locating build output")
@@ -63,16 +66,18 @@ steps refer to a method in TestPlc or to a step_* module"""%(TestMain.default_bu
                           help="Build URL - for using vtest-init-vserver.sh in native mode")
         parser.add_option("-c","--config",action="callback", callback=TestMain.optparse_list, dest="config",
                           nargs=1,type="string",
-                          help="config module - can be set multiple times, or use quotes")
+                          help="Config module - can be set multiple times, or use quotes")
         parser.add_option("-a","--all",action="store_true",dest="all_steps", default=False,
-                          help="Runs all default steps")
+                          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("-s","--state",action="store",dest="dbname",default=None,
                            help="Used by db_dump and db_restore")
         parser.add_option("-d","--display", action="store", dest="display", default='bellami.inria.fr:0.0',
-                          help="set DISPLAY for vmplayer")
+                          help="Set DISPLAY for vmplayer")
         parser.add_option("-i","--ip",action="callback", callback=TestMain.optparse_list, dest="ips",
                           nargs=1,type="string",
-                          help="allows to specify the set of IP addresses to use in vserver mode (disable scanning)")
+                          help="Specify the set of IP addresses to use in vserver mode (disable scanning)")
         parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False, 
                           help="Run in verbose mode")
         parser.add_option("-n","--dry-run", action="store_true", dest="dry_run", default=False,
@@ -84,6 +89,9 @@ steps refer to a method in TestPlc or to a step_* module"""%(TestMain.default_bu
                 self.options.steps=TestMain.default_steps
             elif self.options.dry_run:
                 self.options.steps=TestMain.default_steps
+            elif self.options.list_steps:
+                print steps_message
+                sys.exit(1)
             else:
                 print 'No step found (do you mean -a ? )'
                 print "Run %s --help for help"%sys.argv[0]                        
@@ -91,14 +99,11 @@ steps refer to a method in TestPlc or to a step_* module"""%(TestMain.default_bu
         else:
             self.options.steps = self.args
 
-        # display display
-        utils.header('X11 display : %s'% self.options.display)
-
         # handle defaults and option persistence
-        for (recname,filename,default) in ( ('myplc_url','MYPLC-URL',"") , 
-                                            ('build_url','BUILD-URL',TestMain.default_build_url) ,
-                                            ('ips','IPS',[]) , 
-                                            ('config','CONFIG',TestMain.default_config) , ) :
+        for (recname,filename,default) in ( ('myplc_url','arg-myplc-url',"") , 
+                                            ('build_url','arg-build-url',TestMain.default_build_url) ,
+                                            ('ips','arg-ips',[]) , 
+                                            ('config','arg-config',TestMain.default_config) , ) :
             print 'handling',recname
             path="%s/%s"%(self.path,filename)
             is_list = isinstance(default,list)
index 1c370d6..fee41e0 100644 (file)
@@ -37,6 +37,9 @@ class TestPlc:
         else:
             return name+"[chroot]"
 
+    def is_local (self):
+        return self.plc_spec['hostname'] == 'localhost'
+
     # define the API methods on this object through xmlrpc
     # would help, but not strictly necessary
     def connect (self):
@@ -50,10 +53,10 @@ class TestPlc:
             return "chroot /plc/root %s"%command
 
     def ssh_command(self,command):
-        if self.plc_spec['hostname'] == "localhost":
+        if self.is_local():
             return command
         else:
-            return "ssh " + self.plc_spec['hostname'] + " " + command
+            return "ssh %s sh -c '\"%s\"'"%(self.plc_spec['hostname'],command)
 
     def full_command(self,command):
         return self.ssh_command(self.run_command(command))
@@ -65,7 +68,7 @@ class TestPlc:
 
     # xxx quick n dirty
     def run_in_guest_piped (self,local,remote):
-        return utils.system(local+" | "+self.full_command(command))
+        return utils.system(local+" | "+self.full_command(remote))
 
     def auth_root (self):
        return {'Username':self.plc_spec['PLC_ROOT_USER'],
@@ -123,22 +126,24 @@ class TestPlc:
     # xxx this would not work with hostname != localhost as mylc-init-vserver was extracted locally
     def install_vserver(self,options):
         # we need build dir for vtest-init-vserver
-        build_dir=self.path+"/build"
-        if not os.path.isdir(build_dir):
-            if utils.system("svn checkout %s %s"%(options.build_url,build_dir)) != 0:
-                raise Exception,"Cannot checkout build dir"
+        if self.is_local():
+            # a full path for the local calls
+            build_dir=self.path+"/build"
+        else:
+            # use a standard name - will be relative to HOME 
+            build_dir="tests-system-build"
+        build_checkout = "svn checkout %s %s"%(options.build_url,build_dir)
+        if self.run_in_host(build_checkout) != 0:
+            raise Exception,"Cannot checkout build dir"
         # the repo url is taken from myplc-url 
         # with the last two steps (i386/myplc...) removed
         repo_url = options.myplc_url
         repo_url = os.path.dirname(repo_url)
         repo_url = os.path.dirname(repo_url)
-        command="%s/vtest-init-vserver.sh %s %s -- --interface eth0:%s"%\
+        create_vserver="%s/vtest-init-vserver.sh %s %s -- --interface eth0:%s"%\
             (build_dir,self.vservername,repo_url,self.vserverip)
-        if utils.system(command) != 0:
+        if self.run_in_host(create_vserver) != 0:
             raise Exception,"Could not create vserver for %s"%self.vservername
-        # xxx temporary - initialize /etc/sysconfig/network
-        network="NETWORKING=yes\nHOSTNAME=%s\n"%self.plc_spec['vserverhostname']
-        file("/vservers/%s/etc/sysconfig/network"%self.vservername,"w").write(network)
         return True
 
     def install(self,options):
@@ -151,8 +156,8 @@ class TestPlc:
     def install_rpm_chroot(self,options):
         utils.header('Installing from %s'%options.myplc_url)
         url=options.myplc_url
-        utils.system('rpm -Uvh '+url)
-        utils.system('service plc mount')
+        self.run_in_host('rpm -Uvh '+url)
+        self.run_in_host('service plc mount')
         return True
 
     def install_rpm_vserver(self,options):
@@ -185,7 +190,7 @@ class TestPlc:
         fileconf.write('q\n')
         fileconf.close()
         utils.system('cat %s'%tmpname)
-        self.run_in_guest('plc-config-tty < %s'%tmpname)
+        self.run_in_guest_piped('cat %s'%tmpname,'plc-config-tty')
         utils.system('rm %s'%tmpname)
         return True
 
index 3b0d1cf..c1cef44 100644 (file)
@@ -47,8 +47,6 @@ def config (plcs,options):
             vservername = "%s-%d-%s" % (vservername,plc_counter,simplehostname)
         plc['vservername']=vservername
         plc['vserverip']=ip
-        # temporary - for /etc/sysconfig/networking
-        plc['vserverhostname']=hostname
         plc['name'] = "%s_%s"%(plc['name'],simplehostname)
         utils.header("Attaching plc %s to vserver %s (%s)"%\
                          (plc['name'],plc['vservername'],plc['vserverip']))
index 28101c6..e78c161 100644 (file)
@@ -156,7 +156,7 @@ def plc () :
     return { 
         'name' : 'wifilab',
         # as of yet, not sure we can handle foreign hosts, but this is required though
-        'hostname' : 'localhost',
+        'hostname' : 'pdx',
         # set these two items to run within a vserver
         # 'vservername': '138.96.250.131'
         # 'vserverip': '138.96.250.131'