Пример #1
0
    def cgexec(into, subcommand):
        """execs command into given cgroup(s)."""

        cgrps = [cgrp.split(':') for cgrp in into]
        subsystems = set([subsystem for (subsystem, path) in cgrps])
        cgroups.ensure_mounted(subsystems)

        for (subsystem, path) in cgrps:
            pathplus = path.split('=')
            if len(pathplus) == 2:
                group = os.path.dirname(pathplus[0])
                pseudofile = os.path.basename(pathplus[0])
                value = pathplus[1]
                cgroups.set_value(subsystem, group, pseudofile, value)
            else:
                cgroups.create(subsystem, path)
                cgroups.join(subsystem, path)

        if subcommand:
            execargs = list(subcommand)
            os.execvp(execargs[0], execargs)
Пример #2
0
 def test_ensure_mounted_missing(self):
     """Checks that missing subsystem is mounted."""
     cgroups.ensure_mounted(['cpu', 'memory'])
     treadmill.cgroups.mount.assert_called_with('memory')