Add support for cgexec to the Cgroup class.
Signed-off-by: Tom Hromatka <[email protected]>
---
ftests/cgroup.py | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/ftests/cgroup.py b/ftests/cgroup.py
index 31e06bd79b4a..32b9530ead31 100644
--- a/ftests/cgroup.py
+++ b/ftests/cgroup.py
@@ -783,3 +783,34 @@ class Cgroup(object):
raise re
return ret
+
+ # exec is a keyword in python, so let's name this function cgexec
+ @staticmethod
+ def cgexec(config, controller, cgname, cmdline, sticky=False,
+ cghelp=False):
+ """cgexec equivalent method
+ """
+ cmd = list()
+
+ if not config.args.container:
+ cmd.append('sudo')
+ cmd.append(Cgroup.build_cmd_path('cgexec'))
+ cmd.append('-g')
+ cmd.append('{}:{}'.format(controller, cgname))
+
+ if sticky:
+ cmd.append('--sticky')
+
+ if isinstance(cmdline, str):
+ cmd.append(cmdline)
+ elif isinstance(cmdline, list):
+ for entry in cmdline:
+ cmd.append(entry)
+
+ if cghelp:
+ cmd.append('-h')
+
+ if config.args.container:
+ return config.container.run(cmd, shell_bool=True)
+ else:
+ return Run.run(cmd, shell_bool=True)
--
2.25.1
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel