-def get_cgroup_paths():
- cpusetBase = os.path.join(BASE_DIR, 'cpuset', 'libvirt', 'lxc')
- return filter(os.path.isdir,
- map(lambda f: os.path.join(cpusetBase, f),
- os.listdir(cpusetBase)))
+def get_cgroup_paths(subsystem="cpuset"):
+ subsystem_bases = [
+ # observed on f16-f18
+ os.path.join(BASE_DIR, subsystem, 'libvirt', 'lxc'),
+ # as observed on f20
+ os.path.join(BASE_DIR, subsystem ),
+ # f21
+ os.path.join(BASE_DIR, subsystem, 'machine.slice'),
+ # as observed on f16 libvirt 1.2.1
+ os.path.join(BASE_DIR, subsystem, 'machine'),
+ ]
+ # try several locations and return all the results
+ # get_cgroup_path will sort it out
+
+ # just return all the subdirs in the listed bases
+ return [ subdir
+ # scan the bases
+ for subsystem_base in subsystem_bases if os.path.isdir(subsystem_base)
+ # in each base search the immediate sons that are also dirs
+ for subdir in [ os.path.join(subsystem_base, f) for f in os.listdir(subsystem_base) ]
+ if os.path.isdir(subdir) ]