X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=python%2Fvserver.py;h=de8c16460d5df66b28e998bd4300630c2a99042b;hb=9b74b47baed4fe49c1c08226ba56e59512c6f269;hp=b621e4c6602eaf7bac11a0c98f5cda5292059e55;hpb=da4283f4995283be5020e58eaf7fb02d014a07da;p=util-vserver.git diff --git a/python/vserver.py b/python/vserver.py index b621e4c..de8c164 100644 --- a/python/vserver.py +++ b/python/vserver.py @@ -1,6 +1,6 @@ # Copyright 2005 Princeton University -#$Id: vserver.py,v 1.71 2007/08/02 15:26:42 dhozac Exp $ +#$Id: vserver.py,v 1.72 2007/08/02 16:01:59 dhozac Exp $ import errno import fcntl @@ -14,9 +14,6 @@ import traceback import subprocess import resource -import mountimpl -import runcmd -import utmp import vserverimpl import cpulimit, bwlimit @@ -205,9 +202,6 @@ class VServer: minimum = int(self.config.get("rlimits/%s.min"%type.lower(),VC_LIM_KEEP)) return (hard,soft,minimum) - def set_WHITELISTED_config(self,whitelisted): - self.config.update('whitelisted', whitelisted) - def set_capabilities(self, capabilities): return vserverimpl.setbcaps(self.ctx, vserverimpl.text2bcaps(capabilities)) @@ -399,18 +393,18 @@ class VServer: # set the initial runlevel f = open(RUNDIR + "/utmp", "w") - utmp.set_runlevel(f, runlevel) + vserverimpl.setrunlevel(f, runlevel) f.close() # mount /proc and /dev/pts - self.__do_mount("none", "/proc", "proc") + self.__do_mount("none", self.dir, "/proc", "proc") # XXX - magic mount options - self.__do_mount("none", "/dev/pts", "devpts", 0, "gid=5,mode=0620") + self.__do_mount("none", self.dir, "/dev/pts", "devpts", 0, "gid=5,mode=0620") def __do_mount(self, *mount_args): try: - mountimpl.mount(*mount_args) + vserverimpl.mount(*mount_args) except OSError, ex: if ex.errno == errno.EBUSY: # assume already mounted @@ -462,7 +456,7 @@ class VServer: cmd_args = [cmd[0]] + map(lambda x: x % arg_subst, cmd[1:]) print >>log, "executing '%s'" % " ".join(cmd_args) - os.spawnvp(os.P_WAIT,cmd[0],cmd_args) + os.spawnvp(os.P_NOWAIT,cmd[0],cmd_args) except: traceback.print_exc() os._exit(1) @@ -511,10 +505,17 @@ class VServer: def create(vm_name, static = False, ctor = VServer): - options = [] + options = ['vuseradd'] if static: options += ['--static'] - runcmd.run('vuseradd', options + [vm_name]) + ret = os.spawnvp(os.P_WAIT, 'vuseradd', options + [vm_name]) + if !os.WIFEXITED(ret) || os.WEXITSTATUS(ret) != 0: + out = "system command ('%s') " % options + if os.WIFEXITED(ret): + out += "failed, rc = %d" % os.WEXITSTATUS(ret) + else: + out += "killed by signal %d" % os.WTERMSIG(ret) + raise SystemError, out vm_id = pwd.getpwnam(vm_name)[2] return ctor(vm_name, vm_id)