import subprocess
import resource
-import mountimpl
-import runcmd
-import utmp
import vserverimpl
import cpulimit, bwlimit
# 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
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)
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 not os.WIFEXITED(ret) or 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)