Commit af7d9cc5 by Stéphane Graber

python3: Drop duplicate add_device_node function

It is now natively implemented in C, the new function takes the same arguments (same order, different names) and has been confirmed to work with lxc-device. Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 2edd7a88
......@@ -160,49 +160,6 @@ class Container(_lxc.Container):
self.network = ContainerNetworkList(self)
def add_device_node(self, path, destpath=None):
"""
Add block/char device to running container.
"""
if not self.running:
return False
if not destpath:
destpath = path
if not os.path.exists(path):
return False
# Lookup the source
path_stat = os.stat(path)
mode = stat.S_IMODE(path_stat.st_mode)
# Allow the target
if stat.S_ISBLK(path_stat.st_mode):
self.set_cgroup_item("devices.allow",
"b %s:%s rwm" %
(int(path_stat.st_rdev / 256),
int(path_stat.st_rdev % 256)))
elif stat.S_ISCHR(path_stat.st_mode):
self.set_cgroup_item("devices.allow",
"c %s:%s rwm" %
(int(path_stat.st_rdev / 256),
int(path_stat.st_rdev % 256)))
# Create the target
rootfs = "/proc/%s/root/" % self.init_pid
container_path = "%s/%s" % (rootfs, destpath)
if os.path.exists(container_path):
os.remove(container_path)
os.mknod(container_path, path_stat.st_mode, path_stat.st_rdev)
os.chmod(container_path, mode)
os.chown(container_path, 0, 0)
return True
def add_device_net(self, name, destname=None):
"""
Add network device to running container.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment