]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
python3: Drop duplicate add_device_node function
authorStéphane Graber <stgraber@ubuntu.com>
Tue, 3 Dec 2013 21:45:13 +0000 (16:45 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 3 Dec 2013 21:47:55 +0000 (16:47 -0500)
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: Stéphane Graber <stgraber@ubuntu.com>
src/python-lxc/lxc/__init__.py

index ed1983d06f68e6a584cbcf99e5c4dc32b5eeec93..c3d840c45b762beb12248a895b02132cb777eb5a 100644 (file)
@@ -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.