simpler yet, no need to trigger rc at all now that we use vserver .. start
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 21 Jun 2010 14:52:27 +0000 (14:52 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 21 Jun 2010 14:52:27 +0000 (14:52 +0000)
python/vserver.py

index c6a1cc7..315edbb 100644 (file)
@@ -133,10 +133,6 @@ class VServerConfig:
 
 class VServer:
 
-    # 2010 June 21 - Thierry 
-    # the slice initscript now gets invoked through rc - see sliver_vs.py in nodemanager
-    INITSCRIPTS = [('/etc/rc.d/rc', '%(runlevel)d')]
-
     def __init__(self, name, vm_id = None, vm_running = None, logfile=None):
 
         self.name = name
@@ -377,8 +373,10 @@ class VServer:
     def enter(self):
         subprocess.call("/usr/sbin/vserver %s enter" % self.name, shell=True)
 
-    # detach the process that triggers the initscripts
-    # after http://code.activestate.com/recipes/278731/
+    # 2010 June 21 - Thierry 
+    # the slice initscript now gets invoked through rc - see sliver_vs.py in nodemanager
+    # and, rc is triggered as part of vserver .. start 
+    # so we don't have to worry about initscripts at all anymore here
     def start(self, runlevel = 3):
         if os.fork() != 0:
             # Parent should just return.
@@ -396,28 +394,6 @@ class VServer:
                 # start the vserver
                 subprocess.call(["/usr/sbin/vserver",self.name,"start"])
 
-                # execute initscripts
-                for cmd_to_expand in self.INITSCRIPTS:
-                    # enter vserver context
-                    expand = { 'runlevel': runlevel,
-                               'name': self.name, }
-                    cmd = [ x % expand for x in cmd_to_expand ]
-                    cmd_name = os.path.basename(cmd[0])
-                    cmd_file = "/vservers/" + self.name + cmd[0]
-                    if not os.path.isfile(cmd_file):
-                        self.log("WARNING: could not find %s for %s" % (cmd_file, self.name))
-                        break
-                    self.log("executing %r" % cmd)
-                    try:
-                        logname='/vservers/%s/var/log/%s'%(self.name,cmd_name)
-                        log_fd=os.open(logname,os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0600)
-                        self.log_in_file(log_fd,"Running %r into %s"%(cmd,logname))
-                        self.chroot_call(subprocess.call,cmd,
-                                         stdout=log_fd,stderr=subprocess.STDOUT,
-                                         close_fds=True)
-                    except:  self.log(traceback.format_exc())
-                    finally: os.close(log_fd)
-
             # we get here due to an exception in the grandson process
             except Exception, ex:
                 self.log(traceback.format_exc())