]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
cgroup.py: Add support for lssubsys
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 24 Mar 2021 18:56:23 +0000 (18:56 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 8 Apr 2021 16:26:45 +0000 (10:26 -0600)
Add support for lssubsys to the Cgroup class.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/cgroup.py

index 50a8856fd31785ff29440b7d0e22b5aebbb11dbb..a3f394e2ac8058b49c299301c89968eafbe71b9d 100644 (file)
@@ -655,3 +655,38 @@ class Cgroup(object):
             return config.container.run(cmd)
         else:
             return Run.run(cmd)
+
+    @staticmethod
+    def lssubsys(config, ls_all=False, cghelp=False, hierarchies=False,
+                 mount_points=False, all_mount_points=False):
+        cmd = list()
+
+        cmd.append(Cgroup.build_cmd_path('lssubsys'))
+
+        if ls_all:
+            cmd.append('-a')
+
+        if cghelp:
+            cmd.append('-h')
+
+        if hierarchies:
+            cmd.append('-i')
+
+        if mount_points:
+            cmd.append('-m')
+
+        if all_mount_points:
+            cmd.append('-M')
+
+        if config.args.container:
+            ret = config.container.run(cmd)
+        else:
+            try:
+                ret = Run.run(cmd)
+            except RunError as re:
+                if "profiling" in re.stderr:
+                    ret = re.stdout
+                else:
+                    raise re
+
+        return ret