Merge "Implement namespace creation method" into stable/train
This commit is contained in:
commit
8353c2adba
|
@ -567,11 +567,19 @@ def create_netns(name, **kwargs):
|
||||||
|
|
||||||
:param name: The name of the namespace to create
|
:param name: The name of the namespace to create
|
||||||
"""
|
"""
|
||||||
try:
|
pid = os.fork()
|
||||||
netns.create(name, libc=_get_cdll())
|
if pid == 0:
|
||||||
except OSError as e:
|
try:
|
||||||
if e.errno != errno.EEXIST:
|
netns.create(name, libc=_get_cdll())
|
||||||
raise
|
except OSError as e:
|
||||||
|
if e.errno != errno.EEXIST:
|
||||||
|
os._exit(1)
|
||||||
|
except Exception:
|
||||||
|
os._exit(1)
|
||||||
|
os._exit(0)
|
||||||
|
else:
|
||||||
|
if os.waitpid(pid, 0)[1]:
|
||||||
|
raise RuntimeError(_('Error creating namespace %s') % name)
|
||||||
|
|
||||||
|
|
||||||
@privileged.default.entrypoint
|
@privileged.default.entrypoint
|
||||||
|
|
Loading…
Reference in New Issue