- def __do_chcontext(self, state_file):
-
- if state_file:
- print >>state_file, "%u" % self.ctx
- state_file.close()
-
- if vserverimpl.chcontext(self.ctx, vserverimpl.text2bcaps(self.get_capabilities_config())):
- self.set_resources(True)
- vserverimpl.setup_done(self.ctx)
-
- def __prep(self, runlevel):
-
- """ Perform all the crap that the vserver script does before
- actually executing the startup scripts. """
-
- # remove /var/run and /var/lock/subsys files
- # but don't remove utmp from the top-level /var/run
- RUNDIR = "/var/run"
- LOCKDIR = "/var/lock/subsys"
- filter_fn = lambda fs: filter(lambda f: f != 'utmp', fs)
- garbage = reduce((lambda (out, ff), (dir, subdirs, files):
- (out + map((dir + "/").__add__, ff(files)),
- lambda fs: fs)),
- list(os.walk(RUNDIR)),
- ([], filter_fn))[0]
- garbage += filter(os.path.isfile, map((LOCKDIR + "/").__add__,
- os.listdir(LOCKDIR)))
- if False:
- for f in garbage:
- os.unlink(f)
-
- # set the initial runlevel
- vserverimpl.setrunlevel(RUNDIR + "/utmp", runlevel)
-
- # mount /proc and /dev/pts
- self.__do_mount("none", self.dir, "/proc", "proc")
- # XXX - magic mount options
- self.__do_mount("none", self.dir, "/dev/pts", "devpts", 0, "gid=5,mode=0620")
-
- def __do_mount(self, *mount_args):
-
- try:
- vserverimpl.mount(*mount_args)
- except OSError, ex:
- if ex.errno == errno.EBUSY:
- # assume already mounted
- return
- raise ex
-