git://git.onelab.eu
/
util-vserver-pl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove planetlab.* and netns.c as they are no longer used by util-vserver-pl
[util-vserver-pl.git]
/
python
/
vserver.py
diff --git
a/python/vserver.py
b/python/vserver.py
index
796b012
..
a4e828d
100644
(file)
--- a/
python/vserver.py
+++ b/
python/vserver.py
@@
-20,6
+20,7
@@
import cpulimit, bwlimit
from vserverimpl import DLIMIT_INF
from vserverimpl import VC_LIM_KEEP
from vserverimpl import DLIMIT_INF
from vserverimpl import VC_LIM_KEEP
+from vserverimpl import VC_LIM_INFINITY
from vserverimpl import VLIMIT_NSOCK
from vserverimpl import VLIMIT_OPENFD
from vserverimpl import VLIMIT_ANON
from vserverimpl import VLIMIT_NSOCK
from vserverimpl import VLIMIT_OPENFD
from vserverimpl import VLIMIT_ANON
@@
-229,18
+230,25
@@
class VServer:
def set_ipaddresses(self, addresses):
vserverimpl.netremove(self.ctx, "all")
def set_ipaddresses(self, addresses):
vserverimpl.netremove(self.ctx, "all")
- for
a in addresses.split(",")
:
- vserverimpl.netadd(self.ctx,
a
)
+ for
ip in addresses
:
+ vserverimpl.netadd(self.ctx,
ip
)
def set_ipaddresses_config(self, addresses):
def set_ipaddresses_config(self, addresses):
- return # acb
+ ip_addresses = addresses.split(",")
+
+ # add looopback interface
+ if not ip_addresses.__contains__("127.0.0.1"):
+ ip_addresses.append("127.0.0.1")
+
i = 0
i = 0
- for a in addresses.split(","):
- self.config.update("interfaces/%d/ip" % i, a)
+ for ip in ip_addresses:
+ self.config.update("interfaces/%d/ip" % i, ip)
+ # create emtpy nodev files to silent "No device specified for" warnings
+ self.config.update("interfaces/%d/nodev" % i, "")
i += 1
i += 1
- while self.config.unset("interfaces/%d/ip" % i):
+ while self.config.unset("interfaces/%d/ip" % i)
and self.config.update("interfaces/%d/nodev" % i)
:
i += 1
i += 1
- self.set_ipaddresses(addresses)
+ self.set_ipaddresses(
ip_
addresses)
def get_ipaddresses_config(self):
i = 0
def get_ipaddresses_config(self):
i = 0
@@
-389,7
+397,7
@@
class VServer:
os._exit(0) # Exit parent (the first child) of the second child.
# the grandson is the working one
os.chdir('/')
os._exit(0) # Exit parent (the first child) of the second child.
# the grandson is the working one
os.chdir('/')
- os.umask(0)
+ os.umask(0
022
)
try:
# start the vserver
subprocess.call(["/usr/sbin/vserver",self.name,"start"])
try:
# start the vserver
subprocess.call(["/usr/sbin/vserver",self.name,"start"])
@@
-460,12
+468,3
@@
def create(vm_name, static = False, ctor = VServer):
vm_id = pwd.getpwnam(vm_name)[2]
return ctor(vm_name, vm_id)
vm_id = pwd.getpwnam(vm_name)[2]
return ctor(vm_name, vm_id)
-
-
-def close_nonstandard_fds():
- """Close all open file descriptors other than 0, 1, and 2."""
- _SC_OPEN_MAX = 4
- for fd in range(3, os.sysconf(_SC_OPEN_MAX)):
- try: os.close(fd)
- except OSError: pass # most likely an fd that isn't open
-