+
+ def set_resources(self):
+
+ """ Called when vserver context is entered for first time,
+ should be overridden by subclass. """
+
+ pass
+
+ def update_resources(self, resources):
+
+ self.config.update(resources)
+
+ # write new values to configuration file
+ self.__update_config_file(self.config_file, resources)
+
+ def init_disk_info(self):
+
+ (self.disk_inodes, self.disk_blocks, size) = vduimpl.vdu(self.dir)
+
+ return size
+
+ def stop(self, signal = signal.SIGKILL):
+
+ vserverimpl.killall(self.ctx, signal)
+ self.vm_running = False
+
+
+
+def create(vm_name, static = False, ctor = VServer):
+
+ options = []
+ if static:
+ options += ['--static']
+ runcmd.run('vuseradd', options + [vm_name])
+ vm_id = pwd.getpwnam(vm_name)[2]
+
+ return ctor(vm_name, vm_id)